diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:17:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:18:54 -0300 |
| commit | c3b01a651dcee194f20a5be8da80a3f55a7235e7 (patch) | |
| tree | 09e5b78c6fee75e16c0cb9d6b4bf2aace69e4a48 /core | |
| parent | 304ea98913c178de9645cad5c3fe45a5f13e25d5 (diff) | |
| download | pardes-c3b01a651dcee194f20a5be8da80a3f55a7235e7.tar.gz pardes-c3b01a651dcee194f20a5be8da80a3f55a7235e7.zip | |
bindings, TagState, Messages: nothing changes in the tag before a root's level shows, its keys echo on the notice row's right end at once (walk UI polish P1, UX DESIGN.md D12, C2): SPC, `"` and C-w wrote their key cell into the tag at once (`at_once`), which with D1 (the path hidden out of rest) flipped the whole tag and back at every fast chord (`SPC j o`, `SPC f s`: a flash per chord, UX A16); now the tag stays exactly at rest until the root's delay passes (SPC and C-w 250 ms, `"` 300 ms, g m z [ ] Z 500 ms, on the taped clock), a sequence finished inside the delay never touches it (the spec's `gg` rule, extended to SPC), and after the delay it goes straight to D1's layout in one frame; the keys typed so far show at once at the notice row's right end (`SPC f`, vim's showcmd): TagState.pending gives the chord (bindings.chord) while a root is current and its level not shown, Messages.noticeRow appends it to the row's right part; THE CHANGE: bindings.Info's `at_once` is deleted (every root waits), TagState.hostOf is null until `shown`, and head's `…` branch for a key cell alone is gone (unreachable); TEST FIRST: TagState.zig "SPC changes nothing in the tag until its level shows 250 ms on, its keys on the notice row's right end at once ..." (on the base the tag is `␣ …` after SPC: fails), bindings.zig's registers test (`"`: the tag as at rest until 300 ms), the C-w test, "a tag out of rest keeps its rows at rest at least" (now Help's head under the rows the tag keeps: there is no key-cell-alone state left), the click and the asking tests date the level before they read it; test/behaviour keys.zig's PDF case: SPC leaves the panes as they were and the notice row ends `SPC`; core-test 1062/1232 (170 skipped); behaviour-test 277/277; process-test 0/146 failed (no golden caught the key cell alone); a user saw the flash at every leader chord
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/Messages.zig | 10 | ||||
| -rw-r--r-- | core/TagState.zig | 47 | ||||
| -rw-r--r-- | core/bindings.zig | 30 |
3 files changed, 54 insertions, 33 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 2b63e647..dd5c232a 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -726,6 +726,10 @@ pub fn noticeRow(p: *const Pardes, width: usize, out: *[notice_row_cap]u8) Row { r.writeAll("SPC e walk") catch {} else if (m.len > 0) r.print("{d} message{s} \u{b7} SPC h m", .{ m.len, if (m.len == 1) "" else "s" }) catch {}; + // The keys of a root whose level waits for its delay, at once (UX D12: + // vim's showcmd; the tag stays at rest until the level shows). + var keys: [64]u8 = undefined; + if (pardes.TagState.pending(p, p.view(), &keys)) |typed| r.print("{s}{s}", .{ if (r.end > 0) " " else "", typed }) catch {}; const tail = r.buffered(); // The left cut to make room for the right, a blank between them. const tail_w = panes.File.displayWidth(tab, tail); @@ -1362,9 +1366,11 @@ test "a file changed on disk under unsaved text asks in its tag and never takes try std.testing.expect(std.mem.indexOf(u8, prefix, "changed on disk") == null); // The tag's own text is no one's to edit meanwhile. try std.testing.expect((try pardes.TagState.head(p, frame.allocator(), pane)) != null); - // Out of rest (SPC: its key cell at once) the level's head, not the - // question; at rest again, the question. + // Out of rest (SPC's level shown) the level's head, not the question; + // at rest again, the question. p.update(.{ .key = .{ .cp = ' ' } }); + p.advance(p.clock.now_ns); + p.clock.now_ns = p.view().tag_state.due_ns; try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, frame.allocator(), pane), "changed on disk") == null); p.update(.{ .key = .{ .cp = Key.escape } }); try std.testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagText(p, frame.allocator(), pane), "changed on disk") != null); diff --git a/core/TagState.zig b/core/TagState.zig index 8bead506..96c5b9b1 100644 --- a/core/TagState.zig +++ b/core/TagState.zig @@ -26,6 +26,7 @@ const Band = @import("Band.zig"); const Names = @import("Names.zig"); const Prompt = @import("Prompt.zig"); const Ask = @import("lsp/Ask.zig"); +const Messages = @import("Messages.zig"); /// The tag's states besides a root's level (which `kind` rest with a root /// current is): `help`, a field over every leaf (SPEC §4.5); `describe`, @@ -192,8 +193,7 @@ pub fn hostOf(p: *const Pardes) ?usize { if (v.tag_state.kind != .rest) return for (p.panes, 0..) |slot, i| { if (slot) |pane| if (pane.serial == v.tag_state.host) break i; } else null; - const cur = current(p, v) orelse return null; - if (!bindings.info.get(cur.root).at_once and !shown(p, v)) return null; + if (current(p, v) == null or !shown(p, v)) return null; return if (p.panes[v.active] != null) v.active else null; } @@ -311,6 +311,15 @@ fn asking(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { return b.done(); } +/// The keys of the root current in view `v` while its level waits for its +/// delay (UX D12: the tag is at rest until then), as the notice row's right +/// end echoes them at once: `SPC f`. +pub fn pending(p: *const Pardes, v: *const View, buf: []u8) ?[]const u8 { + if (v.tag_state.kind != .rest or shown(p, v)) return null; + const cur = current(p, v) orelse return null; + return bindings.chord(cur.root, cur.path, buf); +} + /// The last leaf run in the current level, as the line under it says it /// (Messages' leader band): `k Hover: its summary (last used here)`, while /// the level is shown rolled. @@ -557,10 +566,6 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?Head { } const cur = current(p, v) orelse return null; try b.keyCells(cur.root, cur.path); - if (!shown(p, v)) { - try b.put("…"); - return b.done(); - } const node = bindings.nodeAt(cur.root, cur.path) orelse return b.done(); if (s.unrolled) { try b.put(if (cur.path.len == 0) bindings.info.get(cur.root).label else node.label); @@ -614,7 +619,7 @@ fn testTag(p: *Pardes, arena: std.mem.Allocator) ![]const u8 { return tagline.tagText(p, arena, p.panes[p.view().active].?); } -test "SPC writes its key cell at once and its level 250 ms on; g changes nothing until 500 ms, and gg never" { +test "SPC changes nothing in the tag until its level shows 250 ms on, its keys on the notice row's right end at once; g nothing until 500 ms, and gg never" { const Key = pardes.Key; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 30 }); defer p.deinit(); @@ -626,9 +631,12 @@ test "SPC writes its key cell at once and its level 250 ms on; g changes nothing p.clock.stepped_ns = p.clock.now_ns; p.sync(); const rest = try a.dupe(u8, try testTag(p, a)); - // SPC: its cell at once, the own words gone under the head. + // SPC: the tag at rest until the level shows (UX D12), the keys typed + // at the notice row's right end at once. p.update(.{ .key = .{ .cp = ' ' } }); - try std.testing.expect(std.mem.eql(u8, try testTag(p, a), "␣ …")); + try std.testing.expectEqualStrings(rest, try testTag(p, a)); + var row: [Messages.notice_row_cap]u8 = undefined; + try std.testing.expect(std.mem.endsWith(u8, Messages.noticeRow(p, 100, &row).text, "SPC")); // Its time is the next advance's; the level waits 250 ms from it, and // the loop wakes for it then. try std.testing.expectEqual(asked, p.view().tag_state.due_ns); @@ -638,7 +646,7 @@ test "SPC writes its key cell at once and its level 250 ms on; g changes nothing const woken = p.nextWake().?; try std.testing.expect(woken >= due and woken < due + pardes.frame_ns); p.clock.now_ns = due - 1; - try std.testing.expect(std.mem.eql(u8, try testTag(p, a), "␣ …")); + try std.testing.expectEqualStrings(rest, try testTag(p, a)); p.clock.now_ns = due; const level = try testTag(p, a); try std.testing.expect(std.mem.indexOf(u8, level, "␣ ▸ b buffer…") != null); @@ -846,9 +854,10 @@ test "C-w's level is window mode's, shown at once and kept while its keys move t var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const a = frame.allocator(); + const rest = try a.dupe(u8, try testTag(p, a)); p.update(.{ .key = .{ .cp = 'w', .ctrl = true } }); try std.testing.expect(p.view().window_pick != null); - try std.testing.expect(std.mem.endsWith(u8, try testTag(p, a), "C-w …")); + try std.testing.expectEqualStrings(rest, try testTag(p, a)); p.advance(p.clock.now_ns); p.clock.now_ns = p.view().tag_state.due_ns; try std.testing.expect(std.mem.indexOf(u8, try testTag(p, a), "C-w ▸ c Collapse d Del h Left j Down k Up l Right") != null); @@ -953,7 +962,7 @@ test "a terminal's rolled level keeps its tag rows at every width, C-w's as SPC' }; } -test "a tag out of rest keeps its rows at rest at least: a root's key cell alone moves no body up" { +test "a tag out of rest keeps its rows at rest at least: a level shorter than its own text moves no body up" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 40, .rows = 30 }); defer p.deinit(); _ = try p.setTestFile("one\n"); @@ -961,19 +970,23 @@ test "a tag out of rest keeps its rows at rest at least: a root's key cell alone p.sync(); const rows, const tag_rows = .{ pane.rows, pane.tag_rows }; try std.testing.expect(tag_rows > 1); + // Help's head, a row, its band under the rows the tag keeps. p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = '?' } }); p.sync(); try std.testing.expect(hostOf(p) != null); - try std.testing.expectEqual(tag_rows, pane.tag_rows); - try std.testing.expectEqual(rows, pane.rows); + try std.testing.expectEqual(tag_rows, pane.tag_rows - pane.band_rows); + try std.testing.expectEqual(rows, pane.rows + pane.band_rows); // With the keyboard in the tag (whose top row follows its caret) too: - // C-w's key cell, a line, in a tag of more rows. + // C-w's level, a line, in a tag of more rows. toRest(p); pane.focus = .tag; p.update(.{ .key = .{ .cp = 'w', .ctrl = true } }); + p.advance(p.clock.now_ns); + p.clock.now_ns = p.view().tag_state.due_ns; p.sync(); try std.testing.expect(hostOf(p) != null); - try std.testing.expectEqual(tag_rows, pane.tag_rows); + try std.testing.expect(pane.tag_rows >= tag_rows); try std.testing.expectEqual(@as(u16, 0), pane.tag_top); } @@ -1024,6 +1037,8 @@ test "a click that gives the keyboard to another pane ends a level as Esc does; const rl = p.view().rects[low]; // SPC's level in the lower pane's tag; a click in its own tag keeps it. p.update(.{ .key = .{ .cp = ' ' } }); + p.advance(p.clock.now_ns); + p.clock.now_ns = p.view().tag_state.due_ns; try std.testing.expect(hostOf(p) == low); click(p, rl.x + config.GUTTER + 2, rl.y); try std.testing.expect(hostOf(p) == low and p.view().prefix == .leader); diff --git a/core/bindings.zig b/core/bindings.zig index 43145b15..af5e8a6d 100644 --- a/core/bindings.zig +++ b/core/bindings.zig @@ -45,26 +45,25 @@ pub const Info = struct { /// Its key cell in the head (`␣` for SPC). cell: []const u8, label: []const u8, - /// How long after it the level shows (SPEC §3.3). + /// How long after it the level shows (SPEC §3.3): the tag changes + /// nothing before (UX D12), so `gg` and a fast `SPC f s` never touch it; + /// its keys show on the notice row's right end at once (Messages). delay_ns: u64, - /// Its key cell is written at once (SPC, `"`, `C-w`); the others change - /// nothing until the delay is up, so `gg` never touches the tag. - at_once: bool, node: *const Node, }; const ms = std.time.ns_per_ms; pub const info = std.EnumArray(Root, Info).init(.{ - .leader = .{ .key = .{ .cp = config.leader[0].cp }, .cell = "␣", .label = "SPC", .delay_ns = 250 * ms, .at_once = true, .node = &leader_tree }, - .window = .{ .key = .{ .cp = config.window_prefix[0].cp, .ctrl = true }, .cell = "C-w", .label = "window", .delay_ns = 250 * ms, .at_once = true, .node = &window_tree }, - .goto = .{ .key = .{ .cp = config.goto_prefix }, .cell = "g", .label = "goto", .delay_ns = 500 * ms, .at_once = false, .node = &goto_tree }, - .match = .{ .key = .{ .cp = config.match_prefix }, .cell = "m", .label = "match", .delay_ns = 500 * ms, .at_once = false, .node = &match_tree }, - .view = .{ .key = .{ .cp = config.view_prefix }, .cell = "z", .label = "view", .delay_ns = 500 * ms, .at_once = false, .node = &view_tree }, - .view_sticky = .{ .key = .{ .cp = config.view_prefix_sticky }, .cell = "Z", .label = "view", .delay_ns = 500 * ms, .at_once = false, .node = &view_sticky_tree }, - .prev = .{ .key = .{ .cp = config.prev_prefix }, .cell = "[", .label = "previous", .delay_ns = 500 * ms, .at_once = false, .node = &prev_tree }, - .next = .{ .key = .{ .cp = config.next_prefix }, .cell = "]", .label = "next", .delay_ns = 500 * ms, .at_once = false, .node = &next_tree }, - .register = .{ .key = .{ .cp = config.register_prefix }, .cell = "\"", .label = "registers", .delay_ns = 300 * ms, .at_once = true, .node = ®ister_tree }, + .leader = .{ .key = .{ .cp = config.leader[0].cp }, .cell = "␣", .label = "SPC", .delay_ns = 250 * ms, .node = &leader_tree }, + .window = .{ .key = .{ .cp = config.window_prefix[0].cp, .ctrl = true }, .cell = "C-w", .label = "window", .delay_ns = 250 * ms, .node = &window_tree }, + .goto = .{ .key = .{ .cp = config.goto_prefix }, .cell = "g", .label = "goto", .delay_ns = 500 * ms, .node = &goto_tree }, + .match = .{ .key = .{ .cp = config.match_prefix }, .cell = "m", .label = "match", .delay_ns = 500 * ms, .node = &match_tree }, + .view = .{ .key = .{ .cp = config.view_prefix }, .cell = "z", .label = "view", .delay_ns = 500 * ms, .node = &view_tree }, + .view_sticky = .{ .key = .{ .cp = config.view_prefix_sticky }, .cell = "Z", .label = "view", .delay_ns = 500 * ms, .node = &view_sticky_tree }, + .prev = .{ .key = .{ .cp = config.prev_prefix }, .cell = "[", .label = "previous", .delay_ns = 500 * ms, .node = &prev_tree }, + .next = .{ .key = .{ .cp = config.next_prefix }, .cell = "]", .label = "next", .delay_ns = 500 * ms, .node = &next_tree }, + .register = .{ .key = .{ .cp = config.register_prefix }, .cell = "\"", .label = "registers", .delay_ns = 300 * ms, .node = ®ister_tree }, }); /// SPC's groups by their key, as the spec names them (Appendix A). @@ -566,9 +565,10 @@ test "\" shows the registers rolled, each its first line; Down unrolls them besi p.clock.now_ns = 5 * std.time.ns_per_s; p.clock.stepped_ns = p.clock.now_ns; p.sync(); - // Its key cell at once, the level 300 ms on. + // Nothing in the tag until the level shows 300 ms on (UX D12). + const rest = try a.dupe(u8, try tagline.tagText(p, a, pane)); p.update(.{ .key = .{ .cp = '"' } }); - try std.testing.expect(std.mem.endsWith(u8, try tagline.tagText(p, a, pane), "\" …")); + try std.testing.expectEqualStrings(rest, try tagline.tagText(p, a, pane)); p.advance(p.clock.now_ns); try std.testing.expectEqual(p.clock.now_ns + 300 * std.time.ns_per_ms, p.view().tag_state.due_ns); p.clock.now_ns = p.view().tag_state.due_ns; |
