diff options
author | rabite <rabite@posteo.de> | 2019-02-26 00:32:24 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-02-26 00:32:24 +0100 |
commit | a1230fed0d0a4092c5414206604505ba4ca560c4 (patch) | |
tree | 73fd201c78680fc615c123e3f6e0d69eaa0d6d8e /src/tabview.rs | |
parent | 184f4916d32cec88ec9ac5a48afb7aedceffdfea (diff) |
show tab direcories
Diffstat (limited to 'src/tabview.rs')
-rw-r--r-- | src/tabview.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tabview.rs b/src/tabview.rs index 722932a..675ba66 100644 --- a/src/tabview.rs +++ b/src/tabview.rs @@ -8,6 +8,7 @@ pub trait Tabbable { fn close_tab(&mut self); fn next_tab(&mut self); fn on_next_tab(&mut self); + fn get_tab_names(&self) -> Vec<Option<String>>; fn active_tab(&self) -> &dyn Widget; fn active_tab_mut(&mut self) -> &mut dyn Widget; fn on_key(&mut self, key: Key) { @@ -23,7 +24,7 @@ pub trait Tabbable { #[derive(PartialEq)] pub struct TabView<T> where T: Widget, TabView<T>: Tabbable { - widgets: Vec<T>, + pub widgets: Vec<T>, pub active: usize, coordinates: Coordinates } @@ -77,17 +78,21 @@ impl<T> Widget for TabView<T> where T: Widget, TabView<T>: Tabbable { fn render_header(&self) -> String { let xsize = self.get_coordinates().xsize(); let header = self.active_tab_().render_header(); + let mut tab_names = self.get_tab_names(); let mut nums_length = 0; let tabnums = (0..self.widgets.len()).map(|num| { - nums_length += format!("{} ", num).len(); + nums_length += format!("{}:{} ", + num, + tab_names[num].as_ref().unwrap()).len(); if num == self.active { - format!(" {}{}{}{}", + format!(" {}{}:{}{}{}", crate::term::invert(), num, + tab_names[num].as_ref().unwrap(), crate::term::reset(), crate::term::header_color()) } else { - format!(" {}", num) + format!(" {}:{}", num, tab_names[num].as_ref().unwrap()) } }).collect::<String>(); |