diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-16 16:40:20 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-16 16:40:20 -0500 |
commit | 88da91c0f97dcb40e7e4cab54941af92a46d2e1a (patch) | |
tree | d5e7fa33842c19b32bfc834e531e2b942813e985 /src/ui/widgets/tui_dirlist.rs | |
parent | 98d0ce7e70f9febf804cda7473f5e9f7f180fe91 (diff) |
remove more code
- remove curr_list field from tab
- fixes many commands not working
Diffstat (limited to 'src/ui/widgets/tui_dirlist.rs')
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 83891b4..cda2da9 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -103,20 +103,25 @@ 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 screen_index = if skip_dist > 0 { + curr_index % skip_dist + } else { + curr_index + }; for (i, entry) in self .dirlist .contents .iter() + .skip(skip_dist) .enumerate() .take(area.height as usize) { - let fg = entry.get_fg_color(); - let bg = entry.get_bg_color(); let name = entry.file_name(); + let mut style = entry.get_style(); - let mut style = Style::default().fg(fg).bg(bg); - - if i == curr_index { + if i == screen_index { style = style.modifier(Modifier::REVERSED); } buf.set_stringn(x, y + i as u16, name, area.width as usize, style); |