diff options
| author | Rikard Bergqvist <j10rikardb@gmail.com> | 2026-04-18 07:28:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-18 07:28:55 +0200 |
| commit | 0d7ec6569acee97068d238aa1faa8e19fc8b8a4c (patch) | |
| tree | 95b3ba68c4be932881c296eda90b92ca7fe01614 /src | |
| parent | chore(deps): bump cached from 0.56.0 to 0.59.0 (#246) (diff) | |
| download | sl0pstatus-0d7ec6569acee97068d238aa1faa8e19fc8b8a4c.tar.gz sl0pstatus-0d7ec6569acee97068d238aa1faa8e19fc8b8a4c.tar.xz sl0pstatus-0d7ec6569acee97068d238aa1faa8e19fc8b8a4c.zip | |
feat: add zero based tab index support (#249)
* adds zero based tab index support
* update after comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/widgets/tabs.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/widgets/tabs.rs b/src/widgets/tabs.rs index c012e3a..647cf67 100644 --- a/src/widgets/tabs.rs +++ b/src/widgets/tabs.rs @@ -24,6 +24,7 @@ pub struct TabsWidget { tab_display_count: Option<usize>, tab_truncate_start_format: Vec<FormattedPart>, tab_truncate_end_format: Vec<FormattedPart>, + tab_zero_based_index: bool, } impl TabsWidget { @@ -78,6 +79,11 @@ impl TabsWidget { .map(|form| FormattedPart::multiple_from_format_string(form, config)) .unwrap_or_default(); + let tab_zero_based_index = match config.get("tab_zero_based_index") { + Some(e) => matches!(e.as_str(), "true"), + None => false, + }; + let separator = config .get("tab_separator") .map(|s| FormattedPart::from_format_string(s, config)); @@ -97,6 +103,7 @@ impl TabsWidget { tab_display_count, tab_truncate_start_format, tab_truncate_end_format, + tab_zero_based_index, } } } @@ -270,7 +277,11 @@ impl TabsWidget { } if content.contains("{index}") { - content = content.replace("{index}", (tab.position + 1).to_string().as_str()); + let index = match self.tab_zero_based_index { + true => tab.position, + false => tab.position + 1, + }; + content = content.replace("{index}", index.to_string().as_str()); } if content.contains("{floating_total_count}") { |
