diff options
author | DLFW <daniel@llin.info> | 2022-08-14 02:04:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 20:04:38 -0400 |
commit | 6356efaa55830c4ef8ed976a6e89f738ab6e026d (patch) | |
tree | 9f6dde209a7c1e085764538edc2d1679bb50ca80 /src/config | |
parent | d2ef6d44cc09ad3e57642d5839d972d426bfff12 (diff) |
Sort options individual per tab (#191)
Sort options (sort criterion, reversion, dir-first, and case-sensitivity)
are specific for each tab. Changing sort-options will not have any
affect on tabs other than the currently active one. Each new tab will
start with the default sort-options.
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/general/app.rs | 9 | ||||
-rw-r--r-- | src/config/general/display_raw.rs | 6 | ||||
-rw-r--r-- | src/config/option/display_option.rs | 31 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/config/general/app.rs b/src/config/general/app.rs index 3680820..f2602b0 100644 --- a/src/config/general/app.rs +++ b/src/config/general/app.rs @@ -1,7 +1,7 @@ use super::app_raw::AppConfigRaw; use super::DEFAULT_CONFIG_FILE_PATH; -use crate::config::option::{DisplayOption, PreviewOption, SortOption, TabOption}; +use crate::config::option::{DisplayOption, PreviewOption, TabOption}; use crate::error::JoshutoResult; #[derive(Debug, Clone)] @@ -35,13 +35,6 @@ impl AppConfig { &mut self._preview_options } - pub fn sort_options_ref(&self) -> &SortOption { - self.display_options_ref().sort_options_ref() - } - pub fn sort_options_mut(&mut self) -> &mut SortOption { - self.display_options_mut().sort_options_mut() - } - pub fn tab_options_ref(&self) -> &TabOption { &self._tab_options } diff --git a/src/config/general/display_raw.rs b/src/config/general/display_raw.rs index de91ea2..dc0dc9f 100644 --- a/src/config/general/display_raw.rs +++ b/src/config/general/display_raw.rs @@ -3,7 +3,7 @@ use std::convert::From; use serde_derive::Deserialize; use tui::layout::Constraint; -use crate::config::option::{DisplayMode, DisplayOption, LineNumberStyle}; +use crate::config::option::{DisplayMode, DisplayOption, LineNumberStyle, TabDisplayOption}; use super::sort_raw::SortOptionRaw; @@ -117,13 +117,15 @@ impl From<DisplayOptionRaw> for DisplayOption { _show_borders: raw.show_borders, _show_hidden: raw.show_hidden, _show_icons: raw.show_icons, - _sort_options: raw.sort_options.into(), _tilde_in_titlebar: raw.tilde_in_titlebar, _line_nums, column_ratio, default_layout, no_preview_layout, + default_tab_display_option: TabDisplayOption { + _sort_options: raw.sort_options.into(), + }, } } } diff --git a/src/config/option/display_option.rs b/src/config/option/display_option.rs index 5166725..1578e06 100644 --- a/src/config/option/display_option.rs +++ b/src/config/option/display_option.rs @@ -14,6 +14,7 @@ pub const fn default_column_ratio() -> (usize, usize, usize) { (1, 3, 4) } +/// Display options globally valid for Joshuto (for all tabs) #[derive(Clone, Debug)] pub struct DisplayOption { pub _mode: DisplayMode, @@ -23,12 +24,18 @@ pub struct DisplayOption { pub _show_borders: bool, pub _show_hidden: bool, pub _show_icons: bool, - pub _sort_options: SortOption, pub _tilde_in_titlebar: bool, pub _line_nums: LineNumberStyle, pub column_ratio: (usize, usize, usize), pub default_layout: [Constraint; 3], pub no_preview_layout: [Constraint; 3], + pub default_tab_display_option: TabDisplayOption, +} + +/// Display options valid per JoshutoTab +#[derive(Clone, Debug)] +pub struct TabDisplayOption { + pub _sort_options: SortOption, } #[derive(Clone, Copy, Debug)] @@ -38,6 +45,16 @@ pub enum LineNumberStyle { Absolute, } +impl TabDisplayOption { + pub fn sort_options_ref(&self) -> &SortOption { + &self._sort_options + } + + pub fn sort_options_mut(&mut self) -> &mut SortOption { + &mut self._sort_options + } +} + impl DisplayOption { pub fn mode(&self) -> DisplayMode { self._mode @@ -71,14 +88,6 @@ impl DisplayOption { self._show_hidden = show_hidden; } - pub fn sort_options_ref(&self) -> &SortOption { - &self._sort_options - } - - pub fn sort_options_mut(&mut self) -> &mut SortOption { - &mut self._sort_options - } - pub fn tilde_in_titlebar(&self) -> bool { self._tilde_in_titlebar } @@ -125,11 +134,13 @@ impl std::default::Default for DisplayOption { _show_borders: true, _show_hidden: false, _show_icons: false, - _sort_options: SortOption::default(), _tilde_in_titlebar: true, _line_nums: LineNumberStyle::None, default_layout, no_preview_layout, + default_tab_display_option: TabDisplayOption { + _sort_options: SortOption::default(), + }, } } } |