mirror of
https://github.com/alexpasmantier/television.git
synced 2025-07-28 22:01:39 +00:00
feat(bindings): expose hardcoded text input actions
This commit is contained in:
parent
f7d0963d6f
commit
f305f4a55e
@ -125,16 +125,6 @@ sort_alphabetically = true
|
||||
# Keybindings and Events
|
||||
# ----------------------------------------------------------------------------
|
||||
#
|
||||
# HARDCODED KEYBINDINGS (cannot be changed via config):
|
||||
# Input field actions (always active):
|
||||
# Backspace - Delete previous character
|
||||
# Ctrl+w - Delete previous word
|
||||
# Ctrl+u - Delete entire line
|
||||
# Delete - Delete next character
|
||||
# Left/Right - Move cursor left/right
|
||||
# Home / Ctrl+a - Go to input start
|
||||
# End / Ctrl+e - Go to input end
|
||||
#
|
||||
# NEW CONFIGURATION FORMAT:
|
||||
# -------------------------
|
||||
# The keybindings are now structured as Key -> Action mappings
|
||||
@ -184,6 +174,19 @@ ctrl-o = "toggle_preview"
|
||||
ctrl-h = "toggle_help"
|
||||
f12 = "toggle_status_bar"
|
||||
|
||||
# Input field actions
|
||||
# ----------------------------------------
|
||||
backspace = "delete_prev_char"
|
||||
ctrl-w = "delete_prev_word"
|
||||
ctrl-u = "delete_line"
|
||||
delete = "delete_next_char"
|
||||
left = "go_to_prev_char"
|
||||
right = "go_to_next_char"
|
||||
home = "go_to_input_start"
|
||||
ctrl-a = "go_to_input_start"
|
||||
end = "go_to_input_end"
|
||||
ctrl-e = "go_to_input_end"
|
||||
|
||||
# Event bindings
|
||||
# ----------------------------------------------------------------------------
|
||||
# Event bindings map non-keyboard events to actions
|
||||
|
@ -12,22 +12,16 @@ pub enum Action {
|
||||
#[serde(skip)]
|
||||
AddInputChar(char),
|
||||
/// Delete the character before the cursor from the input buffer.
|
||||
#[serde(skip)]
|
||||
DeletePrevChar,
|
||||
/// Delete the previous word from the input buffer.
|
||||
#[serde(skip)]
|
||||
DeletePrevWord,
|
||||
/// Delete the character after the cursor from the input buffer.
|
||||
#[serde(skip)]
|
||||
DeleteNextChar,
|
||||
/// Delete the current line from the input buffer.
|
||||
#[serde(skip)]
|
||||
DeleteLine,
|
||||
/// Move the cursor to the character before the current cursor position.
|
||||
#[serde(skip)]
|
||||
GoToPrevChar,
|
||||
/// Move the cursor to the character after the current cursor position.
|
||||
#[serde(skip)]
|
||||
GoToNextChar,
|
||||
/// Move the cursor to the start of the input buffer.
|
||||
GoToInputStart,
|
||||
|
@ -497,14 +497,6 @@ impl App {
|
||||
} else {
|
||||
// fallback to text input events
|
||||
match keycode {
|
||||
Key::Backspace => Action::DeletePrevChar,
|
||||
Key::Ctrl('w') => Action::DeletePrevWord,
|
||||
Key::Ctrl('u') => Action::DeleteLine,
|
||||
Key::Delete => Action::DeleteNextChar,
|
||||
Key::Left => Action::GoToPrevChar,
|
||||
Key::Right => Action::GoToNextChar,
|
||||
Key::Home | Key::Ctrl('a') => Action::GoToInputStart,
|
||||
Key::End | Key::Ctrl('e') => Action::GoToInputEnd,
|
||||
Key::Char(c) => Action::AddInputChar(c),
|
||||
_ => Action::NoOp,
|
||||
}
|
||||
|
@ -233,6 +233,18 @@ impl Default for KeyBindings {
|
||||
bindings.insert(Key::Ctrl('h'), Action::ToggleHelp);
|
||||
bindings.insert(Key::F(12), Action::ToggleStatusBar);
|
||||
|
||||
// Input field actions
|
||||
bindings.insert(Key::Backspace, Action::DeletePrevChar);
|
||||
bindings.insert(Key::Ctrl('w'), Action::DeletePrevWord);
|
||||
bindings.insert(Key::Ctrl('u'), Action::DeleteLine);
|
||||
bindings.insert(Key::Delete, Action::DeleteNextChar);
|
||||
bindings.insert(Key::Left, Action::GoToPrevChar);
|
||||
bindings.insert(Key::Right, Action::GoToNextChar);
|
||||
bindings.insert(Key::Home, Action::GoToInputStart);
|
||||
bindings.insert(Key::Ctrl('a'), Action::GoToInputStart);
|
||||
bindings.insert(Key::End, Action::GoToInputEnd);
|
||||
bindings.insert(Key::Ctrl('e'), Action::GoToInputEnd);
|
||||
|
||||
Self { bindings }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user