-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TUI: Follow output when scrolled to the bottom #210
TUI: Follow output when scrolled to the bottom #210
Conversation
129760d
to
92fd614
Compare
92fd614
to
5d63561
Compare
src/tui/mod.rs
Outdated
@@ -122,10 +122,18 @@ impl Tui { | |||
self.scroll_offset = min(self.scroll_max(), scroll_offset); | |||
} | |||
|
|||
fn maybe_follow(&mut self) { | |||
let height = self.size.height as usize; | |||
if self.scroll_offset >= self.line_count - height - 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit pick: I would add parens to make order of operations more obvious.
if self.scroll_offset >= self.line_count - height - 1 { | |
if self.scroll_offset >= self.line_count - (height + 1) { |
} | ||
|
||
impl Default for TuiState { | ||
fn default() -> Self { | ||
Self { | ||
quit: false, | ||
scrollback: Vec::with_capacity(TUI_SCROLLBACK_CAPACITY), | ||
line_count: 1, | ||
scroll_offset: 0, | ||
line_count: Saturating(1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol you could go even further and make this a NonZeroUsize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonZeroUsize
isn't saturating, weirdly: https://doc.rust-lang.org/stable/core/num/struct.NonZeroUsize.html#method.saturating_add
Fixes #209.