Support two-stroke TUI key chords (#36511)

## What changed

- Accept two-stroke bindings such as `ctrl-x ctrl-s` in TUI keymap configuration while preserving arrays as alternative bindings.
- Route chords through the active TUI context, show pending and configured chord hints, and cancel pending chords on `esc`, context changes, or a one-second timeout.
- Extend `/keymap` to capture, add, replace, and display key chords.
- Reject chords that conflict with active single-key bindings, overlapping-context chords, or reserved terminal shortcuts.

## Testing

- Add coverage for chord parsing, validation, matching, timeout and cancellation behavior, context dispatch, key capture, and rendered shortcut hints.

GitOrigin-RevId: dfdede03f518d4936ad8621ebf5537026f2b282e
This commit is contained in:
Felipe Coury authored and copyberry committed 2026-08-01 17:43:03 +00:00
1 parent a1dd74b535
commit 1e85ca099e
61 files changed
+3503 -660

No files matched your search

+5 -5
View File
@@ -20,7 +20,7 @@ use unicode_width::UnicodeWidthStr;
use crate::app_event_sender::AppEventSender;
use crate::key_hint;
use crate::key_hint::KeyBinding;
use crate::key_hint::ShortcutHint;
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
use crate::motion::MotionMode;
use crate::motion::ReducedMotionIndicator;
@@ -50,7 +50,7 @@ pub(crate) struct StatusIndicatorWidget {
/// Optional suffix rendered after the elapsed/interrupt segment.
inline_message: Option<String>,
show_interrupt_hint: bool,
interrupt_binding: Option<KeyBinding>,
interrupt_binding: Option<ShortcutHint>,
elapsed_running: Duration,
last_resume_at: Instant,
@@ -89,7 +89,7 @@ impl StatusIndicatorWidget {
details_max_lines: STATUS_DETAILS_DEFAULT_MAX_LINES,
inline_message: None,
show_interrupt_hint: true,
interrupt_binding: Some(key_hint::plain(KeyCode::Esc)),
interrupt_binding: Some(key_hint::plain(KeyCode::Esc).into()),
elapsed_running: Duration::ZERO,
last_resume_at: Instant::now(),
is_paused: false,
@@ -152,7 +152,7 @@ impl StatusIndicatorWidget {
self.show_interrupt_hint = visible;
}
pub(crate) fn set_interrupt_binding(&mut self, binding: Option<KeyBinding>) {
pub(crate) fn set_interrupt_binding(&mut self, binding: Option<ShortcutHint>) {
self.interrupt_binding = binding;
}
@@ -422,7 +422,7 @@ mod tests {
crate::tui::FrameRequester::test_dummy(),
/*animations_enabled*/ false,
);
w.set_interrupt_binding(Some(key_hint::plain(KeyCode::F(12))));
w.set_interrupt_binding(Some(key_hint::plain(KeyCode::F(12)).into()));
w.is_paused = true;
w.elapsed_running = Duration::ZERO;