diff --git a/.config/config.toml b/.config/config.toml index 9232098..57cfc93 100644 --- a/.config/config.toml +++ b/.config/config.toml @@ -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 diff --git a/television/action.rs b/television/action.rs index e599141..b7567b1 100644 --- a/television/action.rs +++ b/television/action.rs @@ -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, diff --git a/television/app.rs b/television/app.rs index 330c131..9ca26e2 100644 --- a/television/app.rs +++ b/television/app.rs @@ -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, } diff --git a/television/config/keybindings.rs b/television/config/keybindings.rs index 36c910e..0c97824 100644 --- a/television/config/keybindings.rs +++ b/television/config/keybindings.rs @@ -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 } } }