diff options
author | rabite <rabite@posteo.de> | 2019-03-20 20:48:46 +0100 |
---|---|---|
committer | rabite <rabite@posteo.de> | 2019-03-20 20:48:46 +0100 |
commit | 04c40ec3ca728ecfc8e7998e66a468abfbfa22fc (patch) | |
tree | 8f02680c8f41fdebb9effa482bd5dc5fb335f52f /src/hbox.rs | |
parent | 118aeac6e0e4a10b2728fd13920a2c6c3808a6ff (diff) |
removed useless miller column widget
Diffstat (limited to 'src/hbox.rs')
-rw-r--r-- | src/hbox.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/hbox.rs b/src/hbox.rs index 49b9c47..a782911 100644 --- a/src/hbox.rs +++ b/src/hbox.rs @@ -102,10 +102,21 @@ impl<T> HBox<T> where T: Widget + PartialEq { Ok(coords) } - pub fn active_widget(&self) -> &T { - &self.widgets.last().unwrap() + pub fn set_active(&mut self, i: usize) -> HResult<()> { + if i+1 > self.widgets.len() { + HError::no_widget()? + } + self.active = Some(i); + Ok(()) } + pub fn active_widget(&self) -> Option<&T> { + self.widgets.get(self.active?) + } + + pub fn active_widget_mut(&mut self) -> Option<&mut T> { + self.widgets.get_mut(self.active?) + } } @@ -125,7 +136,7 @@ impl<T> Widget for HBox<T> where T: Widget + PartialEq { } fn render_header(&self) -> HResult<String> { - self.active_widget().render_header() + self.active_widget()?.render_header() } fn refresh(&mut self) -> HResult<()> { |