aboutsummaryrefslogtreecommitdiffstats
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
parentDisplay session name within session (diff)
downloadsl0ppij-eb6e49c260be568800e76fd3276fc96ad909d4eb.tar.gz
sl0ppij-eb6e49c260be568800e76fd3276fc96ad909d4eb.tar.xz
sl0ppij-eb6e49c260be568800e76fd3276fc96ad909d4eb.zip
Move `ModeInfo::new()` back to `get_mode_info()`
-rw-r--r--zellij-server/src/lib.rs5
-rw-r--r--zellij-server/src/route.rs7
-rw-r--r--zellij-server/src/screen.rs4
-rw-r--r--zellij-tile/src/data.rs43
-rw-r--r--zellij-utils/src/input/mod.rs47
5 files changed, 55 insertions, 51 deletions
diff --git a/zellij-server/src/lib.rs b/zellij-server/src/lib.rs
index a15eb4c9..660acdc9 100644
--- a/zellij-server/src/lib.rs
+++ b/zellij-server/src/lib.rs
@@ -15,7 +15,7 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex, RwLock};
use std::thread;
use wasmer::Store;
-use zellij_tile::data::{Event, ModeInfo, Palette, PluginCapabilities};
+use zellij_tile::data::{Event, Palette, PluginCapabilities};
use crate::{
os_input_output::ServerOsApi,
@@ -31,6 +31,7 @@ use zellij_utils::{
errors::{ContextType, ErrorInstruction, ServerContext},
input::{
command::{RunCommand, TerminalAction},
+ get_mode_info,
layout::Layout,
options::Options,
},
@@ -234,7 +235,7 @@ pub fn start_server(os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
.unwrap();
let default_mode = options.default_mode.unwrap_or_default();
let mode_info =
- ModeInfo::new(default_mode, attrs.palette, session_data.capabilities);
+ get_mode_info(default_mode, attrs.palette, session_data.capabilities);
session_data
.senders
.send_to_screen(ScreenInstruction::ChangeMode(mode_info.clone()))
diff --git a/zellij-server/src/route.rs b/zellij-server/src/route.rs
index 0796ac74..22d843f0 100644
--- a/zellij-server/src/route.rs
+++ b/zellij-server/src/route.rs
@@ -1,6 +1,6 @@
use std::sync::{Arc, RwLock};
-use zellij_utils::zellij_tile::data::{Event, ModeInfo};
+use zellij_utils::zellij_tile::data::Event;
use crate::{
os_input_output::ServerOsApi, pty::PtyInstruction, screen::ScreenInstruction,
@@ -11,6 +11,7 @@ use zellij_utils::{
input::{
actions::{Action, Direction},
command::TerminalAction,
+ get_mode_info,
},
ipc::{ClientToServerMsg, ExitReason, ServerToClientMsg},
};
@@ -42,12 +43,12 @@ fn route_action(
.senders
.send_to_plugin(PluginInstruction::Update(
None,
- Event::ModeUpdate(ModeInfo::new(mode, palette, session.capabilities)),
+ Event::ModeUpdate(get_mode_info(mode, palette, session.capabilities)),
))
.unwrap();
session
.senders
- .send_to_screen(ScreenInstruction::ChangeMode(ModeInfo::new(
+ .send_to_screen(ScreenInstruction::ChangeMode(get_mode_info(
mode,
palette,
session.capabilities,
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 9f5435de..9400599c 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -18,7 +18,7 @@ use crate::{
use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PluginCapabilities, TabInfo};
use zellij_utils::{
errors::{ContextType, ScreenContext},
- input::options::Options,
+ input::{get_mode_info, options::Options},
ipc::ClientAttributes,
pane_size::PositionAndSize,
};
@@ -434,7 +434,7 @@ pub(crate) fn screen_thread_main(
bus,
&client_attributes,
max_panes,
- ModeInfo::new(
+ get_mode_info(
default_mode,
client_attributes.palette,
PluginCapabilities {
diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs
index 48ef4df9..cdf57e69 100644
--- a/zellij-tile/src/data.rs
+++ b/zellij-tile/src/data.rs
@@ -151,49 +151,6 @@ pub struct ModeInfo {
pub session_name: Option<String>,
}
-impl ModeInfo {
- /// Creates a [`ModeInfo`] struct indicating the current [`InputMode`] and its keybinds
- /// (as pairs of [`String`]s).
- pub fn new(mode: InputMode, palette: Palette, capabilities: PluginCapabilities) -> Self {
- 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();
-
- Self {
- mode,
- keybinds,
- palette,
- capabilities,
- session_name,
- }
- }
-}
-
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
pub struct TabInfo {
/* subset of fields to publish to plugins */
diff --git a/zellij-utils/src/input/mod.rs b/zellij-utils/src/input/mod.rs
index e037fe66..746d5861 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()