aboutsummaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorDaniel Jankowski <daniel.jankowski@rub.de>2023-09-20 09:57:27 +0200
committerDaniel Jankowski <daniel.jankowski@rub.de>2023-09-20 09:57:27 +0200
commit61dc9dd922f03bcdcea018851898caab2db9fe94 (patch)
tree540f24931f463af407defb13ec5f940dbcc4d52d /src/widgets
parentchore: update cargo deps (diff)
downloadsl0pstatus-61dc9dd922f03bcdcea018851898caab2db9fe94.tar.gz
sl0pstatus-61dc9dd922f03bcdcea018851898caab2db9fe94.tar.xz
sl0pstatus-61dc9dd922f03bcdcea018851898caab2db9fe94.zip
feat: add formatting for tabs with special status
Implements the feature request from #10
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/tabs.rs51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/widgets/tabs.rs b/src/widgets/tabs.rs
index 29a66fc..ca8323a 100644
--- a/src/widgets/tabs.rs
+++ b/src/widgets/tabs.rs
@@ -8,7 +8,11 @@ use super::widget::Widget;
pub struct TabsWidget {
active_tab_format: FormattedPart,
+ active_tab_fullscreen_format: FormattedPart,
+ active_tab_sync_format: FormattedPart,
normal_tab_format: FormattedPart,
+ normal_tab_fullscreen_format: FormattedPart,
+ normal_tab_sync_format: FormattedPart,
}
impl TabsWidget {
@@ -18,16 +22,40 @@ impl TabsWidget {
normal_tab_format_string = form;
}
+ let normal_tab_fullscreen_format = FormattedPart::from_format_string(match config.get("tab_normal_fullscreen") {
+ Some(form) => form.to_string(),
+ None => normal_tab_format_string.to_string(),
+ });
+
+ let normal_tab_sync_format = FormattedPart::from_format_string(match config.get("tab_normal_sync") {
+ Some(form) => form.to_string(),
+ None => normal_tab_format_string.to_string(),
+ });
+
let active_tab_format = FormattedPart::from_format_string(match config.get("tab_active") {
Some(form) => form.to_string(),
None => normal_tab_format_string.to_string(),
});
+ let active_tab_fullscreen_format = FormattedPart::from_format_string(match config.get("tab_active_fullscreen") {
+ Some(form) => form.to_string(),
+ None => normal_tab_format_string.to_string(),
+ });
+
+ let active_tab_sync_format = FormattedPart::from_format_string(match config.get("tab_active_sync") {
+ Some(form) => form.to_string(),
+ None => normal_tab_format_string.to_string(),
+ });
+
Self {
normal_tab_format: FormattedPart::from_format_string(
normal_tab_format_string.to_string(),
),
+ normal_tab_fullscreen_format,
+ normal_tab_sync_format,
active_tab_format,
+ active_tab_fullscreen_format,
+ active_tab_sync_format,
}
}
}
@@ -82,9 +110,26 @@ impl Widget for TabsWidget {
impl TabsWidget {
fn select_format(&self, info: TabInfo) -> FormattedPart {
- match info.active {
- false => self.normal_tab_format.clone(),
- true => self.active_tab_format.clone(),
+ if info.active && info.is_fullscreen_active {
+ return self.active_tab_fullscreen_format.clone();
+ }
+
+ if info.active && info.is_sync_panes_active {
+ return self.active_tab_sync_format.clone();
+ }
+
+ if info.active {
+ return self.active_tab_format.clone();
+ }
+
+ if info.is_fullscreen_active {
+ return self.normal_tab_fullscreen_format.clone();
}
+
+ if info.is_sync_panes_active {
+ return self.normal_tab_sync_format.clone();
+ }
+
+ self.normal_tab_format.clone()
}
}