summaryrefslogtreecommitdiff
path: root/core/keys.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 22:16:38 -0300
committerGabriel Schneider <[email protected]>2026-11-24 22:16:38 -0300
commitb44a129a8854483dbe45ce2bcfa09f33ccbd6e8c (patch)
tree3038f283024ebee6dd73fbea186e0383ee89c9da /core/keys.zig
parent7bac0f3d594b029a3631687ec3d8dd3626e0f447 (diff)
downloadpardes-b44a129a8854483dbe45ce2bcfa09f33ccbd6e8c.tar.gz
pardes-b44a129a8854483dbe45ce2bcfa09f33ccbd6e8c.zip
registers: `"` shows the registers rolled in the tag, each its key and the first line of its value (`" ▸ " self.dirty = true; a const best = rank(q, nam… / — … % core/x.zig . o # 1 _ —`), `↓` unrolls them a row each (key, what it is, first line) beside the cursor's value in full, and choosing one (its key, or Enter) goes down to its verbs rolled (`" a ▸ p after P before R replace y into`), Backspace back up, Esc to rest (pick-ui SPEC §9, walk UI line F item 1): the level is built from the registers (and the four computed from the pane with the keyboard) when it is read, as the addon words join SPC's (bindings.registerLevel, registerValue: the first value only, a first line cut at 24 columns and never scanned past 96 bytes, the value step reading only the lines the band shows); a register named (`t.normal.register`, the parser's) is the root `"` with that key as its path (TagState.current), its verbs a node of normal mode's paste, yank and replace roles (bindings.register_verbs, a group slot of its own: TagState.used one longer, the dump with it); keys.prefixKey reads the level at the current path, Esc there goes to rest (normal mode's Esc would have named the register ESC, then left the pane), Backspace from the verbs goes back to `"`; TEST: bindings.zig "\" shows the registers rolled ..." (the level, the band's rows and value, Enter, Backspace, `a p` pasting, Esc); core-test 1024/1191 (167 skipped), 0 failed, load 5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/keys.zig')
-rw-r--r--core/keys.zig28
1 files changed, 24 insertions, 4 deletions
diff --git a/core/keys.zig b/core/keys.zig
index 04a3cc35..78f45820 100644
--- a/core/keys.zig
+++ b/core/keys.zig
@@ -376,7 +376,7 @@ pub fn handleKey(p: *Pardes, key: Key) void {
return;
}
if (header == null) if (TagState.current(p, p.view())) |cur| if (cur.root != .leader and cur.root != .window) {
- if (prefixKey(p, t, cur.root, key)) return;
+ if (prefixKey(p, t, cur, key)) return;
};
if (t == &pane.body and pane.jump.items.len > 0) return normal.jumpKey(p, pane, t, key);
// A query pane's line 1 answers Enter, Esc and the stepping keys
@@ -679,15 +679,27 @@ fn levelKey(p: *Pardes, root: bindings.Root, path: []const u8, key: Key) LevelSt
/// A key while a helix prefix waits in text `t` (g m z Z [ ]): which-key's
/// own, else the prefix's, the leaf it runs remembered. True when taken here.
-fn prefixKey(p: *Pardes, t: *Text, root: bindings.Root, key: Key) bool {
+fn prefixKey(p: *Pardes, t: *Text, cur: TagState.Current, key: Key) bool {
+ const root = cur.root;
if (root != .register and key.cp == config.leader_help and !key.ctrl and !key.alt) {
TagState.openHelp(p, root, "");
return true;
}
- switch (levelKey(p, root, "", key)) {
+ // `"` and a register's verbs: Esc goes to rest (normal mode's would
+ // name the register, or leave the pane).
+ if (root == .register and hit(key, config.escape)) {
+ t.normal.clear();
+ return true;
+ }
+ switch (levelKey(p, root, cur.path, key)) {
.taken => return true,
.up => {
t.normal = .{};
+ // A register's verbs go back up to the registers (SPEC §9).
+ if (root == .register and cur.path.len > 0) {
+ t.normal.prefix = .register_prefix;
+ p.view().tag_state.hi = 0;
+ }
return true;
},
.take => |c| {
@@ -697,7 +709,15 @@ fn prefixKey(p: *Pardes, t: *Text, root: bindings.Root, key: Key) bool {
.pass => {
if (!key.ctrl and !key.alt and key.cp >= 0x20 and key.cp < 0x7f) {
const k: u8 = @intCast(key.cp);
- if (bindings.nodeAt(root, &.{k}) != null) TagState.ran(p.view(), root, "", k);
+ var buf: [2]u8 = .{ 0, k };
+ if (cur.path.len > 0) buf[0] = cur.path[0];
+ const here = if (cur.path.len > 0) buf[0..2] else buf[1..2];
+ if (bindings.nodeAt(root, here) != null) TagState.ran(p.view(), root, cur.path, k);
+ // A register named: its verbs, rolled, the cursor afresh.
+ if (root == .register) {
+ p.view().tag_state.hi = 0;
+ p.view().tag_state.unrolled = false;
+ }
}
return false;
},