From 67ee63548aa48caebf32b081d57cb8184bff39b8 Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Fri, 9 Jul 2021 00:25:59 +0530 Subject: [PATCH 01/18] Add on_force_close config option --- zellij-client/src/lib.rs | 4 ++- zellij-utils/assets/config/default.yaml | 7 ++++++ zellij-utils/src/input/actions.rs | 10 ++++++++ zellij-utils/src/input/options.rs | 33 +++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/zellij-client/src/lib.rs b/zellij-client/src/lib.rs index 90732024d..2bfaae2e8 100644 --- a/zellij-client/src/lib.rs +++ b/zellij-client/src/lib.rs @@ -164,6 +164,8 @@ pub fn start_client( }) }); + let on_force_close = config_options.on_force_close.unwrap_or_default(); + let _stdin_thread = thread::Builder::new() .name("stdin_handler".to_string()) .spawn({ @@ -200,7 +202,7 @@ pub fn start_client( Box::new({ let os_api = os_input.clone(); move || { - os_api.send_to_server(ClientToServerMsg::Action(Action::Detach)); + os_api.send_to_server(ClientToServerMsg::Action(on_force_close.into())); } }), ); diff --git a/zellij-utils/assets/config/default.yaml b/zellij-utils/assets/config/default.yaml index 42bc16886..9b0a57ffa 100644 --- a/zellij-utils/assets/config/default.yaml +++ b/zellij-utils/assets/config/default.yaml @@ -240,3 +240,10 @@ keybinds: key: [Ctrl: 'q',] - action: [Detach,] key: [Char: 'd',] + +# Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP +# eg. when terminal window with an active zellij session is closed +# Options: +# - Detach (Default) +# - Quit +#on_force_close: Quit diff --git a/zellij-utils/src/input/actions.rs b/zellij-utils/src/input/actions.rs index ecd515a4a..bfd7d2559 100644 --- a/zellij-utils/src/input/actions.rs +++ b/zellij-utils/src/input/actions.rs @@ -1,6 +1,7 @@ //! Definition of the actions that can be bound to keys. use super::command::RunCommandAction; +use crate::input::options::OnForceClose; use serde::{Deserialize, Serialize}; use zellij_tile::data::InputMode; @@ -81,3 +82,12 @@ pub enum Action { MouseHold(Position), Copy, } + +impl From for Action { + fn from(ofc: OnForceClose) -> Action { + match ofc { + OnForceClose::Quit => Action::Quit, + OnForceClose::Detach => Action::Detach, + } + } +} diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 2ba2be86e..c2083f4e1 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -2,9 +2,34 @@ use crate::cli::Command; use serde::{Deserialize, Serialize}; use std::path::PathBuf; +use std::str::FromStr; use structopt::StructOpt; use zellij_tile::data::InputMode; +#[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)] +pub enum OnForceClose { + Quit, + Detach, +} + +impl Default for OnForceClose { + fn default() -> Self { + Self::Detach + } +} + +impl FromStr for OnForceClose { + type Err = Box; + + fn from_str(s: &str) -> Result { + match s { + "quit" => Ok(Self::Quit), + "detach" => Ok(Self::Detach), + e => Err(e.to_string().into()), + } + } +} + #[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)] /// Options that can be set either through the config file, /// or cli flags @@ -30,6 +55,8 @@ pub struct Options { #[structopt(long)] #[serde(default)] pub disable_mouse_mode: bool, + #[structopt(long)] + pub on_force_close: Option, } impl Options { @@ -77,6 +104,11 @@ impl Options { self.disable_mouse_mode }; + let on_force_close = match other.on_force_close { + None => self.on_force_close, + other => other, + }; + Options { simplified_ui, theme, @@ -84,6 +116,7 @@ impl Options { default_shell, layout_dir, disable_mouse_mode, + on_force_close, } } From 56af1d8640a8ae72b9f82146abb5c9381411b6e4 Mon Sep 17 00:00:00 2001 From: Kunal Mohan Date: Fri, 9 Jul 2021 00:42:06 +0530 Subject: [PATCH 02/18] Add doc comment for the on_force_close option --- zellij-utils/src/input/options.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index c2083f4e1..461f5c341 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -55,6 +55,7 @@ pub struct Options { #[structopt(long)] #[serde(default)] pub disable_mouse_mode: bool, + /// Set behaviour on force close (quit or detach) #[structopt(long)] pub on_force_close: Option, } From 337674b0736f275c579f3355aa12c8900ccccfe9 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 11:55:33 +0200 Subject: [PATCH 03/18] Improve clarity of precedence in options --- zellij-utils/src/input/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 461f5c341..cdb61a857 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -32,7 +32,7 @@ impl FromStr for OnForceClose { #[derive(Clone, Default, Debug, PartialEq, Deserialize, Serialize, StructOpt)] /// Options that can be set either through the config file, -/// or cli flags +/// or cli flags - cli flags should take precedence over the config file pub struct Options { /// Allow plugins to use a more simplified layout /// that is compatible with more fonts From 6299660d5caf294d10ddaf5c6df44ee14889a5f7 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 11:57:52 +0200 Subject: [PATCH 04/18] Add doc-comment for mouse-mode --- zellij-utils/src/input/options.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index cdb61a857..c2f2ba557 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -54,6 +54,7 @@ pub struct Options { pub layout_dir: Option, #[structopt(long)] #[serde(default)] + /// Disable handling of mouse events pub disable_mouse_mode: bool, /// Set behaviour on force close (quit or detach) #[structopt(long)] From 89f84ecd3f1a1573d0f3d8e0c46426d162f2b2e4 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 13:09:05 +0200 Subject: [PATCH 05/18] Simplify merging of options --- zellij-utils/src/input/options.rs | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index c2f2ba557..714e6524b 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -74,42 +74,16 @@ impl Options { /// will supercede a `Some` in `self` // TODO: Maybe a good candidate for a macro? pub fn merge(&self, other: Options) -> Options { - let simplified_ui = if other.simplified_ui { - true - } else { - self.simplified_ui - }; + let merge_bool = |opt_other, opt_self| if opt_other { true } else { opt_self }; - let default_mode = match other.default_mode { - None => self.default_mode, - other => other, - }; + let simplified_ui = merge_bool(other.simplified_ui, self.simplified_ui); + let disable_mouse_mode = merge_bool(other.disable_mouse_mode, self.disable_mouse_mode); - let default_shell = match other.default_shell { - None => self.default_shell.clone(), - other => other, - }; - - let layout_dir = match other.layout_dir { - None => self.layout_dir.clone(), - other => other, - }; - - let theme = match other.theme { - None => self.theme.clone(), - other => other, - }; - - let disable_mouse_mode = if other.disable_mouse_mode { - true - } else { - self.disable_mouse_mode - }; - - let on_force_close = match other.on_force_close { - None => self.on_force_close, - other => other, - }; + let default_mode = other.default_mode.or(self.default_mode); + let default_shell = other.default_shell.or_else(|| self.default_shell.clone()); + let layout_dir = other.layout_dir.or_else(|| self.layout_dir.clone()); + let theme = other.theme.or_else(|| self.theme.clone()); + let on_force_close = other.on_force_close.or(self.on_force_close); Options { simplified_ui, From cf8d5a7a4d7ad6bc350292b3fa1f583d04b21e6c Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 13:11:02 +0200 Subject: [PATCH 06/18] Use lowercase for options --- zellij-utils/assets/config/default.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zellij-utils/assets/config/default.yaml b/zellij-utils/assets/config/default.yaml index 9b0a57ffa..d9090a8dc 100644 --- a/zellij-utils/assets/config/default.yaml +++ b/zellij-utils/assets/config/default.yaml @@ -244,6 +244,6 @@ keybinds: # Choose what to do when zellij receives SIGTERM, SIGINT, SIGQUIT or SIGHUP # eg. when terminal window with an active zellij session is closed # Options: -# - Detach (Default) -# - Quit -#on_force_close: Quit +# - detach (Default) +# - quit +#on_force_close: quit From 8363705939dd35d25832db0b536b250d29d924a1 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 15:01:05 +0200 Subject: [PATCH 07/18] Add serde-alias for on_force_close * It doesn't deserialize from the configuration otherwise, if specified in lower-case. Alternative: use a rename. --- zellij-utils/src/input/options.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zellij-utils/src/input/options.rs b/zellij-utils/src/input/options.rs index 714e6524b..a2f9231cd 100644 --- a/zellij-utils/src/input/options.rs +++ b/zellij-utils/src/input/options.rs @@ -8,7 +8,9 @@ use zellij_tile::data::InputMode; #[derive(Copy, Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum OnForceClose { + #[serde(alias = "quit")] Quit, + #[serde(alias = "detach")] Detach, } From 261e691f9f966d250c15f27969327753cf6ce59a Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 2 Jul 2021 18:44:36 +0200 Subject: [PATCH 08/18] Add commands to layout Add the ability to run commands on loading a layout: ``` - direction: Horizontal split_size: Percent: 50 run: command: {cmd: htop} ``` or respectively: ``` - direction: Horizontal split_size: Percent: 50 run: command: {cmd: htop, args: ["-C"]} ``` In order to specify the difference of commands and plugins now the plugins need to be under the `run` section: ``` - direction: Vertical split_size: Fixed: 2 run: plugin: status-bar ``` This also means that this is a breaking change for people that already have a custom layout. Example layouts: ``` --- direction: Vertical parts: - direction: Horizontal split_size: Percent: 50 parts: - direction: Vertical split_size: Percent: 50 - direction: Vertical split_size: Percent: 50 run: command: {cmd: htop} - direction: Horizontal split_size: Percent: 50 run: command: {cmd: htop} ``` and: ``` --- direction: Horizontal parts: - direction: Vertical split_size: Fixed: 1 run: plugin: tab-bar - direction: Vertical parts: - direction: Vertical parts: - direction: Vertical split_size: Percent: 50 run: command: {cmd: htop} - direction: Vertical split_size: Percent: 50 run: command: {cmd: htop, args: ["-C"]} - direction: Vertical split_size: Fixed: 5 - direction: Vertical split_size: Fixed: 2 run: plugin: status-bar ``` closes #551, closes #284 --- example/run_htop_layout.yaml | 20 ++++++ example/run_htop_layout_with_plugins.yaml | 30 +++++++++ zellij-server/src/pty.rs | 62 +++++++++++++------ zellij-server/src/tab.rs | 7 ++- zellij-utils/assets/layouts/default.yaml | 6 +- .../assets/layouts/disable-status-bar.yaml | 3 +- zellij-utils/assets/layouts/strider.yaml | 9 ++- zellij-utils/src/input/command.rs | 1 + zellij-utils/src/input/layout.rs | 36 +++++++++-- 9 files changed, 142 insertions(+), 32 deletions(-) create mode 100644 example/run_htop_layout.yaml create mode 100644 example/run_htop_layout_with_plugins.yaml diff --git a/example/run_htop_layout.yaml b/example/run_htop_layout.yaml new file mode 100644 index 000000000..949435d69 --- /dev/null +++ b/example/run_htop_layout.yaml @@ -0,0 +1,20 @@ +--- +direction: Vertical +parts: + - direction: Horizontal + split_size: + Percent: 50 + parts: + - direction: Vertical + split_size: + Percent: 50 + - direction: Vertical + split_size: + Percent: 50 + run: + command: {cmd: htop} + - direction: Horizontal + split_size: + Percent: 50 + run: + command: {cmd: htop} diff --git a/example/run_htop_layout_with_plugins.yaml b/example/run_htop_layout_with_plugins.yaml new file mode 100644 index 000000000..99f72edbe --- /dev/null +++ b/example/run_htop_layout_with_plugins.yaml @@ -0,0 +1,30 @@ +--- +direction: Horizontal +parts: + - direction: Vertical + split_size: + Fixed: 1 + run: + plugin: tab-bar + - direction: Vertical + parts: + - direction: Vertical + parts: + - direction: Vertical + split_size: + Percent: 50 + run: + command: {cmd: htop} + - direction: Vertical + split_size: + Percent: 50 + run: + command: {cmd: htop, args: ["-C"]} + - direction: Vertical + split_size: + Fixed: 5 + - direction: Vertical + split_size: + Fixed: 2 + run: + plugin: status-bar diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs index 0dba3611b..dd1ff3f57 100644 --- a/zellij-server/src/pty.rs +++ b/zellij-server/src/pty.rs @@ -1,11 +1,3 @@ -use zellij_utils::async_std; - -use async_std::future::timeout as async_timeout; -use async_std::task::{self, JoinHandle}; -use std::collections::HashMap; -use std::os::unix::io::RawFd; -use std::time::{Duration, Instant}; - use crate::{ os_input_output::{AsyncReader, Pid, ServerOsApi}, panes::PaneId, @@ -14,9 +6,22 @@ use crate::{ wasm_vm::PluginInstruction, ServerInstruction, }; +use async_std::{ + future::timeout as async_timeout, + task::{self, JoinHandle}, +}; +use std::{ + collections::HashMap, + os::unix::io::RawFd, + time::{Duration, Instant}, +}; use zellij_utils::{ + async_std, errors::{get_current_ctx, ContextType, PtyContext}, - input::{command::TerminalAction, layout::Layout}, + input::{ + command::TerminalAction, + layout::{Layout, Run}, + }, logging::debug_to_file, }; @@ -237,19 +242,36 @@ impl Pty { pub fn spawn_terminals_for_layout( &mut self, layout: Layout, - terminal_action: Option, + default_shell: Option, ) { - let total_panes = layout.total_terminal_panes(); + let extracted_run_instructions = layout.extract_run_instructions(); let mut new_pane_pids = vec![]; - for _ in 0..total_panes { - let (pid_primary, pid_secondary): (RawFd, Pid) = self - .bus - .os_input - .as_mut() - .unwrap() - .spawn_terminal(terminal_action.clone()); - self.id_to_child_pid.insert(pid_primary, pid_secondary); - new_pane_pids.push(pid_primary); + for run_instruction in extracted_run_instructions { + match run_instruction { + Some(Run::Command(command)) => { + let cmd = TerminalAction::RunCommand(command); + let (pid_primary, pid_secondary): (RawFd, Pid) = self + .bus + .os_input + .as_mut() + .unwrap() + .spawn_terminal(Some(cmd)); + self.id_to_child_pid.insert(pid_primary, pid_secondary); + new_pane_pids.push(pid_primary); + } + None => { + let (pid_primary, pid_secondary): (RawFd, Pid) = self + .bus + .os_input + .as_mut() + .unwrap() + .spawn_terminal(default_shell.clone()); + self.id_to_child_pid.insert(pid_primary, pid_secondary); + new_pane_pids.push(pid_primary); + } + // Investigate moving plugin loading to here. + Some(Run::Plugin(_)) => {} + } } self.bus .senders diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs index 523f65df2..ff0744590 100644 --- a/zellij-server/src/tab.rs +++ b/zellij-server/src/tab.rs @@ -26,7 +26,10 @@ use std::{ }; use zellij_tile::data::{Event, InputMode, ModeInfo, Palette}; use zellij_utils::{ - input::{layout::Layout, parse_keys}, + input::{ + layout::{Layout, Run}, + parse_keys, + }, pane_size::PositionAndSize, shared::adjust_to_size, }; @@ -319,7 +322,7 @@ impl Tab { let mut new_pids = new_pids.iter(); for (layout, position_and_size) in positions_and_size { // A plugin pane - if let Some(plugin) = &layout.plugin { + if let Some(Run::Plugin(Some(plugin))) = &layout.run { let (pid_tx, pid_rx) = channel(); self.senders .send_to_plugin(PluginInstruction::Load(pid_tx, plugin.clone())) diff --git a/zellij-utils/assets/layouts/default.yaml b/zellij-utils/assets/layouts/default.yaml index 9be7af2a7..96bf1809c 100644 --- a/zellij-utils/assets/layouts/default.yaml +++ b/zellij-utils/assets/layouts/default.yaml @@ -4,9 +4,11 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical - direction: Vertical split_size: Fixed: 2 - plugin: status-bar + run: + plugin: status-bar diff --git a/zellij-utils/assets/layouts/disable-status-bar.yaml b/zellij-utils/assets/layouts/disable-status-bar.yaml index fd9c97da6..b990ba500 100644 --- a/zellij-utils/assets/layouts/disable-status-bar.yaml +++ b/zellij-utils/assets/layouts/disable-status-bar.yaml @@ -4,5 +4,6 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical diff --git a/zellij-utils/assets/layouts/strider.yaml b/zellij-utils/assets/layouts/strider.yaml index 5dc9b08f9..9bbe5772f 100644 --- a/zellij-utils/assets/layouts/strider.yaml +++ b/zellij-utils/assets/layouts/strider.yaml @@ -4,15 +4,18 @@ parts: - direction: Vertical split_size: Fixed: 1 - plugin: tab-bar + run: + plugin: tab-bar - direction: Vertical parts: - direction: Horizontal split_size: Percent: 20 - plugin: strider + run: + plugin: strider - direction: Horizontal - direction: Vertical split_size: Fixed: 2 - plugin: status-bar + run: + plugin: status-bar diff --git a/zellij-utils/src/input/command.rs b/zellij-utils/src/input/command.rs index ca505ea2d..7916e5cfa 100644 --- a/zellij-utils/src/input/command.rs +++ b/zellij-utils/src/input/command.rs @@ -11,6 +11,7 @@ pub enum TerminalAction { #[derive(Clone, Debug, Deserialize, Default, Serialize, PartialEq, Eq)] pub struct RunCommand { + #[serde(alias = "cmd")] pub command: PathBuf, #[serde(default)] pub args: Vec, diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 16309db1d..a48c35219 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -8,7 +8,11 @@ // place. // If plugins should be able to depend on the layout system // then [`zellij-utils`] could be a proper place. -use crate::{input::config::ConfigError, pane_size::PositionAndSize, setup}; +use crate::{ + input::{command::RunCommand, config::ConfigError}, + pane_size::PositionAndSize, + setup, +}; use crate::{serde, serde_yaml}; use serde::{Deserialize, Serialize}; @@ -29,6 +33,15 @@ pub enum SplitSize { Fixed(u16), // An absolute number of columns or rows } +#[derive(Debug, Serialize, Deserialize, Clone)] +#[serde(crate = "self::serde")] +pub enum Run { + #[serde(rename = "plugin")] + Plugin(Option), + #[serde(rename = "command")] + Command(RunCommand), +} + #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(crate = "self::serde")] pub struct Layout { @@ -36,7 +49,7 @@ pub struct Layout { #[serde(default)] pub parts: Vec, pub split_size: Option, - pub plugin: Option, + pub run: Option, } type LayoutResult = Result; @@ -127,13 +140,28 @@ impl Layout { let mut total_panes = 0; total_panes += self.parts.len(); for part in self.parts.iter() { - if part.plugin.is_none() { - total_panes += part.total_terminal_panes(); + match part.run { + Some(Run::Command(_)) | None => { + total_panes += part.total_terminal_panes(); + } + Some(Run::Plugin(_)) => {} } } total_panes } + pub fn extract_run_instructions(&self) -> Vec> { + let mut run_instructions = vec![]; + if self.parts.is_empty() { + run_instructions.push(self.run.clone()); + } + for part in self.parts.iter() { + let mut current_runnables = part.extract_run_instructions(); + run_instructions.append(&mut current_runnables); + } + run_instructions + } + pub fn position_panes_in_space( &self, space: &PositionAndSize, From f755ef23d97f495231e22ddaa364772da32f648f Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 17:08:01 +0200 Subject: [PATCH 09/18] docs(changelog): Add commands to layout #600 --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c5367fd1..d14e222ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] * Kill children properly (https://github.com/zellij-org/zellij/pull/601) * Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602) +* Add running commands to `layouts` (https://github.com/zellij-org/zellij/pull/600) + POSSIBLE BREAKING CHANGE for custom layouts: + Plugins are under the run category now, that means: + ``` + plugin: status-bar + ``` + is now: + ``` + run: + plugin: status-bar + ``` + ## [0.14.0] - 2021-07-05 * Add improved error handling for layouts (https://github.com/zellij-org/zellij/pull/576) From 910c3d4291b3546f84175c4dd48ce6826b8bc368 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 17:29:37 +0200 Subject: [PATCH 10/18] docs(changelog): Add `on_force_close` #609 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d14e222ff..c836ce6e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) run: plugin: status-bar ``` + * Add `on_force_close` config option (https://github.com/zellij-org/zellij/pull/609) ## [0.14.0] - 2021-07-05 From be1cb626eefb9b7efb8be781eb27858c81c274e6 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 17:47:21 +0200 Subject: [PATCH 11/18] Fix formatting of markdown --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c836ce6e0..16675074c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * Kill children properly (https://github.com/zellij-org/zellij/pull/601) * Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602) * Add running commands to `layouts` (https://github.com/zellij-org/zellij/pull/600) + POSSIBLE BREAKING CHANGE for custom layouts: Plugins are under the run category now, that means: ``` From 3df0210647e65170576f1ea97328cce26c211a43 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 9 Jul 2021 17:49:36 +0200 Subject: [PATCH 12/18] Fix formating of markdown --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16675074c..b665fa446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) run: plugin: status-bar ``` - * Add `on_force_close` config option (https://github.com/zellij-org/zellij/pull/609) +* Add `on_force_close` config option (https://github.com/zellij-org/zellij/pull/609) ## [0.14.0] - 2021-07-05 From d097c521acda376899949083f38c857fa30b47d6 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Mon, 19 Jul 2021 20:27:58 +0100 Subject: [PATCH 13/18] chore(release): v0.15.0 --- Makefile.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.toml b/Makefile.toml index c58ce3d0d..e0043ab71 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -151,7 +151,7 @@ run_task = "publish-zellij" [tasks.release-commit] dependencies = ["commit-all", "tag-release"] command = "git" -args = ["push", "--atomic", "upstream", "main", "v${CARGO_MAKE_CRATE_VERSION}"] +args = ["push", "--atomic", "origin", "main", "v${CARGO_MAKE_CRATE_VERSION}"] [tasks.commit-all] ignore_errors = true From 6a90542ae38ca46c84c0b3c721a2a6b231347359 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Mon, 19 Jul 2021 20:35:50 +0100 Subject: [PATCH 14/18] chore(release): bump development version --- Cargo.toml | 8 ++++---- zellij-client/Cargo.toml | 4 ++-- zellij-server/Cargo.toml | 4 ++-- zellij-tile-utils/Cargo.toml | 2 +- zellij-tile/Cargo.toml | 2 +- zellij-utils/Cargo.toml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f5f221e94..9a487176a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij" -version = "0.15.0" +version = "0.16.0" authors = ["Aram Drevekenin "] edition = "2018" description = "A terminal workspace with batteries included" @@ -14,9 +14,9 @@ resolver = "2" [dependencies] names = "0.11.0" -zellij-client = { path = "zellij-client/", version = "0.15.0" } -zellij-server = { path = "zellij-server/", version = "0.15.0" } -zellij-utils = { path = "zellij-utils/", version = "0.15.0" } +zellij-client = { path = "zellij-client/", version = "0.16.0" } +zellij-server = { path = "zellij-server/", version = "0.16.0" } +zellij-utils = { path = "zellij-utils/", version = "0.16.0" } [dev-dependencies] insta = { version = "1.6.0", features = ["backtrace"] } diff --git a/zellij-client/Cargo.toml b/zellij-client/Cargo.toml index 5a2e314a3..f0d67435d 100644 --- a/zellij-client/Cargo.toml +++ b/zellij-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij-client" -version = "0.15.0" +version = "0.16.0" authors = ["Kunal Mohan "] edition = "2018" description = "The client-side library for Zellij" @@ -11,7 +11,7 @@ license = "MIT" [dependencies] mio = "0.7.11" termbg = "0.2.3" -zellij-utils = { path = "../zellij-utils/", version = "0.15.0" } +zellij-utils = { path = "../zellij-utils/", version = "0.16.0" } [dev-dependencies] insta = "1.6.0" diff --git a/zellij-server/Cargo.toml b/zellij-server/Cargo.toml index beefb82da..f6c8fcbe7 100644 --- a/zellij-server/Cargo.toml +++ b/zellij-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij-server" -version = "0.15.0" +version = "0.16.0" authors = ["Kunal Mohan "] edition = "2018" description = "The server-side library for Zellij" @@ -18,7 +18,7 @@ unicode-width = "0.1.8" wasmer = "1.0.0" wasmer-wasi = "1.0.0" cassowary = "0.3.0" -zellij-utils = { path = "../zellij-utils/", version = "0.15.0" } +zellij-utils = { path = "../zellij-utils/", version = "0.16.0" } [dev-dependencies] insta = "1.6.0" diff --git a/zellij-tile-utils/Cargo.toml b/zellij-tile-utils/Cargo.toml index 9c8865a97..d1e7d2330 100644 --- a/zellij-tile-utils/Cargo.toml +++ b/zellij-tile-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij-tile-utils" -version = "0.15.0" +version = "0.16.0" authors = ["denis "] edition = "2018" description = "A utility library for Zellij plugins" diff --git a/zellij-tile/Cargo.toml b/zellij-tile/Cargo.toml index b0c18ff29..90be3e084 100644 --- a/zellij-tile/Cargo.toml +++ b/zellij-tile/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij-tile" -version = "0.15.0" +version = "0.16.0" authors = ["Brooks J Rady "] edition = "2018" description = "A small client-side library for writing Zellij plugins" diff --git a/zellij-utils/Cargo.toml b/zellij-utils/Cargo.toml index 6b530ee96..3365db091 100644 --- a/zellij-utils/Cargo.toml +++ b/zellij-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zellij-utils" -version = "0.15.0" +version = "0.16.0" authors = ["Kunal Mohan "] edition = "2018" description = "A utility library for Zellij client and server" @@ -27,7 +27,7 @@ structopt = "0.3" strum = "0.20.0" termion = "1.5.0" vte = "0.10.1" -zellij-tile = { path = "../zellij-tile/", version = "0.15.0" } +zellij-tile = { path = "../zellij-tile/", version = "0.16.0" } [dependencies.async-std] version = "1.3.0" From 7de19dc6dfd6c847370f354649178e68f0181fd4 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Mon, 19 Jul 2021 20:49:23 +0100 Subject: [PATCH 15/18] fix(style): bury the dead (code) --- Cargo.lock | 12 ++++++------ zellij-server/src/screen.rs | 10 +--------- zellij-server/src/tab.rs | 6 +----- zellij-server/src/unit/screen_tests.rs | 12 ++---------- zellij-server/src/unit/tab_tests.rs | 4 +--- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52967fbb8..d88bcec87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2447,7 +2447,7 @@ dependencies = [ [[package]] name = "zellij" -version = "0.15.0" +version = "0.16.0" dependencies = [ "insta", "names", @@ -2460,7 +2460,7 @@ dependencies = [ [[package]] name = "zellij-client" -version = "0.15.0" +version = "0.16.0" dependencies = [ "insta", "mio", @@ -2470,7 +2470,7 @@ dependencies = [ [[package]] name = "zellij-server" -version = "0.15.0" +version = "0.16.0" dependencies = [ "ansi_term 0.12.1", "async-trait", @@ -2487,7 +2487,7 @@ dependencies = [ [[package]] name = "zellij-tile" -version = "0.15.0" +version = "0.16.0" dependencies = [ "serde", "serde_json", @@ -2497,14 +2497,14 @@ dependencies = [ [[package]] name = "zellij-tile-utils" -version = "0.15.0" +version = "0.16.0" dependencies = [ "ansi_term 0.12.1", ] [[package]] name = "zellij-utils" -version = "0.15.0" +version = "0.16.0" dependencies = [ "async-std", "backtrace", diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index 9005d7957..c96c13455 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -15,7 +15,7 @@ use crate::{ wasm_vm::PluginInstruction, ServerInstruction, SessionState, }; -use zellij_tile::data::{Event, InputMode, ModeInfo, Palette, PluginCapabilities, TabInfo}; +use zellij_tile::data::{Event, ModeInfo, Palette, PluginCapabilities, TabInfo}; use zellij_utils::{ errors::{ContextType, ScreenContext}, input::options::Options, @@ -149,7 +149,6 @@ pub(crate) struct Screen { /// The index of this [`Screen`]'s active [`Tab`]. active_tab_index: Option, mode_info: ModeInfo, - input_mode: InputMode, colors: Palette, session_state: Arc>, } @@ -161,7 +160,6 @@ impl Screen { client_attributes: &ClientAttributes, max_panes: Option, mode_info: ModeInfo, - input_mode: InputMode, session_state: Arc>, ) -> Self { Screen { @@ -172,7 +170,6 @@ impl Screen { active_tab_index: None, tabs: BTreeMap::new(), mode_info, - input_mode, session_state, } } @@ -192,7 +189,6 @@ impl Screen { self.max_panes, Some(PaneId::Terminal(pane_id)), self.mode_info.clone(), - self.input_mode, self.colors, self.session_state.clone(), ); @@ -354,7 +350,6 @@ impl Screen { self.max_panes, None, self.mode_info.clone(), - self.input_mode, self.colors, self.session_state.clone(), ); @@ -428,7 +423,6 @@ pub(crate) fn screen_thread_main( session_state: Arc>, ) { let capabilities = config_options.simplified_ui; - let default_mode = config_options.default_mode.unwrap_or_default(); let mut screen = Screen::new( bus, @@ -439,10 +433,8 @@ pub(crate) fn screen_thread_main( capabilities: PluginCapabilities { arrow_fonts: capabilities, }, - mode: default_mode, ..ModeInfo::default() }, - default_mode, session_state, ); loop { diff --git a/zellij-server/src/tab.rs b/zellij-server/src/tab.rs index 686a1c20a..f3b30fe3a 100644 --- a/zellij-server/src/tab.rs +++ b/zellij-server/src/tab.rs @@ -24,7 +24,7 @@ use std::{ cmp::Reverse, collections::{BTreeMap, HashSet}, }; -use zellij_tile::data::{Event, InputMode, ModeInfo, Palette}; +use zellij_tile::data::{Event, ModeInfo, Palette}; use zellij_utils::{ input::{ layout::{Layout, Run}, @@ -87,7 +87,6 @@ pub(crate) struct Tab { should_clear_display_before_rendering: bool, session_state: Arc>, pub mode_info: ModeInfo, - pub input_mode: InputMode, pub colors: Palette, } @@ -99,7 +98,6 @@ pub(crate) struct TabData { pub name: String, pub active: bool, pub mode_info: ModeInfo, - pub input_mode: InputMode, pub colors: Palette, } @@ -260,7 +258,6 @@ impl Tab { max_panes: Option, pane_id: Option, mode_info: ModeInfo, - input_mode: InputMode, colors: Palette, session_state: Arc>, ) -> Self { @@ -299,7 +296,6 @@ impl Tab { senders, should_clear_display_before_rendering: false, mode_info, - input_mode, colors, session_state, } diff --git a/zellij-server/src/unit/screen_tests.rs b/zellij-server/src/unit/screen_tests.rs index 173e2ccc0..df159dde0 100644 --- a/zellij-server/src/unit/screen_tests.rs +++ b/zellij-server/src/unit/screen_tests.rs @@ -1,5 +1,5 @@ use super::{Screen, ScreenInstruction}; -use crate::zellij_tile::data::{InputMode, ModeInfo, Palette}; +use crate::zellij_tile::data::{ModeInfo, Palette}; use crate::{ os_input_output::{AsyncReader, Pid, ServerOsApi}, thread_bus::Bus, @@ -81,16 +81,8 @@ fn create_new_screen(position_and_size: PositionAndSize) -> Screen { client_attributes.position_and_size = position_and_size; let max_panes = None; let mode_info = ModeInfo::default(); - let input_mode = InputMode::Normal; let session_state = Arc::new(RwLock::new(SessionState::Attached)); - Screen::new( - bus, - &client_attributes, - max_panes, - mode_info, - input_mode, - session_state, - ) + Screen::new(bus, &client_attributes, max_panes, mode_info, session_state) } #[test] diff --git a/zellij-server/src/unit/tab_tests.rs b/zellij-server/src/unit/tab_tests.rs index c19c41ceb..cc08a5b16 100644 --- a/zellij-server/src/unit/tab_tests.rs +++ b/zellij-server/src/unit/tab_tests.rs @@ -1,5 +1,5 @@ use super::Tab; -use crate::zellij_tile::data::{InputMode, ModeInfo, Palette}; +use crate::zellij_tile::data::{ModeInfo, Palette}; use crate::{ os_input_output::{AsyncReader, Pid, ServerOsApi}, panes::PaneId, @@ -82,7 +82,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab { let max_panes = None; let first_pane_id = Some(PaneId::Terminal(1)); let mode_info = ModeInfo::default(); - let input_mode = InputMode::Normal; let colors = Palette::default(); let session_state = Arc::new(RwLock::new(SessionState::Attached)); Tab::new( @@ -95,7 +94,6 @@ fn create_new_tab(position_and_size: PositionAndSize) -> Tab { max_panes, first_pane_id, mode_info, - input_mode, colors, session_state, ) From 55bc1feee1a1239c36f5d8591a9a275df44f4b88 Mon Sep 17 00:00:00 2001 From: Brooks J Rady Date: Mon, 19 Jul 2021 20:50:01 +0100 Subject: [PATCH 16/18] chore(release): rotate changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b665fa446..5ce2d371a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] + + +## [0.15.0] - 2021-07-19 * Kill children properly (https://github.com/zellij-org/zellij/pull/601) * Change name of `Run` binding for actions (https://github.com/zellij-org/zellij/pull/602) * Add running commands to `layouts` (https://github.com/zellij-org/zellij/pull/600) From 697ba09c71407f1cf430dfb59292fb7b6ee3b182 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 20 Jul 2021 15:08:38 +0200 Subject: [PATCH 17/18] Add noop for mouse actions on plugins * Comments the `unimplemented!` macro out, in favor of a noop The macro is still there for easy greppability. It is still unimplemented, but zellij doesn't need to panic once a plugin does get a scroll event. --- zellij-server/src/panes/plugin_pane.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zellij-server/src/panes/plugin_pane.rs b/zellij-server/src/panes/plugin_pane.rs index c01c7b873..256ceaea1 100644 --- a/zellij-server/src/panes/plugin_pane.rs +++ b/zellij-server/src/panes/plugin_pane.rs @@ -196,13 +196,13 @@ impl Pane for PluginPane { self.position_and_size.y -= count; } fn scroll_up(&mut self, _count: usize) { - unimplemented!() + //unimplemented!() } fn scroll_down(&mut self, _count: usize) { - unimplemented!() + //unimplemented!() } fn clear_scroll(&mut self) { - unimplemented!() + //unimplemented!() } // FIXME: This need to be reevaluated and deleted if possible. // `max` doesn't make sense when things are fixed... From 105ae616829da277481b82fb9610062bea22f985 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 20 Jul 2021 16:27:32 +0200 Subject: [PATCH 18/18] docs(changelog): noop for mouse actions on plugins --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce2d371a..9fa68e518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] +* Plugins don't crash zellij anymore on receiving mouse events (https://github.com/zellij-org/zellij/pull/620) ## [0.15.0] - 2021-07-19