Do not draw scrollbar when not needed, draw background behind scrollbar

This commit is contained in:
Jeremy Soller 2023-12-21 10:26:17 -07:00
parent ccec8e813b
commit 49149c3e17
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
2 changed files with 55 additions and 40 deletions

View file

@ -242,16 +242,20 @@ impl Terminal {
));
}
pub fn scrollbar(&self) -> (f32, f32) {
pub fn scrollbar(&self) -> Option<(f32, f32)> {
let term = self.term.lock();
let grid = term.grid();
let total = grid.history_size() + grid.screen_lines();
let start = total - grid.display_offset() - grid.screen_lines();
let end = total - grid.display_offset();
(
(start as f32) / (total as f32),
(end as f32) / (total as f32),
)
if grid.history_size() > 0 {
let total = grid.history_size() + grid.screen_lines();
let start = total - grid.display_offset() - grid.screen_lines();
let end = total - grid.display_offset();
Some((
(start as f32) / (total as f32),
(end as f32) / (total as f32),
))
} else {
None
}
}
pub fn update(&mut self) -> bool {