diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:39:53 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:39:53 -0300 |
| commit | 99c70953a0c3b8e32cc5b61121c2b18e5ee68edd (patch) | |
| tree | 0f950dfa341c68ed8376ea70b0c383ef68255576 /core/Pick.zig | |
| parent | c3b01a651dcee194f20a5be8da80a3f55a7235e7 (diff) | |
| download | pardes-99c70953a0c3b8e32cc5b61121c2b18e5ee68edd.tar.gz pardes-99c70953a0c3b8e32cc5b61121c2b18e5ee68edd.zip | |
TagState, Pick, Prompt: the head's right block, the count `cursor/matches` and the hints at its row's right end, fixed while the field grows, the hints dim and first to go (walk UI polish P1, UX DESIGN.md D3): the count sat three spaces after the field (`Help tut▌ 3/133`, `Find re▌ 2/3`), so it slid right with every key typed, the only moving thing in the tag, and meant two things (Help's matches/total, the picker's cursor/matches); the hints followed it and wrapped mid-word onto a row of their own (msg's `s EXT ... C-r histo` / `ry · esc`); now `TagState.Builder.right(count, hints)` moves what was put from those bytes on to the row's right end (its last cell the row's last, two blanks between, at least two before), drops the hints whole when the row has no room for them, never the count (a head with no room for it runs past its row: the field's scroll D3 asks for there is not built); THE CHANGE: Builder is pub, made by `Builder.of(p, arena, pane)` with the row's width and the prefix's cells before the head (`col`), and Pick.head and Prompt.head build in it (their text and spans the builder's); counts: Help's is the cursor's row of its hits (`2/17`, `0` with none: no total), the picker's `0` with none (was `0/0`), the search prompt's wrap ` ↻` (was ` · wrapped`); hints are dim spans (describe-key's `⏎ run · esc`, Rename's, unrolled's `↑ roll up · ? field · esc`, the prompts' and the themes picker's); the rolled level keeps its hint as before (D2's rows put it on its last row); TEST FIRST: TagState.zig "the right block: the count `cursor/matches` at the row's right end, fixed while the field grows; the hints after it, dim, dropped whole where the row has no room" (Help at 60 columns: the first row exactly the tag's width ending ` 1/N`, the same after typing and `2/N` after Down; unrolled SPC's hints at the end, a dim span; at 24 columns `␣ SPC` alone); the tests reading heads read a run of blanks as two (Prompt.zig, Command.zig `has`; Pick, Band: the first row's start and end); core-test 1063/1233 (170 skipped); process-test: 7 goldens regenerated and read (find, fsearch, lsp, msg, pipe, selregex, ttyhelp): every changed row a count or hints moved to the row's right end (`␣ f Find zqm` ... `1/3`), `0/0` now `0`, ttyhelp's `1/136` now `1/1` (one match, the cursor on it), msg's `s EXT` hints dropped at 70 columns so its tag is one row again (the body a row up, where it is at rest); a user saw the count move at every key
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Pick.zig')
| -rw-r--r-- | core/Pick.zig | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/core/Pick.zig b/core/Pick.zig index 321b16b7..8fcc5945 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -563,8 +563,9 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { const pk = live(p) orelse return null; const s = &p.view().tag_state; - var text: std.ArrayList(u8) = .empty; - var spans: std.ArrayList(TagState.Span) = .empty; + var b = try TagState.Builder.of(p, arena, pane); + const text = &b.text; + const spans = &b.spans; var cells: [4][2]u32 = undefined; var ncells: usize = 0; // SPC's cell, then its keys': `␣ f`. @@ -581,16 +582,22 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head { if (pk.spine == .edit) try text.print(arena, "{s} | Edit ", .{pk.query.slice()}); const caret: u32 = @intCast(text.items.len + s.field.caret); try text.appendSlice(arena, s.field.text()); + // The count at the row's right end (UX D3): `cursor/matches`, `0` with + // none, ` •M` marked. + const counted = text.items.len; const n = count(p, pk); - try text.print(arena, " {d}/{d}", .{ if (n == 0) 0 else s.rows.at + 1, n }); + if (n == 0) try text.append(arena, '0') else try text.print(arena, "{d}/{d}", .{ s.rows.at + 1, n }); if (pk.marks.items.len > 0) try text.print(arena, " •{d}", .{pk.marks.items.len}); if (pk.names.busy() or p.stream.busyFor(pk.id)) try text.appendSlice(arena, " ⋯"); // Themes have no acts and no other sources: no second row. if (pk.source == .themes) { - try text.appendSlice(arena, " ⏎ wear it · esc"); + const hints = text.items.len; + try b.styled("⏎ wear it · esc", .dim); + try b.right(counted, hints); for (cells[0..ncells]) |c| try spans.append(arena, .{ .lo = c[0], .hi = c[1], .style = .key }); return .{ .text = text.items, .spans = spans.items, .cells = @intCast(ncells), .caret = caret }; } + try b.right(counted, text.items.len); // The second row: the spines go on through it from the key cells, // then the other sources' words, each switching to it. try text.append(arena, '\n'); @@ -1528,7 +1535,8 @@ test "a picker from a held pane unrolls in a reader made for it: its rows in the const tag = try tagOf(p, a, reader); // Out of rest no path (UX D1): not the previewed file's, not Keep; // the head starts the tag's text. - try std.testing.expect(std.mem.startsWith(u8, tag, "␣ f Find pick 1/1\n")); + const first = tag[0..std.mem.indexOfScalar(u8, tag, '\n').?]; + try std.testing.expect(std.mem.startsWith(u8, first, "␣ f Find pick ") and std.mem.endsWith(u8, first, " 1/1")); try std.testing.expect(std.mem.indexOf(u8, tag, "│ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist") != null); // The body previews the row's file, after a frame of its own. p.update(.tick); @@ -1570,7 +1578,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and try std.testing.expectEqual(@as(u16, 2), s.rows.at); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, frame.allocator(), id), " Refs 3/4 •1\n") != null); + const refs = try tagOf(p, frame.allocator(), id); + try std.testing.expect(std.mem.indexOf(u8, refs, " Refs ") != null and std.mem.indexOf(u8, refs, " 3/4 •1\n") != null); p.update(.{ .key = .{ .cp = 'a', .alt = true } }); try std.testing.expectEqual(@as(usize, 4), pk.marks.items.len); p.update(.{ .key = .{ .cp = 'a', .alt = true } }); @@ -1588,7 +1597,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and settle(p); try std.testing.expectEqual(@as(usize, 1), count(p, pk)); _ = frame.reset(.retain_capacity); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, frame.allocator(), id), " Refs alpha | w 1/1\n") != null); + const refined = try tagOf(p, frame.allocator(), id); + try std.testing.expect(std.mem.indexOf(u8, refined, " Refs alpha | w ") != null and std.mem.indexOf(u8, refined, " 1/1\n") != null); // Backspace twice: the `w` goes, then the refinement, its query back. p.update(.{ .key = .{ .cp = Key.backspace } }); p.update(.{ .key = .{ .cp = Key.backspace } }); |
