diff options
| author | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-09 19:39:42 +0000 |
|---|---|---|
| committer | Brooks J Rady <b.j.rady@gmail.com> | 2021-03-09 19:39:42 +0000 |
| commit | 06bce9a1fd88651a2e85c120776bc07399206806 (patch) | |
| tree | 6ecb2e8535d9cf2071d4ad5c22a295cd45089d18 /src/common/input | |
| parent | Rename init() to load() in plugin API + Bump deps (diff) | |
| download | sl0ppij-06bce9a1fd88651a2e85c120776bc07399206806.tar.gz sl0ppij-06bce9a1fd88651a2e85c120776bc07399206806.tar.xz sl0ppij-06bce9a1fd88651a2e85c120776bc07399206806.zip | |
Deduplicate the WASM interface structs
Diffstat (limited to 'src/common/input')
| -rw-r--r-- | src/common/input/actions.rs | 4 | ||||
| -rw-r--r-- | src/common/input/handler.rs | 39 | ||||
| -rw-r--r-- | src/common/input/keybinds.rs | 2 |
3 files changed, 4 insertions, 41 deletions
diff --git a/src/common/input/actions.rs b/src/common/input/actions.rs index 88a7036f..059255d3 100644 --- a/src/common/input/actions.rs +++ b/src/common/input/actions.rs @@ -1,6 +1,6 @@ //! Definition of the actions that can be bound to keys. -use super::handler; +use zellij_tile::data::InputMode; /// The four directions (left, right, up, down). #[derive(Clone, Debug)] @@ -19,7 +19,7 @@ pub enum Action { /// Write to the terminal. Write(Vec<u8>), /// Switch to the specified input mode. - SwitchToMode(handler::InputMode), + SwitchToMode(InputMode), /// Resize focus pane in specified direction. Resize(Direction), /// Switch focus to next pane in specified direction. diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index 52db9b4f..e498fbb6 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -10,9 +10,8 @@ use crate::screen::ScreenInstruction; use crate::wasm_vm::{EventType, PluginInputType, PluginInstruction}; use crate::CommandIsExecuting; -use serde::{Deserialize, Serialize}; -use strum_macros::EnumIter; use termion::input::TermReadEventsAndRaw; +use zellij_tile::data::{Help, InputMode}; use super::keybinds::key_to_actions; @@ -269,42 +268,6 @@ impl InputHandler { } } -/// Describes the different input modes, which change the way that keystrokes will be interpreted. -#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, EnumIter, Serialize, Deserialize)] -pub enum InputMode { - /// In `Normal` mode, input is always written to the terminal, except for one special input that - /// triggers the switch to [`InputMode::Command`] mode. - Normal, - /// In `Command` mode, input is bound to actions (more precisely, sequences of actions). - /// `Command` mode gives access to the other modes non-`InputMode::Normal` modes. - /// etc. - Command, - /// `Resize` mode allows resizing the different existing panes. - Resize, - /// `Pane` mode allows creating and closing panes, as well as moving between them. - Pane, - /// `Tab` mode allows creating and closing tabs, as well as moving between them. - Tab, - /// `Scroll` mode allows scrolling up and down within a pane. - Scroll, - RenameTab, -} - -/// Represents the contents of the help message that is printed in the status bar, -/// which indicates the current [`InputMode`] and what the keybinds for that mode -/// are. Related to the default `status-bar` plugin. -#[derive(Default, Debug, Clone, Serialize, Deserialize)] -pub struct Help { - pub mode: InputMode, - pub keybinds: Vec<(String, String)>, // <shortcut> => <shortcut description> -} - -impl Default for InputMode { - fn default() -> InputMode { - InputMode::Normal - } -} - /// Creates a [`Help`] struct indicating the current [`InputMode`] and its keybinds /// (as pairs of [`String`]s). // TODO this should probably be automatically generated in some way diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs index 46abf4ab..da0f1c15 100644 --- a/src/common/input/keybinds.rs +++ b/src/common/input/keybinds.rs @@ -1,12 +1,12 @@ //! 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>>; |
