aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-client/src/input_handler.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-06-14 17:11:02 +0200
committerGitHub <noreply@github.com>2024-06-14 17:11:02 +0200
commit1f0ae94f01647eab66cabbd11434ecae1fac8da3 (patch)
treeb568f9ffc2064f4bdfd9c02c0aa5e581a3d1e750 /zellij-client/src/input_handler.rs
parentdocs(readme): add name origin section (#3391) (diff)
downloadsl0ppij-1f0ae94f01647eab66cabbd11434ecae1fac8da3.tar.gz
sl0ppij-1f0ae94f01647eab66cabbd11434ecae1fac8da3.tar.xz
sl0ppij-1f0ae94f01647eab66cabbd11434ecae1fac8da3.zip
feat(plugins): rebind keys at runtime (#3422)
* refactor(server): interpret keys on server so they can be rebound * feat(plugins): allow rebinding keys at runtime * various cleanups * add tests * style(fmt): rustfmt * fix(tests): address (some) e2e test flakiness * style(fmt): rustfmt
Diffstat (limited to 'zellij-client/src/input_handler.rs')
-rw-r--r--zellij-client/src/input_handler.rs26
1 files changed, 6 insertions, 20 deletions
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs
index b00d1280..a3759063 100644
--- a/zellij-client/src/input_handler.rs
+++ b/zellij-client/src/input_handler.rs
@@ -146,9 +146,6 @@ impl InputHandler {
)) => {
self.handle_key(&key_with_modifier, raw_bytes, true);
},
- Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => {
- self.mode = input_mode;
- },
Ok((
InputInstruction::AnsiStdinInstructions(ansi_stdin_instructions),
_error_context,
@@ -180,18 +177,13 @@ impl InputHandler {
raw_bytes: Vec<u8>,
is_kitty_keyboard_protocol: bool,
) {
- let keybinds = &self.config.keybinds;
- for action in keybinds.get_actions_for_key_in_mode_or_default_action(
- &self.mode,
- key,
+ // we interpret the keys into actions on the server side so that we can change the
+ // keybinds at runtime
+ self.os_input.send_to_server(ClientToServerMsg::Key(
+ key.clone(),
raw_bytes,
is_kitty_keyboard_protocol,
- ) {
- let should_exit = self.dispatch_action(action, None);
- if should_exit {
- self.should_exit = true;
- }
- }
+ ));
}
fn handle_stdin_ansi_instruction(&mut self, ansi_stdin_instructions: AnsiStdinInstruction) {
match ansi_stdin_instructions {
@@ -316,14 +308,8 @@ impl InputHandler {
self.exit(ExitReason::NormalDetached);
should_break = true;
},
- Action::SwitchToMode(mode) => {
- // this is an optimistic update, we should get a SwitchMode instruction from the
- // server later that atomically changes the mode as well
- self.mode = mode;
- self.os_input
- .send_to_server(ClientToServerMsg::Action(action, None, None));
- },
Action::CloseFocus
+ | Action::SwitchToMode(..)
| Action::ClearScreen
| Action::NewPane(..)
| Action::Run(_)