diff options
Diffstat (limited to 'src/tabview.rs')
-rw-r--r-- | src/tabview.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tabview.rs b/src/tabview.rs index 524a469..adf22e7 100644 --- a/src/tabview.rs +++ b/src/tabview.rs @@ -3,7 +3,6 @@ use termion::event::Key; use crate::widget::{Widget, WidgetCore}; use crate::fail::{HResult, ErrorLog}; use crate::coordinates::Coordinates; -use crate::dirty::Dirtyable; pub trait Tabbable { fn new_tab(&mut self) -> HResult<()>; @@ -26,6 +25,10 @@ pub trait Tabbable { _ => self.on_key_sub(key) } } + fn on_refresh(&mut self) -> HResult<()> { Ok(()) } + fn on_config_loaded(&mut self) -> HResult<()> { Ok(()) } + + } @@ -108,6 +111,10 @@ impl<T> Widget for TabView<T> where T: Widget, TabView<T>: Tabbable { Ok(&mut self.core) } + fn config_loaded(&mut self) -> HResult<()> { + self.on_config_loaded() + } + fn set_coordinates(&mut self, coordinates: &Coordinates) -> HResult<()> { self.core.coordinates = coordinates.clone(); for widget in &mut self.widgets { @@ -137,7 +144,8 @@ impl<T> Widget for TabView<T> where T: Widget, TabView<T>: Tabbable { } }).collect::<String>(); - let nums_pos = xsize - nums_length as u16; + + let nums_pos = xsize.saturating_sub(nums_length as u16); Ok(format!("{}{}{}{}", header, @@ -152,6 +160,7 @@ impl<T> Widget for TabView<T> where T: Widget, TabView<T>: Tabbable { } fn refresh(&mut self) -> HResult<()> { + Tabbable::on_refresh(self).log(); self.active_tab_mut().refresh() } |