summaryrefslogtreecommitdiffstats
path: root/zellij-utils
diff options
context:
space:
mode:
authorLovecraftian Horror <LovecraftianHorror@pm.me>2021-07-09 15:21:47 -0400
committerLovecraftian Horror <LovecraftianHorror@pm.me>2021-07-09 15:21:47 -0400
commiteb6e49c260be568800e76fd3276fc96ad909d4eb (patch)
tree0a6bab35187891f5a61c11acfd54ffea340af6ec /zellij-utils
parent4fcf558156dec6cfebd9fc6ba8605594369fded6 (diff)
Move `ModeInfo::new()` back to `get_mode_info()`
Diffstat (limited to 'zellij-utils')
-rw-r--r--zellij-utils/src/input/mod.rs47
1 files changed, 46 insertions, 1 deletions
diff --git a/zellij-utils/src/input/mod.rs b/zellij-utils/src/input/mod.rs
index e037fe662..746d58619 100644
--- a/zellij-utils/src/input/mod.rs
+++ b/zellij-utils/src/input/mod.rs
@@ -10,7 +10,52 @@ pub mod options;
pub mod theme;
use termion::input::TermRead;
-use zellij_tile::data::Key;
+use zellij_tile::data::{InputMode, Key, ModeInfo, Palette, PluginCapabilities};
+
+/// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds
+/// (as pairs of [`String`]s).
+pub fn get_mode_info(
+ mode: InputMode,
+ palette: Palette,
+ capabilities: PluginCapabilities,
+) -> ModeInfo {
+ let keybinds = match mode {
+ InputMode::Normal | InputMode::Locked => Vec::new(),
+ InputMode::Resize => vec![("←↓↑→".to_string(), "Resize".to_string())],
+ InputMode::Pane => vec![
+ ("←↓↑→".to_string(), "Move focus".to_string()),
+ ("p".to_string(), "Next".to_string()),
+ ("n".to_string(), "New".to_string()),
+ ("d".to_string(), "Down split".to_string()),
+ ("r".to_string(), "Right split".to_string()),
+ ("x".to_string(), "Close".to_string()),
+ ("f".to_string(), "Fullscreen".to_string()),
+ ],
+ InputMode::Tab => vec![
+ ("←↓↑→".to_string(), "Move focus".to_string()),
+ ("n".to_string(), "New".to_string()),
+ ("x".to_string(), "Close".to_string()),
+ ("r".to_string(), "Rename".to_string()),
+ ("s".to_string(), "Sync".to_string()),
+ ],
+ InputMode::Scroll => vec![
+ ("↓↑".to_string(), "Scroll".to_string()),
+ ("PgUp/PgDn".to_string(), "Scroll Page".to_string()),
+ ],
+ InputMode::RenameTab => vec![("Enter".to_string(), "when done".to_string())],
+ InputMode::Session => vec![("d".to_string(), "Detach".to_string())],
+ };
+
+ let session_name = std::env::var("ZELLIJ_SESSION_NAME").ok();
+
+ ModeInfo {
+ mode,
+ keybinds,
+ palette,
+ capabilities,
+ session_name,
+ }
+}
pub fn parse_keys(input_bytes: &[u8]) -> Vec<Key> {
input_bytes.keys().flatten().map(cast_termion_key).collect()