summaryrefslogtreecommitdiff
path: root/core/body_layer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/body_layer.zig')
-rw-r--r--core/body_layer.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/body_layer.zig b/core/body_layer.zig
index 6ce2b6be..7bff3c31 100644
--- a/core/body_layer.zig
+++ b/core/body_layer.zig
@@ -349,7 +349,11 @@ pub fn renderBody(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane
panes.File.recolorSyntax(p, s, pane, f, r, tx, tw, body_h);
panes.Tables.paint(p, s, pane, r, tx, tw, body_h);
drawWrapMarkers(p, s, pane, r, tx, tw, body_h, pane_bg);
+ // A picker's landing line under the places it lights (UX D7).
+ const landing = pardes.Pick.landingLine(p, arena, pane);
+ if (landing) |line| paintLanding(p, s, pane, r, tx, tw, body_h, line);
pane.places.paint(p, s, pane, r, body_h);
+ if (landing) |line| paintLandingSpan(p, s, pane, r, f, line);
pardes.Prompt.paintGutter(p, s, pane, r, body_h);
panes.Query.paint(p, s, pane, r, body_h);
} else if (pane.isTerminal()) {
@@ -650,6 +654,47 @@ pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col:
return text.items[b.lo..b.hi];
}
+/// A picker's landing line (UX D7): its text on the hit ground across
+/// the body's width, and `▸` in the key ink in the gutter's cell after its
+/// number (the one a prompt's current place has, Prompt.paintGutter), on
+/// each row it wraps onto.
+fn paintLanding(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, tx: u16, tw: u16, body_h: u16, line: usize) void {
+ const roles = &p.chromeTheme().roles;
+ const gutter = File.gutterWidth(pane);
+ const number = gutter -| File.laneCells(pane) -| pane.layers.heat -| 1;
+ const body_y = p.bodyTop(pane, r);
+ var vr: u16 = pane.context_rows;
+ while (vr < body_h) : (vr += 1) {
+ const w = pane.wrapAt(p.settings.tab, vr);
+ if (w.line != @as(i32, @intCast(line))) continue;
+ for (gutter..tw) |x| {
+ const cell = s.at(tx + @as(u16, @intCast(x)), body_y + vr);
+ cell.default = false;
+ cell.style.bg = .{ .rgb = roles.hit };
+ }
+ if (gutter > 0 and w.at == 0) {
+ var style = s.at(tx + number, body_y + vr).style;
+ style.fg = .{ .rgb = roles.key };
+ s.set(tx + number, body_y + vr, "▸", style);
+ }
+ }
+}
+
+/// The landing line's matched span (a Grep's match at the row's column) on
+/// the current hit's ground, over the places lit on it (UX D7).
+fn paintLandingSpan(p: *Pardes, s: *Surface, pane: *Pane, r: Rect, f: *panes.File.State, line: usize) void {
+ if (!pane.places.shows(pane)) return;
+ const hits = pane.places.hits.items;
+ const ls = File.lineStart(p.gpa, f, line);
+ const caret = ls + @as(usize, @intCast(@max(0, pane.body.cur_col)));
+ var i = panes.Places.firstFrom(hits, ls);
+ while (i < hits.len and hits[i].start <= caret) : (i += 1) {
+ if (hits[i].end <= caret) continue;
+ File.paintWordSelection(p, s, pane, r, @intCast(line), @intCast(hits[i].start - ls), @intCast(hits[i].end - ls), p.chromeTheme().roles.hit_current);
+ return;
+ }
+}
+
/// Painted targets (SPEC §4.4), while a motion root's level shows in this
/// body's tag: each of its keys at the line it would go to, in the gutter
/// (`g e t b .` for `g`; for `]` the next and for `[` the previous