From 62662464e3814bde666ec826850c9d87d4af2639 Mon Sep 17 00:00:00 2001 From: Dante Pippi <6619666+dantepippi@users.noreply.github.com> Date: Tue, 27 Apr 2021 15:56:42 -0300 Subject: [PATCH] Including text on tab name to let users know sync is on. --- default-plugins/tab-bar/src/main.rs | 2 +- default-plugins/tab-bar/src/tab.rs | 13 +++++++++++-- src/common/mod.rs | 1 + src/common/screen.rs | 3 ++- zellij-tile/src/data.rs | 1 + 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/default-plugins/tab-bar/src/main.rs b/default-plugins/tab-bar/src/main.rs index 5a77ebac..f059d20e 100644 --- a/default-plugins/tab-bar/src/main.rs +++ b/default-plugins/tab-bar/src/main.rs @@ -65,7 +65,7 @@ impl ZellijPlugin for State { } else if t.active { active_tab_index = t.position; } - let tab = tab_style(tabname, t.active, t.position); + let tab = tab_style(tabname, t.active, t.position, t.is_sync_panes_active); all_tabs.push(tab); } let tab_line = tab_line(all_tabs, active_tab_index, cols); diff --git a/default-plugins/tab-bar/src/tab.rs b/default-plugins/tab-bar/src/tab.rs index a4c7c376..0bc143b7 100644 --- a/default-plugins/tab-bar/src/tab.rs +++ b/default-plugins/tab-bar/src/tab.rs @@ -40,9 +40,18 @@ pub fn non_active_tab(text: String) -> LinePart { } } -pub fn tab_style(text: String, is_active_tab: bool, position: usize) -> LinePart { +pub fn tab_style( + text: String, + is_active_tab: bool, + position: usize, + is_sync_panes_active: bool, +) -> LinePart { + let sync_text = match is_sync_panes_active { + true => " (Sync)".to_string(), + false => "".to_string(), + }; let tab_text = if text.is_empty() { - format!("Tab #{}", position + 1) + format!("Tab #{}{}", position + 1, sync_text) } else { text }; diff --git a/src/common/mod.rs b/src/common/mod.rs index d829451e..0a04e3ff 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -450,6 +450,7 @@ pub fn start(mut os_input: Box, opts: CliArgs) { .get_active_tab_mut() .unwrap() .toggle_sync_panes_is_active(); + screen.update_tabs(); } ScreenInstruction::Quit => { break; diff --git a/src/common/screen.rs b/src/common/screen.rs index 75c0a805..bc68f2ea 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -286,7 +286,7 @@ impl Screen { self.update_tabs(); } - fn update_tabs(&self) { + pub fn update_tabs(&self) { let mut tab_data = vec![]; let active_tab_index = self.active_tab_index.unwrap(); for tab in self.tabs.values() { @@ -294,6 +294,7 @@ impl Screen { position: tab.position, name: tab.name.clone(), active: active_tab_index == tab.index, + is_sync_panes_active: tab.is_sync_panes_active(), }); } self.send_plugin_instructions diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs index fec37b17..713282cb 100644 --- a/zellij-tile/src/data.rs +++ b/zellij-tile/src/data.rs @@ -83,6 +83,7 @@ pub struct TabInfo { pub position: usize, pub name: String, pub active: bool, + pub is_sync_panes_active: bool, } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]