Including text on tab name to let users know sync is on.

This commit is contained in:
Dante Pippi 2021-04-27 15:56:42 -03:00
parent 6769627c36
commit 62662464e3
5 changed files with 16 additions and 4 deletions

View file

@ -65,7 +65,7 @@ impl ZellijPlugin for State {
} else if t.active { } else if t.active {
active_tab_index = t.position; 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); all_tabs.push(tab);
} }
let tab_line = tab_line(all_tabs, active_tab_index, cols); let tab_line = tab_line(all_tabs, active_tab_index, cols);

View file

@ -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() { let tab_text = if text.is_empty() {
format!("Tab #{}", position + 1) format!("Tab #{}{}", position + 1, sync_text)
} else { } else {
text text
}; };

View file

@ -450,6 +450,7 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
.get_active_tab_mut() .get_active_tab_mut()
.unwrap() .unwrap()
.toggle_sync_panes_is_active(); .toggle_sync_panes_is_active();
screen.update_tabs();
} }
ScreenInstruction::Quit => { ScreenInstruction::Quit => {
break; break;

View file

@ -286,7 +286,7 @@ impl Screen {
self.update_tabs(); self.update_tabs();
} }
fn update_tabs(&self) { pub fn update_tabs(&self) {
let mut tab_data = vec![]; let mut tab_data = vec![];
let active_tab_index = self.active_tab_index.unwrap(); let active_tab_index = self.active_tab_index.unwrap();
for tab in self.tabs.values() { for tab in self.tabs.values() {
@ -294,6 +294,7 @@ impl Screen {
position: tab.position, position: tab.position,
name: tab.name.clone(), name: tab.name.clone(),
active: active_tab_index == tab.index, active: active_tab_index == tab.index,
is_sync_panes_active: tab.is_sync_panes_active(),
}); });
} }
self.send_plugin_instructions self.send_plugin_instructions

View file

@ -83,6 +83,7 @@ pub struct TabInfo {
pub position: usize, pub position: usize,
pub name: String, pub name: String,
pub active: bool, pub active: bool,
pub is_sync_panes_active: bool,
} }
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]