diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-23 23:57:18 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-23 23:57:18 +0000 |
| commit | 23df8e447a1e73b8e3536fbf9781f1aafcee2765 (patch) | |
| tree | eb462c458798ca3ff14f79f1e23d4d22c115f456 /src/common/input | |
| parent | Initial implementation of the update callback + upstream termion (diff) | |
| download | sl0ppij-23df8e447a1e73b8e3536fbf9781f1aafcee2765.tar.gz sl0ppij-23df8e447a1e73b8e3536fbf9781f1aafcee2765.tar.xz sl0ppij-23df8e447a1e73b8e3536fbf9781f1aafcee2765.zip | |
Move most key handling to the update() + event system
Diffstat (limited to 'src/common/input')
| -rw-r--r-- | src/common/input/handler.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 90afb64c..4b948cbf 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -10,8 +10,8 @@ use crate::screen::ScreenInstruction; use crate::wasm_vm::{NaughtyEventType, PluginInputType, PluginInstruction}; use crate::CommandIsExecuting; -use termion::input::TermReadEventsAndRaw; -use zellij_tile::data::{Event, Help, InputMode, Key}; +use termion::input::{TermRead, TermReadEventsAndRaw}; +use zellij_tile::data::{Help, InputMode, Key}; use super::keybinds::key_to_actions; @@ -61,19 +61,15 @@ impl InputHandler { 'input_loop: loop { //@@@ I think this should actually just iterate over stdin directly let stdin_buffer = self.os_input.read_from_stdin(); - // FIXME: Kill me someday (soon) - drop( - self.send_plugin_instructions - .send(PluginInstruction::GlobalInput(stdin_buffer.clone())), - ); for key_result in stdin_buffer.events_and_raw() { match key_result { Ok((event, raw_bytes)) => match event { termion::event::Event::Key(key) => { let key = cast_termion_key(key); + // FIXME: This is a bit of a hack to get resizing to work! drop( - self.send_plugin_instructions - .send(PluginInstruction::Update(Event::KeyPress(key))), + self.send_screen_instructions + .send(ScreenInstruction::Render), ); // FIXME this explicit break is needed because the current test // framework relies on it to not create dead threads that loop @@ -327,6 +323,10 @@ pub fn input_loop( .handle_input(); } +pub fn parse_keys(input_bytes: &[u8]) -> Vec<Key> { + input_bytes.keys().flatten().map(cast_termion_key).collect() +} + // FIXME: This is an absolutely cursed function that should be destroyed as soon // as an alternative that doesn't touch zellij-tile can be developed... fn cast_termion_key(event: termion::event::Key) -> Key { |
