diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:27:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:27:43 -0300 |
| commit | 0e6c60d17dd5f0e48232a46096e3a7a92f8841cf (patch) | |
| tree | 3e1f941f076da82edb957739b1919af4480748c7 /core/Band.zig | |
| parent | 6c842c2ab84dba9e3052d886ce65c2a7e08ca260 (diff) | |
| download | pardes-0e6c60d17dd5f0e48232a46096e3a7a92f8841cf.tar.gz pardes-0e6c60d17dd5f0e48232a46096e3a7a92f8841cf.zip | |
Pick, Band, draw: the themes picker marks the theme in use (POLISH 12, UX DESIGN.md A15): its row says `in use` at its right end in the dim ink, whichever theme the window wears under the cursor, and the cursor opens on it as before; a band row's meta (Band.Row.meta: said right-aligned in its part, two cells off its text at least, the first to give way, as D5 asks; the step as wide as text and meta; Band.metaShown says whether it fits, so Band.line and draw.zig joinBand agree), placed from the part's own column (a step's rows start where the spines leave off, not always at its x); TEST FIRST: Pick.zig "the themes picker marks the theme in use" (fails without the mark at its `in use`; it holds the row's meta, one row only, the cells' dim ink on the cursor row's selection, and the mark staying on the theme in use while the window wears the next); core-test 1068/1238 (170 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Band.zig')
| -rw-r--r-- | core/Band.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/core/Band.zig b/core/Band.zig index a8d97bb4..e562da1d 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -56,6 +56,9 @@ pub const Row = struct { /// tint; the `faint` bytes after them dimmed (a path's directory). pre: u16 = 0, faint: u16 = 0, + /// Said at the row's right end in the dim ink, two cells off its text + /// at least, and the first to give way (UX D5): `in use`. + meta: []const u8 = "", }; /// A column of rows. A level of more than 9 rows flows into two columns @@ -375,7 +378,7 @@ fn place(band: *Band, p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usi for (band.steps[0..band.nsteps]) |*step| { if (step.doc) continue; var widest: usize = 0; - for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text)); + for (step.rows) |row| widest = @max(widest, File.displayWidth(tab, row.text) + if (row.meta.len > 0) 2 + File.displayWidth(tab, row.meta) else 0); const column: u16 = @intCast(@min(widest + 2, std.math.maxInt(u16) / 4, @max(min_width, band.columns -| x))); step.width = if (step.two) 2 * column + 1 else column; need += step.width + 2; @@ -493,14 +496,26 @@ pub fn line(band: *const Band, arena: std.mem.Allocator, tab: u16, y: u16) !Line col += @intCast(File.displayWidth(tab, lead)); try parts.append(arena, .{ .col = col, .width = per -| @as(u16, @intCast(File.displayWidth(tab, lead))), .row = row }); const room = per -| @as(u16, @intCast(File.displayWidth(tab, lead))); + const at = col; const cut = File.byteAtDisplay(tab, row.text, room); try text.appendSlice(arena, row.text[0..cut]); col += @intCast(File.displayWidth(tab, row.text[0..cut])); + if (metaShown(tab, row, room)) { + const meta: u16 = @intCast(File.displayWidth(tab, row.meta)); + while (col < at + room - meta) : (col += 1) try text.append(arena, ' '); + try text.appendSlice(arena, row.meta); + col += meta; + } } } return .{ .text = text.items, .parts = parts.items }; } +/// Whether row `row`'s meta fits `room` cells after its text. +pub fn metaShown(tab: u16, row: Row, room: u16) bool { + return row.meta.len > 0 and File.displayWidth(tab, row.text) + 2 + File.displayWidth(tab, row.meta) <= room; +} + /// The word under column `col` of band row `y` of pane `id`, at the /// tagline's pitch: what B2 executes and B3 looks at. pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, y: u16, col: u16) !?[]const u8 { |
