summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/search-proto-converge.md5
-rw-r--r--src/Query.zig75
-rw-r--r--src/body_layer.zig1
-rw-r--r--src/exec.zig4
-rw-r--r--test/snapshots/fsearch.golden2
-rw-r--r--test/snapshots/lookrange.golden4
-rw-r--r--test/snapshots/lsprelpath.golden4
-rw-r--r--test/snapshots/stepgrain.golden4
8 files changed, 61 insertions, 38 deletions
diff --git a/docs/search-proto-converge.md b/docs/search-proto-converge.md
index 2e992e3c..99adbc2c 100644
--- a/docs/search-proto-converge.md
+++ b/docs/search-proto-converge.md
@@ -81,8 +81,9 @@ address is a Look as anywhere, on its code a word Look; B2 on line 1 runs
it again. Enter lands the current row, which is the caret's once j / k put
it there, never a row B1 only clicked; Callstack has no current row apart
from its caret, so the two agree except after a click. The current row's
-line mark is no selection: B2 / B3 on it take the word clicked, as on any
-row.
+mark is its own, a row tint drawn from the current row under the match's
+tint (`Query.paintMark`), no selection: a click, a sweep or a chord never
+erases it and B2 / B3 on it take the word clicked, as on any row.
**Enter** puts the keyboard on the current hit in its pane (the +Preview
promoted in place: same slot, serial, rect, an unattached file pane from
diff --git a/src/Query.zig b/src/Query.zig
index a5d33cf4..11db8579 100644
--- a/src/Query.zig
+++ b/src/Query.zig
@@ -1349,18 +1349,15 @@ fn clearPlaces(p: *Pardes, q: *Query, serial: u32, owner_id: ?usize, asked: anyt
// ---- the current row ----
-/// The current row drawn as the visited row is (a line selection), while
-/// the keyboard is on line 1 or elsewhere; on the rows, the cursor itself
-/// is current. Scrolled into view, line 1 kept when it can be.
+/// The current row scrolled into view while the keyboard is on line 1 or
+/// elsewhere, line 1 kept when it can be. Its mark is `paint`'s, drawn
+/// from `current`: no selection, so no click, sweep or chord clears it and
+/// no B2 or B3 borrows it.
fn showCurrent(rp: *Pane) void {
const q = rp.query orelse return;
if (rp.body.cur_row != 0 and rp.focus == .body) return;
- const c = q.current orelse {
- rp.body.msel.active = false;
- return;
- };
+ const c = q.current orelse return;
const r: i32 = @intCast(c + 1);
- rp.body.msel = .{ .active = true, .r0 = r, .r1 = r };
// Typed into, line 1 stays in view whatever the current row: what you
// type is never scrolled away (the live rows start just before the
// current one, so it sits under line 1). Frozen, the row is scrolled to.
@@ -1373,11 +1370,9 @@ fn showCurrent(rp: *Pane) void {
if (r > shown) rp.scrollBy(r - shown) else if (r < off) rp.scrollBy(r - off);
}
-/// The caret on item `i`'s row, the row in view: the current row's own
-/// mark from here (the line selection is for the caret on line 1).
+/// The caret on item `i`'s row, the row in view.
fn caretTo(rp: *Pane, i: usize) void {
const r: i32 = @intCast(i + 1);
- rp.body.msel.active = false;
rp.body.cur_row = r;
rp.body.cur_col = 0;
rp.body.cur_pinned = true;
@@ -1941,6 +1936,25 @@ pub fn tagPrefix(q: *const Query, arena: std.mem.Allocator, path: []const u8) ![
return std.fmt.allocPrint(arena, "{s} {d}/{d}{s}", .{ name, q.k, q.total, more });
}
+/// The current row's mark: a tint the width of the body, painted before
+/// the row's colours, so its match's tint, the places' and any selection
+/// draw over it. Its own, from `current`: no click, sweep or chord clears
+/// it, no B2 or B3 borrows it.
+pub fn paintMark(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, body_h: u16) void {
+ const q = pane.query orelse return;
+ const c = q.current orelse return;
+ const th = p.theme();
+ const mark = colors.mix(th.bg orelse th.tag_bg, th.sel_bg);
+ const tx = r.x + config.GUTTER;
+ const tw = r.w -| config.GUTTER;
+ const col = File.gutterWidth(pane);
+ var row: i32 = 0;
+ while (row < body_h) : (row += 1) {
+ if (pane.wrapAt(row).line != @as(i32, @intCast(c + 1)) or col >= tw) continue;
+ s.tint(tx + col, p.bodyTop(pane, r) + @as(u16, @intCast(row)), tw - col, mark, null);
+ }
+}
+
/// The other places on a hit row's line tinted, from the pane its rows are
/// in (the first is the row's own mark, Output.decorateRow): the current
/// one strongest, as in that pane's text.
@@ -2438,7 +2452,7 @@ test "a language server's list: one answer lands with no pane, several open the
try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
}
-test "B1 on a query pane's rows places the caret and selects, nothing else; j, k and n make a row current, Enter lands the current" {
+test "B1 on a query pane's rows places the caret and selects, nothing else, the current row's mark kept; j, k and n make a row current, Enter lands the current" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
defer p.deinit();
const pane = try p.setTestFile("alpha one\nbeta\nalphabet\ngamma alpha\nalpha two\ndelta\n");
@@ -2449,44 +2463,51 @@ test "B1 on a query pane's rows places the caret and selects, nothing else; j, k
p.acknowledgePanelPresentation(&.{});
const owner_sel = pane.body.primaryRange(pane.file.?.content, 0);
const owner_scroll = pane.file.?.scroll;
- const current = q.current;
+ try std.testing.expectEqual(@as(?usize, 0), q.current);
const place = pane.places.current;
const r = p.rects[qid];
- const y = r.y + qp.tag_rows + 3;
+ const row_y = r.y + qp.tag_rows;
+ const y = row_y + 3;
const x = r.x + config.GUTTER + File.gutterWidth(qp) + 6;
// a click: the caret there, the current row and every other pane as they were
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = y } });
try std.testing.expectEqual(@as(i32, 3), qp.body.cur_row);
- try std.testing.expectEqual(current, q.current);
+ try std.testing.expectEqual(@as(?usize, 0), q.current);
try std.testing.expectEqual(place, pane.places.current);
try std.testing.expectEqual(owner_sel, pane.body.primaryRange(pane.file.?.content, 0));
try std.testing.expectEqual(owner_scroll, pane.file.?.scroll);
- try std.testing.expect(p.panes[qid] != null and queryPane2(p, qid) == null);
+ try std.testing.expect(queryPane2(p, qid) == null);
+ // the current row (1) still marked, no other row (2) is
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const surf = try p.render(frame.allocator());
+ const far = r.x + r.w - 2;
+ try std.testing.expect(!std.meta.eql(surf.at(far, row_y + 1).style.bg, surf.at(far, row_y + 2).style.bg));
// a sweep selects the text it went over, and nothing else
p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = y } });
p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = x + 4, .row = y } });
p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x + 4, .row = y } });
const swept = qp.sel[@backingInt(config.select_button)];
try std.testing.expect(swept.state == .done and swept.r0 == swept.r1 and swept.c1 - swept.c0 == 4);
- try std.testing.expectEqual(current, q.current);
+ try std.testing.expectEqual(@as(?usize, 0), q.current);
try std.testing.expectEqual(owner_sel, pane.body.primaryRange(pane.file.?.content, 0));
- // the keyboard: j onto the next row makes it current, the text follows
+ // the keyboard: n steps from the current row, not the caret's, the caret with it
p.active = qid;
if (qp.body.mode == .insert) p.update(.{ .key = .{ .cp = Key.escape } });
try std.testing.expect(p.panes[qid] != null);
- typeKeys(p, "j");
- try std.testing.expectEqual(@as(i32, 4), qp.body.cur_row);
- try std.testing.expectEqual(@as(?usize, 3), pane.places.current);
- // n round the end: the caret goes with the current row
typeKeys(p, "n");
- try std.testing.expectEqual(@as(?usize, 0), pane.places.current);
- try std.testing.expectEqual(@as(i32, 1), qp.body.cur_row);
+ try std.testing.expectEqual(@as(?usize, 1), pane.places.current);
+ try std.testing.expectEqual(@as(i32, 2), qp.body.cur_row);
+ // j onto the next row makes it current, the text following
+ typeKeys(p, "j");
+ try std.testing.expectEqual(@as(i32, 3), qp.body.cur_row);
+ try std.testing.expectEqual(@as(?usize, 2), pane.places.current);
// B1 elsewhere, then Enter: the current row lands, not the caret's
- p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = y } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = y } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = row_y + 1 } });
+ p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = row_y + 1 } });
p.active = qid;
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(@as(i32, 0), pane.body.cur_row);
+ try std.testing.expectEqual(@as(i32, 3), pane.body.cur_row);
}
diff --git a/src/body_layer.zig b/src/body_layer.zig
index d4ca6d69..bfca268a 100644
--- a/src/body_layer.zig
+++ b/src/body_layer.zig
@@ -286,6 +286,7 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
// File layout is independent of whether its producer requests colors.
if (pane.file) |*f| {
panes.File.drawGutter(p, s, pane, r, tx, tw, body_h, active);
+ panes.Query.paintMark(p, s, pane, r, body_h);
if (p.settings.colors and pane.colorAlgo() != .none)
panes.File.recolorSyntax(p, s, pane, f, r, tx, tw, body_h);
panes.Tables.paint(p, s, pane, r, tx, tw, body_h);
diff --git a/src/exec.zig b/src/exec.zig
index 7248632b..5b0eb204 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -182,9 +182,7 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
result.text = edit.currentSelText(p, pane);
return result;
}
- // A query pane's line selection is its current row's mark, not a
- // selection made: a click on that row takes its word, as on any row.
- if (pane.body.msel.active and pane.query == null and row >= @min(pane.body.msel.r0, pane.body.msel.r1) and
+ if (pane.body.msel.active and row >= @min(pane.body.msel.r0, pane.body.msel.r1) and
row <= @max(pane.body.msel.r0, pane.body.msel.r1))
{
result.text = edit.currentSelText(p, pane);
diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden
index 5de12bab..f7e5bba6 100644
--- a/test/snapshots/fsearch.golden
+++ b/test/snapshots/fsearch.golden
@@ -46,7 +46,7 @@
|8: 0-0 d,#5e4923, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #f5f7ee,#3c614a, 11-11 #f5f7ee,#0d1410, 12-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
|9: 0-1 #000000,#add38a, 2-89 #becfc4,#314738, 90-90 #becfc4,#608269, 91-179 #becfc4,#0d1410,
|10: 0-0 d,#608269, 1-1 d,#0d1410, 2-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
-|11: 0-0 d,#608269, 1-5 d,#0d1410, 6-8 #59675c,#0d1410, 9-12 #f7e4a5,#5e4923, 13-13 #f7e4a5,#0d1410, 14-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
+|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 d,#243a2d, 6-8 #59675c,#243a2d, 9-12 #f7e4a5,#5e4923, 13-13 #f7e4a5,#243a2d, 14-89 #e5eee5,#243a2d, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
|12: 0-0 d,#608269, 1-5 d,#0d1410, 6-8 #59675c,#0d1410, 9-12 #f7e4a5,#352e19, 13-13 #f7e4a5,#0d1410, 14-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
|13: 0-0 d,#608269, 1-4 d,#0d1410, 5-8 #59675c,#0d1410, 9-12 #f7e4a5,#352e19, 13-13 #f7e4a5,#0d1410, 14-89 #e5eee5,#0d1410, 90-90 #e5eee5,#608269, 91-179 #e5eee5,#0d1410,
|14: 0-0 d,#608269, 1-89 d,#0d1410, 90-90 d,#608269, 91-179 d,#0d1410,
diff --git a/test/snapshots/lookrange.golden b/test/snapshots/lookrange.golden
index 86a4b0ac..2c0aa63d 100644
--- a/test/snapshots/lookrange.golden
+++ b/test/snapshots/lookrange.golden
@@ -81,7 +81,7 @@
|21: 0-1 d,#496656, 2-149 #b2c3b8,#1d2824,
|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410,
|23: 0-0 d,#608269, 1-5 d,#0d1410, 6-8 #59675c,#0d1410, 9-11 #e5eee5,#0d1410, 12-17 #f7e4a5,#352e19, 18-18 #f7e4a5,#0d1410, 19-149 #e5eee5,#0d1410,
-|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 d,#3c614a, 6-149 #f5f7ee,#3c614a,
+|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 d,#243a2d, 6-8 #59675c,#243a2d, 9-13 #e5eee5,#243a2d, 14-19 #f7e4a5,#5e4923, 20-149 #f7e4a5,#243a2d,
== snap hit2 grid=150x31 cursor=15,14
== style hit2 grid=150x31
|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-9 #e5eee5,#0d1410, 10-15 #f5f7ee,#3c614a, 16-16 #f5f7ee,#0d1410, 17-149 #e5eee5,#0d1410,
@@ -89,6 +89,7 @@
|16: 0-0 d,#e5eee5, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410,
|18: 0-0 d,#5e4923, 1-149 d,#0d1410,
|23: 0-0 d,#608269, 1-5 d,#0d1410, 6-8 #59675c,#0d1410, 9-11 #e5eee5,#0d1410, 12-17 #f7e4a5,#5e4923, 18-18 #f7e4a5,#0d1410, 19-149 #e5eee5,#0d1410,
+|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 d,#243a2d, 6-8 #59675c,#243a2d, 9-13 #e5eee5,#243a2d, 14-19 #f7e4a5,#352e19, 20-149 #f7e4a5,#243a2d,
== snap back grid=150x31 cursor=17,15
== style back grid=150x31
|14: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-9 #e5eee5,#0d1410, 10-15 #e5eee5,#352e19, 16-149 #e5eee5,#0d1410,
@@ -96,3 +97,4 @@
|16: 0-0 d,#5e4923, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410,
|18: 0-0 d,#e5eee5, 1-149 d,#0d1410,
|23: 0-0 d,#608269, 1-5 d,#0d1410, 6-8 #59675c,#0d1410, 9-11 #e5eee5,#0d1410, 12-17 #f7e4a5,#352e19, 18-18 #f7e4a5,#0d1410, 19-149 #e5eee5,#0d1410,
+|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 d,#243a2d, 6-8 #59675c,#243a2d, 9-13 #e5eee5,#243a2d, 14-19 #f7e4a5,#5e4923, 20-149 #f7e4a5,#243a2d,
diff --git a/test/snapshots/lsprelpath.golden b/test/snapshots/lsprelpath.golden
index 6351de03..dacb6b89 100644
--- a/test/snapshots/lsprelpath.golden
+++ b/test/snapshots/lsprelpath.golden
@@ -56,7 +56,7 @@
|16: 0-1 d,#496656, 2-99 #b2c3b8,#1d2824,
|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
-|19: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-20 #e5eee5,#0d1410, 21-25 #f7e4a5,#5e4923, 26-26 #f7e4a5,#0d1410, 27-99 #e5eee5,#0d1410,
+|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-7 d,#243a2d, 8-10 #59675c,#243a2d, 11-20 #e5eee5,#243a2d, 21-25 #f7e4a5,#5e4923, 26-26 #f7e4a5,#243a2d, 27-99 #e5eee5,#243a2d,
|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|21: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-31 #e5eee5,#0d1410, 32-36 #f7e4a5,#5e4923, 37-99 #e5eee5,#0d1410,
|22: 0-0 d,#608269, 1-99 d,#0d1410,
@@ -130,7 +130,7 @@
|16: 0-1 d,#496656, 2-99 #b2c3b8,#1d2824,
|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
-|19: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-20 #e5eee5,#0d1410, 21-24 #f7e4a5,#5e4923, 25-25 #f7e4a5,#0d1410, 26-99 #e5eee5,#0d1410,
+|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-7 d,#243a2d, 8-10 #59675c,#243a2d, 11-20 #e5eee5,#243a2d, 21-24 #f7e4a5,#5e4923, 25-25 #f7e4a5,#243a2d, 26-99 #e5eee5,#243a2d,
|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|21: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-29 #e5eee5,#0d1410, 30-33 #f7e4a5,#5e4923, 34-99 #e5eee5,#0d1410,
|22: 0-0 d,#608269, 1-99 d,#0d1410,
diff --git a/test/snapshots/stepgrain.golden b/test/snapshots/stepgrain.golden
index 43445ed4..a406597c 100644
--- a/test/snapshots/stepgrain.golden
+++ b/test/snapshots/stepgrain.golden
@@ -42,7 +42,7 @@
|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410,
|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410,
|15: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-16 #e5eee5,#0d1410, 17-22 #f7e4a5,#5e4923, 23-23 #f7e4a5,#0d1410, 24-149 #e5eee5,#0d1410,
-|16: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-33 #e5eee5,#0d1410, 34-39 #f7e4a5,#5e4923, 40-40 #f7e4a5,#0d1410, 41-149 #e5eee5,#0d1410,
+|16: 0-0 d,#608269, 1-1 d,#0d1410, 2-7 d,#243a2d, 8-10 #59675c,#243a2d, 11-33 #e5eee5,#243a2d, 34-39 #f7e4a5,#5e4923, 40-40 #f7e4a5,#243a2d, 41-149 #e5eee5,#243a2d,
|17: 0-0 d,#608269, 1-1 d,#0d1410, 2-149 #e5eee5,#0d1410,
|18: 0-0 d,#608269, 1-7 d,#0d1410, 8-10 #59675c,#0d1410, 11-16 #f7e4a5,#5e4923, 17-17 #f7e4a5,#0d1410, 18-149 #e5eee5,#0d1410,
|19: 0-0 d,#608269, 1-149 d,#0d1410,
@@ -77,7 +77,7 @@
|3: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410,
|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-149 #e5eee5,#0d1410,
|7: 0-0 d,#608269, 1-149 d,#0d1410,
-|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 #e5eee5,#0d1410, 6-10 #f7e4a5,#5e4923,b 11-149 #e5eee5,#0d1410,
+|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-5 #e5eee5,#243a2d, 6-10 #f7e4a5,#5e4923,b 11-149 #e5eee5,#243a2d,
|15: 0-0 d,#608269, 1-149 d,#0d1410,
|16: 0-0 d,#608269, 1-149 d,#0d1410,
|17: 0-0 d,#608269, 1-149 d,#0d1410,