Skip to content

Commit

Permalink
Extract get_pane_width() into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Jul 5, 2024
1 parent cc659a9 commit 4cb8e89
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Line<'a>>) {
self.data = data;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 4cb8e89

Please sign in to comment.