From 0ea8ce497d899e1a9faa241cfeaedcaa35f8e3f0 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Thu, 25 Mar 2021 14:30:31 +0000 Subject: [PATCH] Rename Help to ModeInfo --- default-tiles/status-bar/src/first_line.rs | 2 +- default-tiles/status-bar/src/second_line.rs | 8 ++++---- src/common/input/handler.rs | 6 +++--- zellij-tile/src/data.rs | 4 ++-- zellij-tile/src/shim.rs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/default-tiles/status-bar/src/first_line.rs b/default-tiles/status-bar/src/first_line.rs index 00ff1543..20603df1 100644 --- a/default-tiles/status-bar/src/first_line.rs +++ b/default-tiles/status-bar/src/first_line.rs @@ -287,7 +287,7 @@ pub fn superkey() -> LinePart { } } -pub fn ctrl_keys(help: &Help, max_len: usize) -> LinePart { +pub fn ctrl_keys(help: &ModeInfo, max_len: usize) -> LinePart { match &help.mode { InputMode::Locked => key_indicators( max_len, diff --git a/default-tiles/status-bar/src/second_line.rs b/default-tiles/status-bar/src/second_line.rs index 743fba7f..322f4333 100644 --- a/default-tiles/status-bar/src/second_line.rs +++ b/default-tiles/status-bar/src/second_line.rs @@ -97,7 +97,7 @@ fn select_pane_shortcut(is_first_shortcut: bool) -> LinePart { } } -fn full_shortcut_list(help: &Help) -> LinePart { +fn full_shortcut_list(help: &ModeInfo) -> LinePart { match help.mode { InputMode::Normal => LinePart::default(), InputMode::Locked => locked_interface_indication(), @@ -116,7 +116,7 @@ fn full_shortcut_list(help: &Help) -> LinePart { } } -fn shortened_shortcut_list(help: &Help) -> LinePart { +fn shortened_shortcut_list(help: &ModeInfo) -> LinePart { match help.mode { InputMode::Normal => LinePart::default(), InputMode::Locked => locked_interface_indication(), @@ -135,7 +135,7 @@ fn shortened_shortcut_list(help: &Help) -> LinePart { } } -fn best_effort_shortcut_list(help: &Help, max_len: usize) -> LinePart { +fn best_effort_shortcut_list(help: &ModeInfo, max_len: usize) -> LinePart { match help.mode { InputMode::Normal => LinePart::default(), InputMode::Locked => { @@ -169,7 +169,7 @@ fn best_effort_shortcut_list(help: &Help, max_len: usize) -> LinePart { } } -pub fn keybinds(help: &Help, max_width: usize) -> LinePart { +pub fn keybinds(help: &ModeInfo, max_width: usize) -> LinePart { let full_shortcut_list = full_shortcut_list(help); if full_shortcut_list.len <= max_width { return full_shortcut_list; diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs index f48ec7c9..857ebb5a 100644 --- a/src/common/input/handler.rs +++ b/src/common/input/handler.rs @@ -11,7 +11,7 @@ use crate::wasm_vm::{NaughtyEventType, PluginInputType, PluginInstruction}; use crate::CommandIsExecuting; use termion::input::{TermRead, TermReadEventsAndRaw}; -use zellij_tile::data::{Help, InputMode, Key}; +use zellij_tile::data::{InputMode, Key, ModeInfo}; use super::keybinds::key_to_actions; @@ -273,7 +273,7 @@ impl InputHandler { /// 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 -pub fn get_help(mode: InputMode) -> Help { +pub fn get_help(mode: InputMode) -> ModeInfo { let mut keybinds: Vec<(String, String)> = vec![]; match mode { InputMode::Normal | InputMode::Locked => {} @@ -302,7 +302,7 @@ pub fn get_help(mode: InputMode) -> Help { keybinds.push(("Enter".to_string(), "when done".to_string())); } } - Help { mode, keybinds } + ModeInfo { mode, keybinds } } /// Entry point to the module. Instantiates an [`InputHandler`] and starts diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs index a6e07983..67bf0d74 100644 --- a/zellij-tile/src/data.rs +++ b/zellij-tile/src/data.rs @@ -27,7 +27,7 @@ pub enum Key { #[strum_discriminants(derive(EnumString, Hash, Serialize, Deserialize))] #[strum_discriminants(name(EventType))] pub enum Event { - ModeUpdate(Help), // FIXME: Rename the `Help` struct + ModeUpdate(ModeInfo), TabUpdate(TabInfo), KeyPress(Key), } @@ -62,7 +62,7 @@ impl Default for InputMode { /// 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 struct ModeInfo { pub mode: InputMode, // FIXME: This should probably return Keys and Actions, then sort out strings plugin-side pub keybinds: Vec<(String, String)>, // => diff --git a/zellij-tile/src/shim.rs b/zellij-tile/src/shim.rs index e0e65490..afb49f27 100644 --- a/zellij-tile/src/shim.rs +++ b/zellij-tile/src/shim.rs @@ -36,7 +36,7 @@ pub fn set_selectable(selectable: bool) { unsafe { host_set_selectable(selectable) }; } -pub fn get_help() -> Help { +pub fn get_help() -> ModeInfo { unsafe { host_get_help() }; deserialize_from_stdin().unwrap_or_default() }