diff options
author | DLFW <daniel@llin.info> | 2021-06-21 02:40:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-20 20:40:44 -0400 |
commit | 68a6bf78cfe6d0a46f15f2e80e917ffb69b8c963 (patch) | |
tree | d293189829d59dd5d8e8b8265d494a03f5975737 /src/ui | |
parent | e6359a599e804031189eb9bc067c4eff9b01a1a8 (diff) |
Fix selecting an entry by mouse click when show_borders=true (#77)
* encapsulate paging strategy
This commit introduces one central place where the “paging” (first entry
of a dir list shown in the UI) strategy is implemented.
This decreases the risk for copy-paste mistakes, makes it easier to
change it, and would make the implementation of a configurable paging
strategy easier.
* fix: correct new index on click for parent column
And a little refactoring of the code that handles the left click.
* fix: consider borders on left click
When selecting a dir entry with a left click of the mouse, the borders
were not considered, which led to
1. a faulty, constant y offset of 1 row
2. a faulty offset, which increased with each page scrolled down, due to
a wrong calculation of the content height
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 2 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist_detailed.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 7d9f888..f66c9f0 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -36,7 +36,7 @@ impl<'a> Widget for TuiDirList<'a> { } let curr_index = self.dirlist.index.unwrap(); - let skip_dist = curr_index / area.height as usize * area.height as usize; + let skip_dist = self.dirlist.first_index_for_viewport(area.height as usize); let drawing_width = area.width as usize; diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 796ead4..2c0337d 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -41,7 +41,7 @@ impl<'a> Widget for TuiDirListDetailed<'a> { }; let drawing_width = area.width as usize; - let skip_dist = curr_index / area.height as usize * area.height as usize; + let skip_dist = self.dirlist.first_index_for_viewport(area.height as usize); // draw every entry self.dirlist |