From 542e6677e23e277ce39edb3e96d729e9adca99d0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 19:29:06 -0300 Subject: split pardes.zig by noun, keys: the keyboard leaves the session for src/keys.zig, free functions on it as mouse.zig is the mouse: handleKey, leaderKey, replayKeys, cycleMode, toggleTty, questionChoices and answerQuestion; their callers name keys (builtins.zig, ninep/ctl.zig, normal.zig, whose own `keys` are the replayed keys, so it imports the file as keyboard; update calls keys.handleKey); comments citing Pardes.handleKey and Pardes.answerQuestion cite keys; tests moved with them, by name: Esc back into a tty leaves its view at the prompt; Del from a key asks which neighbour takes the rows; nothing else asks; raw tty Esc backs out and Shift-Esc is the program's Esc; with ProgramEsc raw tty Escape only leaves at a shell prompt; the Del question shows only once its delay is up: a quick SPC d j never sees it; raw tty Ctrl-B switches to editor mode without sending child input; raw tty forwards Ctrl letters and former global shortcuts to the child; s in a header selects in the header's own text; a pure move, no field touched, a dump and the wire as they were; gates on tui: core-test 960/960, behaviour-test 238/238 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/normal.zig | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/normal.zig') diff --git a/src/normal.zig b/src/normal.zig index fefdd88c..6a65ee3e 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -12,6 +12,7 @@ const modal = @import("modal.zig"); const panes = @import("panes.zig"); const edit = @import("edit.zig"); const config = @import("config.zig"); +const keyboard = @import("keys.zig"); const pdf_enabled = panes.Pdf.enabled; const Pane = panes.Pane; const Text = panes.Text; @@ -885,7 +886,7 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) void { const notation = p.registers.value(name, 0) orelse return; const keys = Macro.decode(p.scratch.allocator(), notation) catch return; p.register = 0; - for (0..a.count) |_| p.replayKeys(keys); + for (0..a.count) |_| keyboard.replayKeys(p, keys); }, .repeat_insert => { const m = &p.macro; @@ -897,10 +898,10 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) void { // helix repeat_last_insert: the command once, what was typed // count times, and out of insert mode the way it was left const typed = @min(m.typed_from, keys.len); - p.replayKeys(keys[0..typed]); + keyboard.replayKeys(p, keys[0..typed]); if (keys.len == typed) return; - for (0..a.count) |_| p.replayKeys(keys[typed .. keys.len - 1]); - p.replayKeys(keys[keys.len - 1 ..]); + for (0..a.count) |_| keyboard.replayKeys(p, keys[typed .. keys.len - 1]); + keyboard.replayKeys(p, keys[keys.len - 1 ..]); }, // prefix keys: what they begin is the command .goto_prefix, .view_prefix, .next_prefix, .prev_prefix, .register_prefix, .view_prefix_sticky => {}, -- cgit v1.3