diff options
| author | Brooks Rady <b.j.rady@gmail.com> | 2021-03-26 13:20:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-26 13:20:06 +0000 |
| commit | d818661c727a59312e1a43432e84fbeec79fc145 (patch) | |
| tree | e8ab04124ee7f5c87cd88be63c1867c7d9b2289c /src/common/input/keybinds.rs | |
| parent | fix(render): various rendering issues (#238) (diff) | |
| parent | Fix some overzealous format!() removals and a stray comment (diff) | |
| download | sl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.tar.gz sl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.tar.xz sl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.zip | |
feat(plugin): refactored to a new and more general plugin API
- Changed `init()` to `load()`
- Deduplicated structs that are in both `zellij` and `zellij-tile`
- WASM thread now keeps a mapping of plugins and event subscriptions
- Added host-functions for subscribing and unsubscribing from events
- Introduced the `update(event)` callback into the API (which is called to handle plugin events)
- Made mode changes send an event to the WASM thread
- Removed the `AppInstruction::Get/SetState` calls (and any global state)
- Removed the `get_help()` host function
- Added an event system for key-presses
- Added an event for updating tabs
- Ported support for renaming tabs
- Removed every plugin callback other than `load()`, `update(event)`, and `draw(rows, cols)`
- Removed every WASM thread event other than Load, Draw, Update, Unload, and Quit
- Calls render after a plugin is updated
- Switched back to upstream `termion`
- Loads of lint fixing
- Shrunk and simplified the code!
Diffstat (limited to 'src/common/input/keybinds.rs')
| -rw-r--r-- | src/common/input/keybinds.rs | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs index 4b676037..7b1e8779 100644 --- a/src/common/input/keybinds.rs +++ b/src/common/input/keybinds.rs @@ -1,12 +1,11 @@ //! Mapping of inputs to sequences of actions. use super::actions::{Action, Direction}; -use super::handler::InputMode; use std::collections::HashMap; use strum::IntoEnumIterator; -use termion::event::Key; +use zellij_tile::data::*; type Keybinds = HashMap<InputMode, ModeKeybinds>; type ModeKeybinds = HashMap<Key, Vec<Action>>; @@ -17,14 +16,14 @@ pub fn get_default_keybinds() -> Result<Keybinds, String> { let mut defaults = Keybinds::new(); for mode in InputMode::iter() { - defaults.insert(mode, get_defaults_for_mode(&mode)?); + defaults.insert(mode, get_defaults_for_mode(&mode)); } Ok(defaults) } /// Returns the default keybinds for a givent [`InputMode`]. -fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> { +fn get_defaults_for_mode(mode: &InputMode) -> ModeKeybinds { let mut defaults = ModeKeybinds::new(); match *mode { @@ -227,10 +226,7 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> { defaults.insert(Key::Up, vec![Action::ScrollUp]); } InputMode::RenameTab => { - defaults.insert( - Key::Char('\n'), - vec![Action::SaveTabName, Action::SwitchToMode(InputMode::Tab)], - ); + defaults.insert(Key::Char('\n'), vec![Action::SwitchToMode(InputMode::Tab)]); defaults.insert( Key::Ctrl('g'), vec![Action::SwitchToMode(InputMode::Normal)], @@ -245,7 +241,7 @@ fn get_defaults_for_mode(mode: &InputMode) -> Result<ModeKeybinds, String> { } } - Ok(defaults) + defaults } /// Converts a [`Key`] terminal event to a sequence of [`Action`]s according to the current |
