diff options
author | quentin konieczko <konieczko@gmail.com> | 2022-10-04 12:40:24 +0200 |
---|---|---|
committer | quentin konieczko <konieczko@gmail.com> | 2022-10-04 12:40:24 +0200 |
commit | 804345386049430dde0b9f67b93dbaf78276e7c5 (patch) | |
tree | 037f999009ae96c3ecd2bdff44943465b322f730 | |
parent | ed5446cb70a7c8c667b6d427227d457c75c89867 (diff) |
reverse sort displayreverse
-rw-r--r-- | src/display.rs | 2 | ||||
-rw-r--r-- | src/fileinfo.rs | 3 | ||||
-rw-r--r-- | src/mode.rs | 2 | ||||
-rw-r--r-- | src/status.rs | 4 |
4 files changed, 9 insertions, 2 deletions
diff --git a/src/display.rs b/src/display.rs index a0e0175..e38adff 100644 --- a/src/display.rs +++ b/src/display.rs @@ -11,7 +11,7 @@ use crate::mode::Mode; use crate::status::Status; const EDIT_BOX_OFFSET: usize = 10; -const SORT_CURSOR_OFFSET: usize = 29; +const SORT_CURSOR_OFFSET: usize = 36; /// Is responsible for displaying content in the terminal. /// It uses an already created terminal. diff --git a/src/fileinfo.rs b/src/fileinfo.rs index c8fb274..a56ffc6 100644 --- a/src/fileinfo.rs +++ b/src/fileinfo.rs @@ -192,6 +192,7 @@ pub struct PathContent { pub selected: usize, pub show_hidden: bool, pub sort_by: SortBy, + pub reverse: bool, } impl PathContent { @@ -222,6 +223,7 @@ impl PathContent { if !files.is_empty() { files[selected].select(); } + let reverse = false; Self { path, @@ -229,6 +231,7 @@ impl PathContent { selected, show_hidden, sort_by, + reverse, } } diff --git a/src/mode.rs b/src/mode.rs index 0aad464..07ca789 100644 --- a/src/mode.rs +++ b/src/mode.rs @@ -48,7 +48,7 @@ impl fmt::Debug for Mode { Mode::RegexMatch => write!(f, "Regex : "), Mode::Jump => write!(f, "Jump : "), Mode::NeedConfirmation => write!(f, "Y/N :"), - Mode::Sort => write!(f, "(N)ame (D)ate (S)ize (E)xt : "), + Mode::Sort => write!(f, "(N)ame (D)ate (S)ize (E)xt (R)ev :"), } } } diff --git a/src/status.rs b/src/status.rs index e0178e5..f9296c8 100644 --- a/src/status.rs +++ b/src/status.rs @@ -281,6 +281,7 @@ impl Status { 'd' => self.path_content.sort_by = SortBy::Date, 's' => self.path_content.sort_by = SortBy::Size, 'e' => self.path_content.sort_by = SortBy::Extension, + 'r' => self.path_content.reverse = !self.path_content.reverse, _ => { return; } @@ -288,6 +289,9 @@ impl Status { if !self.path_content.files.is_empty() { self.path_content.files[self.file_index].unselect(); self.path_content.sort(); + if self.path_content.reverse { + self.path_content.files.reverse(); + } self.event_go_top(); self.path_content.select_index(0) } |