mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 08:58:21 +00:00
show scrollbars in tree and syntax text (#725)
This commit is contained in:
parent
13b346b8b1
commit
eb9b0753a0
2 changed files with 29 additions and 3 deletions
|
|
@ -197,14 +197,18 @@ impl DrawableComponent for RevisionFilesComponent {
|
|||
usize::from(chunks[0].height.saturating_sub(2));
|
||||
|
||||
let selection = self.tree.visual_selection();
|
||||
selection.map_or_else(
|
||||
|| self.scroll_top.set(0),
|
||||
let visual_count = selection.map_or_else(
|
||||
|| {
|
||||
self.scroll_top.set(0);
|
||||
0
|
||||
},
|
||||
|selection| {
|
||||
self.scroll_top.set(ui::calc_scroll_top(
|
||||
self.scroll_top.get(),
|
||||
tree_height,
|
||||
selection.index,
|
||||
))
|
||||
));
|
||||
selection.count
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -242,6 +246,16 @@ impl DrawableComponent for RevisionFilesComponent {
|
|||
items,
|
||||
);
|
||||
|
||||
if is_tree_focused {
|
||||
ui::draw_scrollbar(
|
||||
f,
|
||||
chunks[0],
|
||||
&self.theme,
|
||||
visual_count.saturating_sub(tree_height),
|
||||
self.scroll_top.get(),
|
||||
);
|
||||
}
|
||||
|
||||
self.current_file.draw(f, chunks[1])?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,6 +187,18 @@ impl DrawableComponent for SyntaxTextComponent {
|
|||
|
||||
self.scroll(None);
|
||||
|
||||
if self.focused() {
|
||||
ui::draw_scrollbar(
|
||||
f,
|
||||
area,
|
||||
&self.theme,
|
||||
usize::from(state.lines().saturating_sub(
|
||||
state.height().saturating_sub(2),
|
||||
)),
|
||||
usize::from(state.scroll().y),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue