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 {
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);

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() {
format!("Tab #{}", position + 1)
format!("Tab #{}{}", position + 1, sync_text)
} else {
text
};

View File

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

View File

@ -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

View File

@ -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)]