summaryrefslogtreecommitdiff
path: root/core/keys.zig
diff options
context:
space:
mode:
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;
},