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/lib.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/lib.rs')
| -rw-r--r-- | zellij-client/src/lib.rs | 48 |
1 files changed, 6 insertions, 42 deletions
diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 06f7e32e..45842fec 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -2,6 +2,7 @@ pub mod os_input_output; mod command_is_executing; mod input_handler; +mod stdin_handler; use log::info; use std::env::current_exe; @@ -12,15 +13,14 @@ use std::thread; use crate::{ command_is_executing::CommandIsExecuting, input_handler::input_loop, - os_input_output::ClientOsApi, + os_input_output::ClientOsApi, stdin_handler::stdin_loop, }; -use termion::input::TermReadEventsAndRaw; use zellij_tile::data::InputMode; use zellij_utils::{ channels::{self, ChannelWithContext, SenderWithContext}, consts::{SESSION_NAME, ZELLIJ_IPC_PIPE}, errors::{ClientContext, ContextType, ErrorInstruction}, - input::{actions::Action, config::Config, mouse::MouseEvent, options::Options}, + input::{actions::Action, config::Config, options::Options}, ipc::{ClientAttributes, ClientToServerMsg, ExitReason, ServerToClientMsg}, termion, }; @@ -91,9 +91,10 @@ pub enum ClientInfo { } #[derive(Debug, Clone)] -pub enum InputInstruction { +pub(crate) enum InputInstruction { KeyEvent(termion::event::Event, Vec<u8>), SwitchToMode(InputMode), + PastedText(Vec<u8>), } pub fn start_client( @@ -193,44 +194,7 @@ pub fn start_client( .spawn({ let os_input = os_input.clone(); let send_input_instructions = send_input_instructions.clone(); - move || loop { - let stdin_buffer = os_input.read_from_stdin(); - for key_result in stdin_buffer.events_and_raw() { - let (key_event, raw_bytes) = key_result.unwrap(); - if let termion::event::Event::Mouse(me) = key_event { - let mouse_event = zellij_utils::input::mouse::MouseEvent::from(me); - if let MouseEvent::Hold(_) = mouse_event { - // as long as the user is holding the mouse down (no other stdin, eg. - // MouseRelease) we need to keep sending this instruction to the app, - // because the app itself doesn't have an event loop in the proper - // place - let mut poller = os_input.stdin_poller(); - send_input_instructions - .send(InputInstruction::KeyEvent( - key_event.clone(), - raw_bytes.clone(), - )) - .unwrap(); - loop { - let ready = poller.ready(); - if ready { - break; - } - send_input_instructions - .send(InputInstruction::KeyEvent( - key_event.clone(), - raw_bytes.clone(), - )) - .unwrap(); - } - continue; - } - } - send_input_instructions - .send(InputInstruction::KeyEvent(key_event, raw_bytes)) - .unwrap(); - } - } + move || stdin_loop(os_input, send_input_instructions) }); let _input_thread = thread::Builder::new() |
