diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-04-09 17:41:44 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-04-09 17:41:44 -0400 |
commit | f7d20c82260821226873c75f421583722b1ca544 (patch) | |
tree | ef26a8a8667860b191454f5cd134aea293c3bf54 /src/config | |
parent | 84f9df66c391a0c0236dc5d052b27060c4b08c76 (diff) |
rename crude to raw again = =;
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/general/app.rs | 6 | ||||
-rw-r--r-- | src/config/general/app_raw.rs (renamed from src/config/general/app_crude.rs) | 34 | ||||
-rw-r--r-- | src/config/general/display_raw.rs (renamed from src/config/general/display_crude.rs) | 34 | ||||
-rw-r--r-- | src/config/general/mod.rs | 10 | ||||
-rw-r--r-- | src/config/general/preview_raw.rs (renamed from src/config/general/preview_crude.rs) | 16 | ||||
-rw-r--r-- | src/config/general/sort_raw.rs (renamed from src/config/general/sort_crude.rs) | 16 | ||||
-rw-r--r-- | src/config/general/tab_raw.rs (renamed from src/config/general/tab_crude.rs) | 10 | ||||
-rw-r--r-- | src/config/theme/app_theme.rs | 28 | ||||
-rw-r--r-- | src/config/theme/mod.rs | 4 | ||||
-rw-r--r-- | src/config/theme/style.rs | 6 |
10 files changed, 82 insertions, 82 deletions
diff --git a/src/config/general/app.rs b/src/config/general/app.rs index c21c10d..2c78e33 100644 --- a/src/config/general/app.rs +++ b/src/config/general/app.rs @@ -1,6 +1,6 @@ use super::DEFAULT_CONFIG_FILE_PATH; -use super::app_crude::AppConfigCrude; +use super::app_raw::AppConfigRaw; use crate::config::option::{DisplayOption, PreviewOption, SortOption, TabOption}; use crate::error::JoshutoResult; @@ -17,8 +17,8 @@ pub struct AppConfig { impl AppConfig { pub fn default_res() -> JoshutoResult<Self> { - let crude: AppConfigCrude = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?; - Ok(Self::from(crude)) + let raw: AppConfigRaw = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?; + Ok(Self::from(raw)) } pub fn display_options_ref(&self) -> &DisplayOption { diff --git a/src/config/general/app_crude.rs b/src/config/general/app_raw.rs index cd7bc78..a3d88d9 100644 --- a/src/config/general/app_crude.rs +++ b/src/config/general/app_raw.rs @@ -5,9 +5,9 @@ use serde_derive::Deserialize; use crate::config::option::{DisplayOption, PreviewOption, TabOption}; use crate::config::{parse_to_config_file, AppConfig, TomlConfigFile}; -use super::display_crude::DisplayOptionCrude; -use super::preview_crude::PreviewOptionCrude; -use super::tab_crude::TabOptionCrude; +use super::display_raw::DisplayOptionRaw; +use super::preview_raw::PreviewOptionRaw; +use super::tab_raw::TabOptionRaw; const fn default_true() -> bool { true @@ -17,7 +17,7 @@ const fn default_scroll_offset() -> usize { } #[derive(Clone, Debug, Deserialize)] -pub struct AppConfigCrude { +pub struct AppConfigRaw { #[serde(default = "default_scroll_offset")] pub scroll_offset: usize, #[serde(default = "default_true")] @@ -29,29 +29,29 @@ pub struct AppConfigCrude { #[serde(default = "default_true")] pub watch_files: bool, #[serde(default, rename = "display")] - pub display_options: DisplayOptionCrude, + pub display_options: DisplayOptionRaw, #[serde(default, rename = "preview")] - pub preview_options: PreviewOptionCrude, + pub preview_options: PreviewOptionRaw, #[serde(default, rename = "tab")] - pub tab_options: TabOptionCrude, + pub tab_options: TabOptionRaw, } -impl From<AppConfigCrude> for AppConfig { - fn from(crude: AppConfigCrude) -> Self { +impl From<AppConfigRaw> for AppConfig { + fn from(raw: AppConfigRaw) -> Self { Self { - use_trash: crude.use_trash, - xdg_open: crude.xdg_open, - xdg_open_fork: crude.xdg_open_fork, - watch_files: crude.watch_files, - _display_options: DisplayOption::from(crude.display_options), - _preview_options: PreviewOption::from(crude.preview_options), - _tab_options: TabOption::from(crude.tab_options), + use_trash: raw.use_trash, + xdg_open: raw.xdg_open, + xdg_open_fork: raw.xdg_open_fork, + watch_files: raw.watch_files, + _display_options: DisplayOption::from(raw.display_options), + _preview_options: PreviewOption::from(raw.preview_options), + _tab_options: TabOption::from(raw.tab_options), } } } impl TomlConfigFile for AppConfig { fn get_config(file_name: &str) -> Self { - parse_to_config_file::<AppConfigCrude, AppConfig>(file_name).unwrap_or_default() + parse_to_config_file::<AppConfigRaw, AppConfig>(file_name).unwrap_or_default() } } diff --git a/src/config/general/display_crude.rs b/src/config/general/display_raw.rs index bc4cf45..0d44a97 100644 --- a/src/config/general/display_crude.rs +++ b/src/config/general/display_raw.rs @@ -5,7 +5,7 @@ use tui::layout::Constraint; use crate::config::option::{DisplayOption, LineNumberStyle}; -use super::sort_crude::SortOptionCrude; +use super::sort_raw::SortOptionRaw; pub const fn default_column_ratio() -> (usize, usize, usize) { (1, 3, 4) @@ -20,7 +20,7 @@ const fn default_scroll_offset() -> usize { } #[derive(Clone, Debug, Deserialize)] -pub struct DisplayOptionCrude { +pub struct DisplayOptionRaw { #[serde(default)] pub automatically_count_files: bool, @@ -46,13 +46,13 @@ pub struct DisplayOptionCrude { pub tilde_in_titlebar: bool, #[serde(default, rename = "sort")] - pub sort_options: SortOptionCrude, + pub sort_options: SortOptionRaw, #[serde(default)] pub line_number_style: String, } -impl std::default::Default for DisplayOptionCrude { +impl std::default::Default for DisplayOptionRaw { fn default() -> Self { Self { automatically_count_files: false, @@ -62,16 +62,16 @@ impl std::default::Default for DisplayOptionCrude { show_borders: true, show_hidden: false, show_icons: false, - sort_options: SortOptionCrude::default(), + sort_options: SortOptionRaw::default(), tilde_in_titlebar: true, line_number_style: "none".to_string(), } } } -impl From<DisplayOptionCrude> for DisplayOption { - fn from(crude: DisplayOptionCrude) -> Self { - let column_ratio = match crude.column_ratio { +impl From<DisplayOptionRaw> for DisplayOption { + fn from(raw: DisplayOptionRaw) -> Self { + let column_ratio = match raw.column_ratio { Some(s) if s.len() == 3 => (s[0], s[1], s[2]), Some(s) if s.len() == 2 => (0, s[0], s[1]), _ => default_column_ratio(), @@ -90,21 +90,21 @@ impl From<DisplayOptionCrude> for DisplayOption { Constraint::Ratio(0, total), ]; - let _line_nums = match crude.line_number_style.as_ref() { + let _line_nums = match raw.line_number_style.as_ref() { "absolute" => LineNumberStyle::Absolute, "relative" => LineNumberStyle::Relative, _ => LineNumberStyle::None, }; Self { - _automatically_count_files: crude.automatically_count_files, - _collapse_preview: crude.collapse_preview, - _scroll_offset: crude.scroll_offset, - _show_borders: crude.show_borders, - _show_hidden: crude.show_hidden, - _show_icons: crude.show_icons, - _sort_options: crude.sort_options.into(), - _tilde_in_titlebar: crude.tilde_in_titlebar, + _automatically_count_files: raw.automatically_count_files, + _collapse_preview: raw.collapse_preview, + _scroll_offset: raw.scroll_offset, + _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, diff --git a/src/config/general/mod.rs b/src/config/general/mod.rs index 5840d95..7b85b7f 100644 --- a/src/config/general/mod.rs +++ b/src/config/general/mod.rs @@ -1,10 +1,10 @@ pub mod app; -mod app_crude; -mod display_crude; -mod preview_crude; -mod sort_crude; -mod tab_crude; +mod app_raw; +mod display_raw; +mod preview_raw; +mod sort_raw; +mod tab_raw; pub use self::app::AppConfig; diff --git a/src/config/general/preview_crude.rs b/src/config/general/preview_raw.rs index 6a5b4ff..6fb4e05 100644 --- a/src/config/general/preview_crude.rs +++ b/src/config/general/preview_raw.rs @@ -12,7 +12,7 @@ pub const fn default_max_preview_size() -> u64 { } #[derive(Clone, Debug, Deserialize)] -pub struct PreviewOptionCrude { +pub struct PreviewOptionRaw { #[serde(default = "default_max_preview_size")] pub max_preview_size: u64, #[serde(default)] @@ -23,7 +23,7 @@ pub struct PreviewOptionCrude { pub preview_removed_hook_script: Option<String>, } -impl std::default::Default for PreviewOptionCrude { +impl std::default::Default for PreviewOptionRaw { fn default() -> Self { Self { max_preview_size: default_max_preview_size(), @@ -34,9 +34,9 @@ impl std::default::Default for PreviewOptionCrude { } } -impl From<PreviewOptionCrude> for PreviewOption { - fn from(crude: PreviewOptionCrude) -> Self { - let preview_script = match crude.preview_script { +impl From<PreviewOptionRaw> for PreviewOption { + fn from(raw: PreviewOptionRaw) -> Self { + let preview_script = match raw.preview_script { Some(s) => { let tilde_cow = shellexpand::tilde_with_context(s.as_str(), dirs_next::home_dir); let tilde_path = path::PathBuf::from(tilde_cow.as_ref()); @@ -44,7 +44,7 @@ impl From<PreviewOptionCrude> for PreviewOption { } None => search_directories("preview.sh", &CONFIG_HIERARCHY), }; - let preview_shown_hook_script = match crude.preview_shown_hook_script { + let preview_shown_hook_script = match raw.preview_shown_hook_script { Some(s) => { let tilde_cow = shellexpand::tilde_with_context(s.as_str(), dirs_next::home_dir); let tilde_path = path::PathBuf::from(tilde_cow.as_ref()); @@ -52,7 +52,7 @@ impl From<PreviewOptionCrude> for PreviewOption { } None => None, }; - let preview_removed_hook_script = match crude.preview_removed_hook_script { + let preview_removed_hook_script = match raw.preview_removed_hook_script { Some(s) => { let tilde_cow = shellexpand::tilde_with_context(s.as_str(), dirs_next::home_dir); let tilde_path = path::PathBuf::from(tilde_cow.as_ref()); @@ -62,7 +62,7 @@ impl From<PreviewOptionCrude> for PreviewOption { }; Self { - max_preview_size: crude.max_preview_size, + max_preview_size: raw.max_preview_size, preview_script, preview_shown_hook_script, preview_removed_hook_script, diff --git a/src/config/general/sort_crude.rs b/src/config/general/sort_raw.rs index f7a1836..a75a9a5 100644 --- a/src/config/general/sort_crude.rs +++ b/src/config/general/sort_raw.rs @@ -9,7 +9,7 @@ const fn default_true() -> bool { } #[derive(Clone, Debug, Deserialize)] -pub struct SortOptionCrude { +pub struct SortOptionRaw { #[serde(default = "default_true")] pub directories_first: bool, #[serde(default)] @@ -20,7 +20,7 @@ pub struct SortOptionCrude { pub sort_method: Option<String>, } -impl std::default::Default for SortOptionCrude { +impl std::default::Default for SortOptionRaw { fn default() -> Self { Self { directories_first: default_true(), @@ -31,9 +31,9 @@ impl std::default::Default for SortOptionCrude { } } -impl From<SortOptionCrude> for SortOption { - fn from(crude: SortOptionCrude) -> Self { - let sort_method = match crude.sort_method.as_ref() { +impl From<SortOptionRaw> for SortOption { + fn from(raw: SortOptionRaw) -> Self { + let sort_method = match raw.sort_method.as_ref() { Some(s) => SortType::parse(s).unwrap_or(SortType::Natural), None => SortType::Natural, }; @@ -42,9 +42,9 @@ impl From<SortOptionCrude> for SortOption { sort_methods.reorganize(sort_method); Self { - directories_first: crude.directories_first, - case_sensitive: crude.case_sensitive, - reverse: crude.reverse, + directories_first: raw.directories_first, + case_sensitive: raw.case_sensitive, + reverse: raw.reverse, sort_methods, } } diff --git a/src/config/general/tab_crude.rs b/src/config/general/tab_raw.rs index 2a8f8f3..193c30d 100644 --- a/src/config/general/tab_crude.rs +++ b/src/config/general/tab_raw.rs @@ -10,12 +10,12 @@ fn default_home_page() -> String { } #[derive(Clone, Debug, Deserialize)] -pub struct TabOptionCrude { +pub struct TabOptionRaw { #[serde(default = "default_home_page")] pub home_page: String, } -impl std::default::Default for TabOptionCrude { +impl std::default::Default for TabOptionRaw { fn default() -> Self { Self { home_page: default_home_page(), @@ -23,9 +23,9 @@ impl std::default::Default for TabOptionCrude { } } -impl From<TabOptionCrude> for TabOption { - fn from(crude: TabOptionCrude) -> Self { - let home_page = match crude.home_page.as_str() { +impl From<TabOptionRaw> for TabOption { + fn from(raw: TabOptionRaw) -> Self { + let home_page = match raw.home_page.as_str() { "inherit" => TabHomePage::Inherit, "home" => TabHomePage::Home, "root" => TabHomePage::Root, diff --git a/src/config/theme/app_theme.rs b/src/config/theme/app_theme.rs index 5609db9..651b2fd 100644 --- a/src/config/theme/app_theme.rs +++ b/src/config/theme/app_theme.rs @@ -2,32 +2,32 @@ use serde_derive::Deserialize; use std::collections::HashMap; use super::DEFAULT_CONFIG_FILE_PATH; -use super::{AppStyle, RawAppStyle}; +use super::{AppStyle, AppStyleRaw}; use crate::config::{parse_to_config_file, TomlConfigFile}; use crate::error::JoshutoResult; #[derive(Clone, Debug, Deserialize, Default)] -pub struct AppThemeCrude { +pub struct AppThemeRaw { #[serde(default)] - pub regular: RawAppStyle, + pub regular: AppStyleRaw, #[serde(default)] - pub selection: RawAppStyle, + pub selection: AppStyleRaw, #[serde(default)] - pub directory: RawAppStyle, + pub directory: AppStyleRaw, #[serde(default)] - pub executable: RawAppStyle, + pub executable: AppStyleRaw, #[serde(default)] - pub link: RawAppStyle, + pub link: AppStyleRaw, #[serde(default)] - pub link_invalid: RawAppStyle, + pub link_invalid: AppStyleRaw, #[serde(default)] - pub socket: RawAppStyle, + pub socket: AppStyleRaw, #[serde(default)] - pub ext: HashMap<String, RawAppStyle>, + pub ext: HashMap<String, AppStyleRaw>, } -impl From<AppThemeCrude> for AppTheme { - fn from(crude: AppThemeCrude) -> Self { +impl From<AppThemeRaw> for AppTheme { + fn from(crude: AppThemeRaw) -> Self { let selection = crude.selection.to_style_theme(); let executable = crude.executable.to_style_theme(); let regular = crude.regular.to_style_theme(); @@ -71,14 +71,14 @@ pub struct AppTheme { impl AppTheme { pub fn default_res() -> JoshutoResult<Self> { - let crude: AppThemeCrude = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?; + let crude: AppThemeRaw = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?; Ok(Self::from(crude)) } } impl TomlConfigFile for AppTheme { fn get_config(file_name: &str) -> Self { - parse_to_config_file::<AppThemeCrude, AppTheme>(file_name).unwrap_or_default() + parse_to_config_file::<AppThemeRaw, AppTheme>(file_name).unwrap_or_default() } } diff --git a/src/config/theme/mod.rs b/src/config/theme/mod.rs index 7a44897..41dc0e2 100644 --- a/src/config/theme/mod.rs +++ b/src/config/theme/mod.rs @@ -1,8 +1,8 @@ mod app_theme; mod style; -pub use self::app_theme::AppTheme; -pub use self::style::{AppStyle, RawAppStyle}; +pub use self::app_theme::*; +pub use self::style::*; #[cfg(not(target_os = "windows"))] const DEFAULT_CONFIG_FILE_PATH: &str = include_str!("../../../config/theme.toml"); diff --git a/src/config/theme/style.rs b/src/config/theme/style.rs index 265a4f2..5fecdf8 100644 --- a/src/config/theme/style.rs +++ b/src/config/theme/style.rs @@ -9,7 +9,7 @@ const fn default_color() -> style::Color { } #[derive(Clone, Debug, Deserialize)] -pub struct RawAppStyle { +pub struct AppStyleRaw { #[serde(default)] pub fg: String, #[serde(default)] @@ -22,7 +22,7 @@ pub struct RawAppStyle { pub invert: bool, } -impl RawAppStyle { +impl AppStyleRaw { pub fn to_style_theme(&self) -> AppStyle { let bg = Self::str_to_color(self.bg.as_str()); let fg = Self::str_to_color(self.fg.as_str()); @@ -84,7 +84,7 @@ impl RawAppStyle { } } -impl std::default::Default for RawAppStyle { +impl std::default::Default for AppStyleRaw { fn default() -> Self { Self { bg: "".to_string(), |