@@ -7,6 +7,7 @@ use chrono::DateTime;
77use dua:: traverse:: TreeIndex ;
88use itertools:: Itertools ;
99use std:: borrow:: { Borrow , Cow } ;
10+ use std:: collections:: HashSet ;
1011use std:: time:: SystemTime ;
1112use tui:: {
1213 buffer:: Buffer ,
@@ -33,6 +34,7 @@ pub struct EntriesProps<'a> {
3334 pub border_style : Style ,
3435 pub is_focussed : bool ,
3536 pub sort_mode : SortMode ,
37+ pub show_columns : & ' a HashSet < Column > ,
3638}
3739
3840#[ derive( Default ) ]
@@ -56,6 +58,7 @@ impl Entries {
5658 border_style,
5759 is_focussed,
5860 sort_mode,
61+ show_columns,
5962 } = props. borrow ( ) ;
6063 let list = & mut self . list ;
6164
@@ -87,7 +90,7 @@ impl Entries {
8790 let percentage_style = percentage_style ( fraction, text_style) ;
8891
8992 let mut columns = Vec :: new ( ) ;
90- if show_mtime_column ( sort_mode) {
93+ if show_mtime_column ( sort_mode, show_columns ) {
9194 columns. push ( mtime_column (
9295 bundle. mtime ,
9396 column_style ( Column :: MTime , * sort_mode, text_style) ,
@@ -99,7 +102,7 @@ impl Entries {
99102 column_style ( Column :: Bytes , * sort_mode, text_style) ,
100103 ) ) ;
101104 columns. push ( percentage_column ( * display, fraction, percentage_style) ) ;
102- if show_count_column ( sort_mode) {
105+ if show_count_column ( sort_mode, show_columns ) {
103106 columns. push ( count_column (
104107 bundle. entry_count ,
105108 column_style ( Column :: Count , * sort_mode, text_style) ,
@@ -323,8 +326,8 @@ fn bytes_column(display: DisplayOptions, entry_size: u128, style: Style) -> Span
323326 )
324327}
325328
326- #[ derive( PartialEq ) ]
327- enum Column {
329+ #[ derive( PartialEq , Eq , Hash ) ]
330+ pub enum Column {
328331 Bytes ,
329332 MTime ,
330333 Count ,
@@ -344,18 +347,18 @@ fn column_style(column: Column, sort_mode: SortMode, style: Style) -> Style {
344347 }
345348}
346349
347- fn show_mtime_column ( sort_mode : & SortMode ) -> bool {
350+ fn show_mtime_column ( sort_mode : & SortMode , show_columns : & HashSet < Column > ) -> bool {
348351 matches ! (
349352 sort_mode,
350353 SortMode :: MTimeAscending | SortMode :: MTimeDescending
351- )
354+ ) || show_columns . contains ( & Column :: MTime )
352355}
353356
354- fn show_count_column ( sort_mode : & SortMode ) -> bool {
357+ fn show_count_column ( sort_mode : & SortMode , show_columns : & HashSet < Column > ) -> bool {
355358 matches ! (
356359 sort_mode,
357360 SortMode :: CountAscending | SortMode :: CountDescending
358- )
361+ ) || show_columns . contains ( & Column :: Count )
359362}
360363
361364/// Note that this implementation isn't correct as `width` is the amount of blocks to display,
0 commit comments