mirror of
https://github.com/openai/codex.git
synced 2026-11-28 07:32:19 +00:00
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:
1 parent
a1dd74b535
commit
1e85ca099e
61 files changed
+3503
-660
No files matched your search
@@ -15,9 +15,10 @@ use crate::app_event::AppEvent;
|
||||
use crate::app_event_sender::AppEventSender;
|
||||
use crate::key_hint;
|
||||
use crate::key_hint::KeyBindingListExt;
|
||||
use crate::key_hint::ShortcutHint;
|
||||
use crate::key_hint::is_plain_text_key_event;
|
||||
use crate::keymap::ListAction;
|
||||
use crate::keymap::ListKeymap;
|
||||
use crate::keymap::primary_binding;
|
||||
use crate::render::Insets;
|
||||
use crate::render::RectExt as _;
|
||||
use crate::render::renderable::ColumnRenderable;
|
||||
@@ -232,6 +233,10 @@ impl SkillsToggleView {
|
||||
}
|
||||
|
||||
impl BottomPaneView for SkillsToggleView {
|
||||
fn keymap_contexts(&self) -> crate::keymap::KeymapContextSet {
|
||||
crate::keymap::KeymapContextSet::new(crate::keymap::KeymapContext::List)
|
||||
}
|
||||
|
||||
fn handle_key_event(&mut self, key_event: KeyEvent) {
|
||||
// Printable characters always feed search. Movement aliases such as
|
||||
// plain j/k only apply through non-text events or modified bindings.
|
||||
@@ -388,8 +393,10 @@ impl Renderable for SkillsToggleView {
|
||||
|
||||
fn skills_toggle_hint_line(keymap: &ListKeymap) -> Line<'static> {
|
||||
let space = key_hint::plain(KeyCode::Char(' '));
|
||||
let accept = primary_binding(&keymap.accept).filter(|binding| *binding != space);
|
||||
let cancel = primary_binding(&keymap.cancel);
|
||||
let accept = keymap
|
||||
.primary_hint(ListAction::Accept)
|
||||
.filter(|binding| *binding != ShortcutHint::Single(space));
|
||||
let cancel = keymap.primary_hint(ListAction::Cancel);
|
||||
|
||||
match (accept, cancel) {
|
||||
(Some(accept), Some(cancel)) => Line::from(vec![
|
||||
|
||||
Reference in new issue
Block a user