summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 19:24:44 -0300
committerGabriel Schneider <[email protected]>2026-11-24 19:24:44 -0300
commit1c4aea3b0298f6f59ffec9b49f4d5e5f38c8af0f (patch)
tree09aa46200e9b005852a533da932c46b09a077388 /core/draw.zig
parent08524143c84c069a80861895fafd0b7411a201f5 (diff)
downloadpardes-1c4aea3b0298f6f59ffec9b49f4d5e5f38c8af0f.tar.gz
pardes-1c4aea3b0298f6f59ffec9b49f4d5e5f38c8af0f.zip
walk (pick-ui SPEC §6.3, §6.4, item 3 of the Walk UI line B): a reader's trail is words of its tag: its back steps before its path (`‹@p3 › rank.zig:14 › `, the owner's word written so that its Look is `@p3`, the newest shown_steps 3 whole and older ones folded to `·`, still their steps), its forward steps after it, dimmed in the theme's lineno ink (draw.zig inkTag, the name's tint loop made one with it), then Keep; the prefix is made in the room Trail.bytes measures (tagline.pathPrefix, no allocation past it), and the name's place after the words is tagline.nameAt (onName, typedIntoName, tagTintRange, the drafted name's caret); a click on a step's word is that step's Look (B1 with no drag, the one place it does more than select, and B3) or Exec (B2): a place gone back to (the later steps kept as forward steps) or forward to, the owner focused; a list, a search or a recipe word says it is not walked yet (their makers are D's and E's: Trail.lookStep, Trail.execStep); TEST FIRST: Trail.zig "the session of pick-ui §6.7: four jumps across three files, back by a click on a trail word, the later steps kept dimmed after the path, forward again, Keep, and a new reader on the next jump" and "a trail keeps its newest three back steps whole, older ones fold to ·, and a click on a · goes back to its step"; core-test 998/1164 (166 skipped), pane-test 183/184, behaviour-test 277/277
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig44
1 files changed, 26 insertions, 18 deletions
diff --git a/core/draw.zig b/core/draw.zig
index f00a7583..91a14c98 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -619,7 +619,7 @@ fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct {
}
return null;
}
- var start: usize = 0;
+ var start: usize = tagline.nameAt(pane);
const name = if (pane.file) |file|
if (pane.prompt == .name) pane.input.own orelse file.path else file.path
else if (pane.addon) |k| blk: {
@@ -793,6 +793,25 @@ fn joinPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r
}
}
+/// Bytes `lo` to `hi` of a tag's text in `ink`, over whichever of its
+/// shown rows (`lines`, from shown row `top`, drawn at `x`, `y`, `w`
+/// wide) they wrapped onto.
+fn inkTag(p: *Pardes, s: *Surface, shown: tagline.Shown, lines: []const []const u8, top: usize, x: u16, y: u16, w: u16, lo: usize, hi: usize, ink: [3]u8) void {
+ const a = modal.positionAt(shown.text, shown.fromReal(lo));
+ const b = modal.positionAt(shown.text, shown.fromReal(hi));
+ var row = @max(a.row, top);
+ while (row <= b.row and row < top + lines.len) : (row += 1) {
+ const line = lines[row - top];
+ const from = if (row == a.row) a.col else 0;
+ const to = if (row == b.row) b.col else line.len;
+ var col = panes.File.rawDisplayCol(p.settings.tab, line, @min(from, line.len));
+ const end = panes.File.rawDisplayCol(p.settings.tab, line, @min(to, line.len));
+ const row_y = y + @as(u16, @intCast(row - top));
+ while (col < end and col < w) : (col += 1)
+ s.at(x + @as(u16, @intCast(col)), row_y).style.fg = .{ .rgb = ink };
+ }
+}
+
/// A pane's tag's ground: a reading pane's tint (its focus is its grip's),
/// else the focused tag's or the tag's.
fn tagGround(p: *Pardes, pane: *const Pane, active: bool) [3]u8 {
@@ -840,7 +859,7 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
else if (pane.prompt == .name) caret: {
// A drafted name is the prefix: its caret is on row 0 of the tag,
// the rows it wrapped onto included.
- const at = modal.positionAt(shown.text, shown.fromReal(@intCast(@max(0, pane.input.cur_col))));
+ const at = modal.positionAt(shown.text, shown.fromReal(tagline.nameAt(pane) + @as(usize, @intCast(@max(0, pane.input.cur_col)))));
if (at.row < top or at.row >= top + rows) break :caret null;
break :caret .{ .row = at.row - top, .at = @min(lines[at.row - top].len, at.col) };
} else if (pane.focus == .tag and pane.prompt == .none) caret: {
@@ -860,22 +879,11 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane,
// The name's tint, in the tag's first line, over whichever rows it
// wrapped onto.
const first_line = whole[0 .. std.mem.indexOfScalar(u8, whole, '\n') orelse whole.len];
- if (tagTintRange(pane, first_line, prefix_len)) |name| if (name.lo < name.hi) {
- const name_fg = if (active) chrome.tag_active_name_fg else chrome.tag_name_fg;
- const a = modal.positionAt(shown.text, shown.fromReal(name.lo));
- const b = modal.positionAt(shown.text, shown.fromReal(@min(name.hi, first_line.len)));
- var row = @max(a.row, top);
- while (row <= b.row and row < top + rows) : (row += 1) {
- const line = lines[row - top];
- const from = if (row == a.row) a.col else 0;
- const to = if (row == b.row) b.col else line.len;
- var col = panes.File.rawDisplayCol(p.settings.tab, line, @min(from, line.len));
- const end = panes.File.rawDisplayCol(p.settings.tab, line, @min(to, line.len));
- const y = tag_y + @as(u16, @intCast(row - top));
- while (col < end and col < tw) : (col += 1)
- s.at(tx + @as(u16, @intCast(col)), y).style.fg = .{ .rgb = name_fg };
- }
- };
+ if (tagTintRange(pane, first_line, prefix_len)) |name| if (name.lo < name.hi)
+ inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), if (active) chrome.tag_active_name_fg else chrome.tag_name_fg);
+ // A walk's forward steps, after the name, dimmed (Trail.zig).
+ const ahead = tagline.forwardSpan(pane);
+ if (ahead[0] < ahead[1]) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, ahead[0], @min(ahead[1], first_line.len), chrome.lineno);
// The tag's own selections, while it has the keyboard, a line at a
// time. A range of one grapheme is the block cursor, not a selection.
if (pane.focus == .tag) {