diff options
| author | Aram Drevekenin <aram@poor.dev> | 2021-10-27 19:20:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-27 19:20:43 +0200 |
| commit | 21e5ffdfd8dce7b2cd1a2a74e948e8e071d22161 (patch) | |
| tree | 7f3da35f3f3960edd90ee880c618b1770d233f12 /zellij-client/src/input_handler.rs | |
| parent | chore(docs): update changelog (diff) | |
| download | sl0ppij-21e5ffdfd8dce7b2cd1a2a74e948e8e071d22161.tar.gz sl0ppij-21e5ffdfd8dce7b2cd1a2a74e948e8e071d22161.tar.xz sl0ppij-21e5ffdfd8dce7b2cd1a2a74e948e8e071d22161.zip | |
fix(input): properly handle bracketed paste (#810)
* fix(input): properly handle bracketed paste
* style(fmt): make rustfmt happy
Diffstat (limited to 'zellij-client/src/input_handler.rs')
| -rw-r--r-- | zellij-client/src/input_handler.rs | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/zellij-client/src/input_handler.rs b/zellij-client/src/input_handler.rs index 78869fd5..2b89741e 100644 --- a/zellij-client/src/input_handler.rs +++ b/zellij-client/src/input_handler.rs @@ -31,7 +31,6 @@ struct InputHandler { command_is_executing: CommandIsExecuting, send_client_instructions: SenderWithContext<ClientInstruction>, should_exit: bool, - pasting: bool, receive_input_instructions: Receiver<(InputInstruction, ErrorContext)>, } @@ -54,7 +53,6 @@ impl InputHandler { command_is_executing, send_client_instructions, should_exit: false, - pasting: false, receive_input_instructions, } } @@ -65,9 +63,6 @@ impl InputHandler { let mut err_ctx = OPENCALLS.with(|ctx| *ctx.borrow()); err_ctx.add_call(ContextType::StdinHandler); let alt_left_bracket = vec![27, 91]; - let bracketed_paste_start = vec![27, 91, 50, 48, 48, 126]; // \u{1b}[200~ - let bracketed_paste_end = vec![27, 91, 50, 48, 49, 126]; // \u{1b}[201 - if !self.options.disable_mouse_mode { self.os_input.enable_mouse(); } @@ -92,12 +87,6 @@ impl InputHandler { if unsupported_key == alt_left_bracket { let key = Key::Alt('['); self.handle_key(&key, raw_bytes); - } else if unsupported_key == bracketed_paste_start { - self.pasting = true; - self.handle_unknown_key(raw_bytes); - } else if unsupported_key == bracketed_paste_end { - self.pasting = false; - self.handle_unknown_key(raw_bytes); } else { // this is a hack because termion doesn't recognize certain keys // in this case we just forward it to the terminal @@ -106,6 +95,12 @@ impl InputHandler { } } } + Ok((InputInstruction::PastedText(raw_bytes), _error_context)) => { + if self.mode == InputMode::Normal || self.mode == InputMode::Locked { + let action = Action::Write(raw_bytes); + self.dispatch_action(action); + } + } Ok((InputInstruction::SwitchToMode(input_mode), _error_context)) => { self.mode = input_mode; } @@ -121,20 +116,10 @@ impl InputHandler { } fn handle_key(&mut self, key: &Key, raw_bytes: Vec<u8>) { let keybinds = &self.config.keybinds; - if self.pasting { - // we're inside a paste block, if we're in a mode that allows sending text to the - // terminal, send all text directly without interpreting it - // otherwise, just discard the input - if self.mode == InputMode::Normal || self.mode == InputMode::Locked { - let action = Action::Write(raw_bytes); - self.dispatch_action(action); - } - } else { - for action in Keybinds::key_to_actions(key, raw_bytes, &self.mode, keybinds) { - let should_exit = self.dispatch_action(action); - if should_exit { - self.should_exit = true; - } + for action in Keybinds::key_to_actions(key, raw_bytes, &self.mode, keybinds) { + let should_exit = self.dispatch_action(action); + if should_exit { + self.should_exit = true; } } } |
