diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 20:33:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 20:33:01 -0300 |
| commit | abe3817e8dd0af41e6b5786bdbeb631219b58c23 (patch) | |
| tree | d2db2ba07f1b8ee743926aa87b8c25070f72fcb6 /core/keys.zig | |
| parent | 480f36b85299fa7407c20a2d6482dd093f842bf7 (diff) | |
| download | pardes-abe3817e8dd0af41e6b5786bdbeb631219b58c23.tar.gz pardes-abe3817e8dd0af41e6b5786bdbeb631219b58c23.zip | |
Prompt: a body's text prompts ask in its tag's head (walk UI, pick-ui SPEC.md §7.1, §7.2, item 1 of line E): `s S K A-K | A-| ! A-! $` from a body are a typing state of the view's tag (TagState.Kind.prompt, its state Prompt.zig, its field A's Field), drawn after the prefix in place of the tag's own text (R1): box `^`, the prompt's key cell, the field, the plain word it stands for (`= Exec Edit x/self/`, `Edit g/re/`, `Edit |tr a-z A-Z`, `Edit >cmd`; none for `! A-! $`), its count (`2 selections in 3 lines`, `keeps 1 of 2`, `0` for no match, the selections it began with back), the hints; the live machinery as it was (normal.applySelRegex, now returning what it found; the pipe off the loop, Pipe.submit split from the notice band's submitPipe); a pattern that is no regex changes nothing, the last result drawn dimmed (body_layer) and the reason at the count's place in the error ink (TagState.Style.err, regexp's message); Up/Down recall the history inline, Ctrl-r unrolls it as a band step filtered by the field (three session histories, Pardes.prompt_history: search and select's, the pipes', the command line's, 16 lines each, in the digest and the dump); Esc and Backspace on an empty field put the body back; Enter keeps the line in its history and the pattern in `/`, the command in `|`; a paste goes into the field; a prompt for a tag's or a header's text, Save's path, a terminal's `/` still ask on the notice band; wire 37; TEST FIRST: Prompt.zig "s asks in the tag's head ..." and "Enter keeps what s found ... a pipe from the body asks in the tag and runs off the loop"; Pipe.zig's and panes.zig's prompt tests and test/behaviour/keys.zig's two read the head; goldens pipe, selregex, msg (the prompt in the tag head, no chip); core-test 1014/1180 (166 skipped), shell-test 1227/1230, pane-test 182/184 (the 1 failure A's: `SPC h ?` is Help in the tag now), behaviour-test 274/277 (the 3 failures A's: window mode's head, a struck leader key), process-test the 6 of A's report plus none of mine, term-test 17/17, kitty-test 45/45
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/keys.zig')
| -rw-r--r-- | core/keys.zig | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/keys.zig b/core/keys.zig index 6f43e166..6ffca8e1 100644 --- a/core/keys.zig +++ b/core/keys.zig @@ -20,6 +20,7 @@ const Pipe = @import("Pipe.zig"); const Registers = @import("Registers.zig"); const bindings = @import("bindings.zig"); const TagState = @import("TagState.zig"); +const Prompt = @import("Prompt.zig"); const Pardes = pardes.Pardes; const Pane = panes.Pane; const Text = panes.Text; @@ -360,8 +361,9 @@ pub fn handleKey(p: *Pardes, key: Key) void { .save => if (submit) exec.submitSave(p, p.view().active), .search => if (submit) look.submitSearch(p, p.view().active) - else if (normal.selRegexArmed(pane)) |_| if (target) |answered| - normal.applySelRegex(p, pane, answered, "", .select), + else if (normal.selRegexArmed(pane)) |_| if (target) |answered| { + _ = normal.applySelRegex(p, pane, answered, "", .select); + }, .none, .del_side, .repl_choice, .name => unreachable, } pane.closePrompt(); @@ -372,7 +374,9 @@ pub fn handleKey(p: *Pardes, key: Key) void { return; } edit.handleInsert(p.editor(), &pane.input, key); - if (normal.selRegexArmed(pane)) |a| if (panes.promptTarget(p, pane)) |answered| normal.applySelRegex(p, pane, answered, a.pat, a.mode); + if (normal.selRegexArmed(pane)) |a| if (panes.promptTarget(p, pane)) |answered| { + _ = normal.applySelRegex(p, pane, answered, a.pat, a.mode); + }; return; } if (header == null) if (TagState.current(p, p.view())) |cur| if (cur.root != .leader and cur.root != .window) { @@ -549,9 +553,10 @@ fn leaderTake(p: *Pardes, c: u8) void { fn tagStateKey(p: *Pardes, key: Key) void { const v = p.view(); const s = &v.tag_state; + if (s.kind == .prompt) return Prompt.key(p, key); if (TagState.hostOf(p) == null or hit(key, config.escape)) return TagState.toRest(p); switch (s.kind) { - .rest => unreachable, + .rest, .prompt => unreachable, .describe => return TagState.toRest(p), .help => { const plain = !key.ctrl and !key.alt; |
