summaryrefslogtreecommitdiff
path: root/core/keys.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/keys.zig')
-rw-r--r--core/keys.zig19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/keys.zig b/core/keys.zig
index 04a3cc35..c30ef233 100644
--- a/core/keys.zig
+++ b/core/keys.zig
@@ -211,6 +211,23 @@ pub fn handleKey(p: *Pardes, key: Key) void {
}
return;
}
+ // A background question SPC e gave the keyboard: one of its answers'
+ // keys answers it (Diff leaves it asking), Esc leaves it waiting, and
+ // nothing else gets past it (pick-ui SPEC ยง10.4).
+ if (p.view().answering != 0) answering: {
+ const v = p.view();
+ const at = p.paneBySerial(v.answering) orelse break :answering;
+ const i = p.messages.waiting(p.panes[at].?) orelse break :answering;
+ if (key.cp == Key.escape and !key.ctrl and !key.alt) {
+ v.answering = 0;
+ p.needs_frame = true;
+ return;
+ }
+ if (key.ctrl or key.alt or key.cp > 0x7f) return;
+ if (pardes.Messages.answer(p, i, @intCast(key.cp)) and key.cp != 'd') v.answering = 0;
+ return;
+ }
+ p.view().answering = 0;
// A tag in a typing state takes every key (TagState: Help, describe-key).
if (p.view().tag_state.kind != .rest) return tagStateKey(p, key);
if (p.view().window_pick != null) return layout.windowKey(p, key);
@@ -803,7 +820,7 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" {
// A word that is not a side closes nothing.
try std.testing.expect(p.executeBuiltinLine(again, "Del x"));
- try std.testing.expectEqualStrings("Del: takes k, j or nothing", p.panes[again].?.msg[0..p.panes[again].?.msg_len]);
+ try std.testing.expectEqualStrings("Del: takes k, j or nothing", p.messages.saidBy(p.panes[again].?));
try std.testing.expect(p.panes[again] != null);
// DelAbove is Del k, and a line that is not a key never asks.
try std.testing.expect(p.executeBuiltinLine(again, "DelAbove"));