From 4cb8e89f6357cd3b2b3ff90314c5d7c6b490e57c Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 4 Jul 2024 15:33:44 -0700 Subject: [PATCH] Extract `get_pane_width()` into a function --- src/watch.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/watch.rs b/src/watch.rs index 132743a..2761400 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -69,6 +69,14 @@ impl<'a> WatchArea<'a> { return height; } + pub fn get_pane_width(&mut self) -> u16 { + let mut pane_width: u16 = self.area.width; + if self.border && pane_width > 0 { + pane_width -= 1; + } + pane_width + } + /// pub fn update_output(&mut self, data: Vec>) { self.data = data; @@ -125,12 +133,7 @@ impl<'a> WatchArea<'a> { .scroll((self.position as u16, 0)); // get self.lines - let mut pane_width: u16 = self.area.width as u16; - if self.border { - pane_width = pane_width - 1; - } - - self.lines = block.line_count(pane_width) as i16; + self.lines = block.line_count(self.get_pane_width()) as i16; frame.render_widget(block, self.area);