From 2b29f8485e95fd3cda434ed472992fff2ee8e7a0 Mon Sep 17 00:00:00 2001 From: Jiayi Zhao Date: Mon, 14 Dec 2020 21:39:10 -0500 Subject: selected item now highlights entire row instead of just filename --- src/ui/widgets/tui_dirlist.rs | 6 +++++- src/ui/widgets/tui_dirlist_detailed.rs | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 60b7374..afa3258 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -40,6 +40,8 @@ impl<'a> Widget for TuiDirList<'a> { let screen_index = curr_index % area.height as usize; let area_width = area.width as usize - 1; + let space_fill = " ".repeat(area_width); + for (i, entry) in self .dirlist .iter() @@ -51,7 +53,9 @@ impl<'a> Widget for TuiDirList<'a> { let name_width = name.width(); let style = if i == screen_index { - entry.get_style().add_modifier(Modifier::REVERSED) + let s = entry.get_style().add_modifier(Modifier::REVERSED); + buf.set_string(x, y + i as u16, space_fill.as_str(), s); + s } else { entry.get_style() }; diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 4bb63ce..b63ebdb 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -1,6 +1,7 @@ use tui::buffer::Buffer; use tui::layout::Rect; use tui::style::{Color, Modifier, Style}; +use tui::symbols::block; use tui::widgets::Widget; use unicode_width::UnicodeWidthStr; @@ -42,6 +43,8 @@ impl<'a> Widget for TuiDirListDetailed<'a> { let screen_index = curr_index % area.height as usize; let area_width = area.width as usize; + let space_fill = " ".repeat(area_width); + for (i, entry) in self .dirlist .iter() @@ -58,6 +61,8 @@ impl<'a> Widget for TuiDirListDetailed<'a> { entry.get_style() }; + buf.set_string(x, y + i as u16, space_fill.as_str(), style); + let file_type = &entry.metadata.file_type; match file_type { FileType::Directory => { -- cgit v1.2.3