diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 19:35:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 19:37:58 -0300 |
| commit | 173b0b8a4c854715e8bb697efc5c066927b7b671 (patch) | |
| tree | 3318589923205da6c7099f9bc4a92bee1f6ddd04 /core/Band.zig | |
| parent | f44d1b7d040acf674814be3cde336527833450e9 (diff) | |
| download | pardes-173b0b8a4c854715e8bb697efc5c066927b7b671.tar.gz pardes-173b0b8a4c854715e8bb697efc5c066927b7b671.zip | |
TagState, builtins: describe-key (walk UI, pick-ui SPEC.md §4.5, item 5 of line A): SPC h k runs a new builtin, Keys (its word anywhere does the same), and the next keys typed are replayed in the tag of the pane it ran in (TagState.kind describe, its sequence in the view's scope_root and scope): the head says ` Keys` and the keys as key cells; a sequence that reaches a leaf shows ` Keys g ▸ d Def` and unrolls its level in the band with the leaf on the cursor and its doc beside it, for every root (g d, ] f, SPC l r, C-w h); Enter runs it, typed as its keys; a sequence nothing is bound to is struck, `runs nothing` (a first key that is no root's, `starts no sequence`); Backspace takes a key back, Esc goes to rest, any key after a sequence ended starts the next; docs/typ/builtins-tui.json and -gui.json have Keys (the tui's made by `zig build builtins-json`, the gui's line the same); TESTS: TagState.zig's describe-key (g d replayed with its level and doc in the band, ] f, SPC l r, g q struck, g e run by Enter) and window mode's level (C-w: its cell at once, its level after the delay, kept while h j k l move the outline, gone at Enter); core-test 1005 pass, 166 skip, 0 fail
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/Band.zig')
| -rw-r--r-- | core/Band.zig | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/Band.zig b/core/Band.zig index 079a1bcc..8a433243 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -88,7 +88,11 @@ pub fn takes(p: *Pardes, id: usize) u16 { switch (s.kind) { .rest => {}, .help => return @max(doc_rows, @max(1, @min(Cursor.shown, s.nhits))), - .describe => return 0, + .describe => { + if (!s.found) return 0; + var children: [bindings.max_children]bindings.Child = undefined; + return @max(doc_rows, levelRows(@intCast(bindings.level(p, s.scope_root.?, s.scope[0 .. s.scope_n - 1], &children).len))); + }, } if (!s.unrolled) return 0; const cur = TagState.current(p, v) orelse return 0; @@ -116,7 +120,23 @@ pub fn of(p: *Pardes, arena: std.mem.Allocator, pane: *Pane, id: usize) !?Band { try band.place(p, arena, pane, id); return band; }, - .describe => return null, + // describe-key's leaf: its level replayed, the leaf on the cursor, + // and its doc. + .describe => { + const root = s.scope_root.?; + const path = s.scope[0 .. s.scope_n - 1]; + var children: [bindings.max_children]bindings.Child = undefined; + const level = bindings.level(p, root, path, &children); + var at: usize = 0; + for (level, 0..) |c, i| if (c.key == s.scope[s.scope_n - 1]) { + at = i; + }; + const node = bindings.nodeAt(root, path); + band.add(try levelStep(arena, pane, level, at, if (node) |n| s.used[n.group] else 0)); + band.add(try docStep(p, arena, root, path, level[at])); + try band.place(p, arena, pane, id); + return band; + }, } const cur = TagState.current(p, v).?; // The level, its cursor on the child it names, else the leaf its group |
