diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/change_directory.rs | 1 | ||||
-rw-r--r-- | src/commands/open_file.rs | 2 | ||||
-rw-r--r-- | src/commands/reload.rs | 2 | ||||
-rw-r--r-- | src/commands/tab_ops.rs | 1 | ||||
-rw-r--r-- | src/config/clean/app/config.rs | 4 | ||||
-rw-r--r-- | src/config/raw/app/config.rs | 2 | ||||
-rw-r--r-- | src/fs/dirlist.rs | 1 | ||||
-rw-r--r-- | src/fs/entry.rs | 8 | ||||
-rw-r--r-- | src/history.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/run.rs | 1 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist.rs | 14 | ||||
-rw-r--r-- | src/ui/widgets/tui_dirlist_detailed.rs | 8 | ||||
-rw-r--r-- | src/util/style.rs | 26 |
14 files changed, 38 insertions, 39 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index 6ac2575..ebf471f 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -30,7 +30,6 @@ pub fn change_directory(context: &mut AppContext, mut path: &path::Path) -> AppR cd(new_cwd.as_path(), context)?; let dirlists = generate_entries_to_root( new_cwd.as_path(), - context.config_ref(), context.tab_context_ref().curr_tab_ref().history_ref(), context.ui_context_ref(), context.config_ref().display_options_ref(), diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index fe057b0..0f4ab20 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -23,7 +23,7 @@ fn _get_options<'a>(path: &path::Path, config: &AppConfig) -> Vec<&'a ProgramEnt .extension() .and_then(|ext| ext.to_str()) .and_then(|ext| { - if config.case_sensitive_ext { + if config.case_insensitive_ext { MIMETYPE_T.app_list_for_ext(ext) } else { MIMETYPE_T.app_list_for_ext(&ext.to_lowercase()) diff --git a/src/commands/reload.rs b/src/commands/reload.rs index 4134272..d59d0cd 100644 --- a/src/commands/reload.rs +++ b/src/commands/reload.rs @@ -8,7 +8,6 @@ use uuid::Uuid; pub fn soft_reload(context: &mut AppContext, id: &Uuid) -> std::io::Result<()> { let mut dirlists = Vec::with_capacity(3); if let Some(curr_tab) = context.tab_context_ref().tab_ref(id) { - let config = context.config_ref(); let display_options = context.config_ref().display_options_ref(); let tab_options = context.tab_context_ref().curr_tab_ref().option_ref(); let history = curr_tab.history_ref(); @@ -50,7 +49,6 @@ pub fn soft_reload_curr_tab(context: &mut AppContext) -> std::io::Result<()> { pub fn reload(context: &mut AppContext, id: &Uuid) -> std::io::Result<()> { let mut dirlists = Vec::with_capacity(3); if let Some(curr_tab) = context.tab_context_ref().tab_ref(id) { - let config = context.config_ref(); let display_options = context.config_ref().display_options_ref(); let tab_options = context.tab_context_ref().curr_tab_ref().option_ref(); let history = curr_tab.history_ref(); diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs index f1adfe2..e519267 100644 --- a/src/commands/tab_ops.rs +++ b/src/commands/tab_ops.rs @@ -159,7 +159,6 @@ pub fn new_tab(context: &mut AppContext, mode: &NewTabMode) -> AppResult { .clone(); let dirlists = generate_entries_to_root( new_tab_path.as_path(), - context.config_ref(), &new_tab_history, context.ui_context_ref(), context.config_ref().display_options_ref(), diff --git a/src/config/clean/app/config.rs b/src/config/clean/app/config.rs index 11272a0..3d0be5a 100644 --- a/src/config/clean/app/config.rs +++ b/src/config/clean/app/config.rs @@ -18,7 +18,7 @@ pub struct AppConfig { pub use_trash: bool, pub xdg_open: bool, pub xdg_open_fork: bool, - pub case_sensitive_ext: bool, + pub case_insensitive_ext: bool, pub watch_files: bool, pub custom_commands: Vec<CustomCommand>, pub focus_on_create: bool, @@ -85,7 +85,7 @@ impl From<AppConfigRaw> for AppConfig { use_trash: raw.use_trash, xdg_open: raw.xdg_open, xdg_open_fork: raw.xdg_open_fork, - case_sensitive_ext: raw.case_sensitive_ext, + case_insensitive_ext: raw.case_insensitive_ext, watch_files: raw.watch_files, cmd_aliases: raw.cmd_aliases, focus_on_create: raw.focus_on_create, diff --git a/src/config/raw/app/config.rs b/src/config/raw/app/config.rs index 8c8b0ab..2980e4c 100644 --- a/src/config/raw/app/config.rs +++ b/src/config/raw/app/config.rs @@ -29,7 +29,7 @@ pub struct AppConfigRaw { #[serde(default)] pub xdg_open: bool, #[serde(default)] - pub case_sensitive_ext: bool, + pub case_insensitive_ext: bool, #[serde(default)] pub xdg_open_fork: bool, #[serde(default = "default_true")] diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs index de13440..30738f3 100644 --- a/src/fs/dirlist.rs +++ b/src/fs/dirlist.rs @@ -3,7 +3,6 @@ use std::{io, path}; use crate::config::clean::app::display::tab::TabDisplayOption; use crate::config::clean::app::display::DisplayOption; -use crate::config::clean::app::AppConfig; use crate::context::UiContext; use crate::fs::{JoshutoDirEntry, JoshutoMetadata}; use crate::history::read_directory; diff --git a/src/fs/entry.rs b/src/fs/entry.rs index 9a4b557..752d93d 100644 --- a/src/fs/entry.rs +++ b/src/fs/entry.rs @@ -1,12 +1,6 @@ use std::{fs, io, path}; -use crate::{ - config::clean::app::{display::DisplayOption, AppConfig}, - fs::{FileType, JoshutoMetadata}, -}; - -#[cfg(feature = "devicons")] -use crate::ICONS_T; +use crate::{config::clean::app::display::DisplayOption, fs::JoshutoMetadata}; #[derive(Clone, Debug)] pub struct JoshutoDirEntry { diff --git a/src/history.rs b/src/history.rs index 5302828..5a691d0 100644 --- a/src/history.rs +++ b/src/history.rs @@ -7,7 +7,6 @@ use walkdir::WalkDir; use crate::config::clean::app::display::dirlist::DirListDisplayOptions; use crate::config::clean::app::display::tab::TabDisplayOption; use crate::config::clean::app::display::DisplayOption; -use crate::config::clean::app::AppConfig; use crate::context::UiContext; use crate::fs::{JoshutoDirEntry, JoshutoDirList, JoshutoMetadata}; @@ -227,7 +226,6 @@ where pub fn generate_entries_to_root( path: &Path, - config: &AppConfig, history: &JoshutoHistory, ui_context: &UiContext, display_options: &DisplayOption, diff --git a/src/main.rs b/src/main.rs index cae9c55..7862bba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,8 +75,9 @@ lazy_static! { static ref ICONS_T: Icons = Icons::get_config(); static ref HOME_DIR: Option<PathBuf> = dirs_next::home_dir(); - static ref USERNAME: String = whoami::username(); - static ref HOSTNAME: String = whoami::hostname(); + + static ref USERNAME: String = whoami::fallible::realname().unwrap_or("No Username".to_string()); + static ref HOSTNAME: String = whoami::fallible::hostname().unwrap_or("No Hostname".to_string()); static ref TIMEZONE_STR: String = { let offset = chrono::Local::now().offset().local_minus_utc() / 3600; @@ -44,7 +44,6 @@ pub fn run_loop( .clone(); let dirlists = generate_entries_to_root( curr_path.as_path(), - context.config_ref(), &new_tab_history, context.ui_context_ref(), context.config_ref().display_options_ref(), diff --git a/src/ui/widgets/tui_dirlist.rs b/src/ui/widgets/tui_dirlist.rs index 3ee6917..6149474 100644 --- a/src/ui/widgets/tui_dirlist.rs +++ b/src/ui/widgets/tui_dirlist.rs @@ -56,11 +56,11 @@ impl<'a> Widget for TuiDirList<'a> { let ix = skip_dist + i; let style = if !self.focused { - style::entry_style(entry) + style::entry_style(self.config, entry) } else if ix == curr_index { - style::entry_style(entry).add_modifier(Modifier::REVERSED) + style::entry_style(self.config, entry).add_modifier(Modifier::REVERSED) } else { - style::entry_style(entry) + style::entry_style(self.config, entry) }; buf.set_string(x, y + i as u16, space_fill.as_str(), style); @@ -89,7 +89,7 @@ fn print_entry( #[cfg(feature = "devicons")] let (label, label_width) = { if config.display_options_ref().show_icons() { - let icon = get_entry_icon(&config, entry.file_name(), entry.ext(), &entry.metadata); + let icon = get_entry_icon(config, entry.file_name(), entry.ext(), &entry.metadata); let label = format!("{icon} {name}"); let label_width = label.width(); (label, label_width) @@ -135,10 +135,10 @@ pub fn get_entry_icon( .map(|s| s.as_str()) .unwrap_or_else(|| { ext.and_then(|ext| { - let ext: String = if config.case_sensitive_ext { - ext.to_owned() - } else { + let ext: String = if config.case_insensitive_ext { ext.to_lowercase() + } else { + ext.to_owned() }; ICONS_T.ext.get(&ext).map(|s| s.as_str()) }) diff --git a/src/ui/widgets/tui_dirlist_detailed.rs b/src/ui/widgets/tui_dirlist_detailed.rs index 0b203fe..7b31300 100644 --- a/src/ui/widgets/tui_dirlist_detailed.rs +++ b/src/ui/widgets/tui_dirlist_detailed.rs @@ -86,11 +86,11 @@ impl<'a> Widget for TuiDirListDetailed<'a> { let ix = skip_dist + i; let style = if !self.focused { - style::entry_style(entry) + style::entry_style(self.config, entry) } else if ix == curr_index { - style::entry_style(entry).add_modifier(Modifier::REVERSED) + style::entry_style(self.config, entry).add_modifier(Modifier::REVERSED) } else { - style::entry_style(entry) + style::entry_style(self.config, entry) }; buf.set_string(x, y + i as u16, space_fill.as_str(), style); @@ -156,7 +156,7 @@ fn print_entry( #[cfg(feature = "devicons")] let label = { if config.display_options_ref().show_icons() { - let icon = get_entry_icon(&config, entry.file_name(), entry.ext(), &entry.metadata); + let icon = get_entry_icon(config, entry.file_name(), entry.ext(), &entry.metadata); format!("{icon} {name}") } else { name.to_string() diff --git a/src/util/style.rs b/src/util/style.rs index de5a622..058a9a9 100644 --- a/src/util/style.rs +++ b/src/util/style.rs @@ -3,6 +3,7 @@ use lscolors::LsColors; use ratatui::style::Style; use std::path::Path; +use crate::config::clean::app::AppConfig; use crate::fs::{FileType, JoshutoDirEntry, LinkType}; use crate::util::unix; @@ -25,7 +26,7 @@ impl PathStyleIfSome for Style { } } -pub fn entry_style(entry: &JoshutoDirEntry) -> Style { +pub fn entry_style(config: &AppConfig, entry: &JoshutoDirEntry) -> Style { let metadata = &entry.metadata; let filetype = metadata.file_type(); let linktype = metadata.link_type(); @@ -41,9 +42,9 @@ pub fn entry_style(entry: &JoshutoDirEntry) -> Style { Some(lscolors) => { let path = entry.file_path(); lscolors_style(lscolors, path) - .unwrap_or_else(|| default_style(entry, linktype, filetype)) + .unwrap_or_else(|| default_style(config, entry, linktype, filetype)) } - None => default_style(entry, linktype, filetype), + None => default_style(config, entry, linktype, filetype), } } @@ -63,13 +64,18 @@ pub fn entry_prefix(entry: &JoshutoDirEntry) -> (&str, usize) { ("", 0) } -fn default_style(entry: &JoshutoDirEntry, linktype: &LinkType, filetype: &FileType) -> Style { +fn default_style( + config: &AppConfig, + entry: &JoshutoDirEntry, + linktype: &LinkType, + filetype: &FileType, +) -> Style { match linktype { LinkType::Symlink { valid: true, .. } => symlink_valid_style(), LinkType::Symlink { valid: false, .. } => symlink_invalid_style(), LinkType::Normal => match filetype { FileType::Directory => directory_style(), - FileType::File => file_style(entry), + FileType::File => file_style(config, entry), }, } } @@ -109,7 +115,7 @@ fn directory_style() -> Style { .add_modifier(THEME_T.directory.modifier) } -fn file_style(entry: &JoshutoDirEntry) -> Style { +fn file_style(config: &AppConfig, entry: &JoshutoDirEntry) -> Style { let regular_style = Style::default() .fg(THEME_T.regular.fg) .bg(THEME_T.regular.bg) @@ -123,7 +129,13 @@ fn file_style(entry: &JoshutoDirEntry) -> Style { } else { entry .ext() - .and_then(|s| THEME_T.ext.get(s)) + .and_then(|s| { + if config.case_insensitive_ext { + THEME_T.ext.get(&s.to_lowercase()) + } else { + THEME_T.ext.get(s) + } + }) .map(|theme| { Style::default() .fg(theme.fg) |