diff options
-rw-r--r-- | config/keymap.toml | 2 | ||||
-rw-r--r-- | src/commands/commands.rs | 4 | ||||
-rw-r--r-- | src/config/keymap/keymapping.rs | 2 | ||||
-rw-r--r-- | src/error.rs | 10 | ||||
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 3 | ||||
-rw-r--r-- | src/util/format.rs | 6 |
6 files changed, 10 insertions, 17 deletions
diff --git a/config/keymap.toml b/config/keymap.toml index c631023..17900bf 100644 --- a/config/keymap.toml +++ b/config/keymap.toml @@ -21,7 +21,7 @@ keys = [ "q" ] command = "force_quit" keys = [ "Q" ] [[mapcommand]] -command = "reload_dir_list" +command = "reload_dirlist" keys = [ "R" ] [[mapcommand]] command = "toggle_hidden" diff --git a/src/commands/commands.rs b/src/commands/commands.rs index 6e005ad..02cd181 100644 --- a/src/commands/commands.rs +++ b/src/commands/commands.rs @@ -71,7 +71,7 @@ pub enum KeyCommand { } impl KeyCommand { - pub fn command(&self) -> &'static str { + pub const fn command(&self) -> &'static str { match self { Self::BulkRename => "bulk_rename", Self::ChangeDirectory(_) => "cd", @@ -235,7 +235,7 @@ impl KeyCommand { Ok(Self::PasteFiles(options)) } "quit" => Ok(Self::Quit), - "reload_dir_list" => Ok(Self::ReloadDirList), + "reload_dirlist" => Ok(Self::ReloadDirList), "rename" => match arg { "" => Err(JoshutoError::new( JoshutoErrorKind::IoInvalidData, diff --git a/src/config/keymap/keymapping.rs b/src/config/keymap/keymapping.rs index c3f6ee1..3b8313f 100644 --- a/src/config/keymap/keymapping.rs +++ b/src/config/keymap/keymapping.rs @@ -46,7 +46,7 @@ impl Flattenable<AppKeyMapping> for RawAppKeyMapping { Err(e) => eprintln!("{}", e), } } - Err(e) => eprintln!("{}", e.cause()), + Err(e) => eprintln!("{}", e), } } keymaps diff --git a/src/error.rs b/src/error.rs index 68e5d6a..bb2a360 100644 --- a/src/error.rs +++ b/src/error.rs @@ -72,15 +72,11 @@ impl JoshutoError { pub fn kind(&self) -> JoshutoErrorKind { self._kind } - - pub fn cause(&self) -> &str { - self._cause.as_str() - } } -impl std::string::ToString for JoshutoError { - fn to_string(&self) -> String { - self._cause.clone() +impl std::fmt::Display for JoshutoError { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self._cause) } } diff --git a/src/ui/widgets/tui_footer.rs b/src/ui/widgets/tui_footer.rs index aa7a821..baf2262 100644 --- a/src/ui/widgets/tui_footer.rs +++ b/src/ui/widgets/tui_footer.rs @@ -6,6 +6,7 @@ use tui::widgets::{Paragraph, Widget}; use crate::fs::{FileType, JoshutoDirList}; use crate::util::format; +use crate::util::unix; pub struct TuiFooter<'a> { dirlist: &'a JoshutoDirList, @@ -25,7 +26,7 @@ impl<'a> Widget for TuiFooter<'a> { let entry = &self.dirlist.contents[i]; let mode_style = Style::default().fg(Color::Cyan); - let mode_str = format::mode_to_string(entry.metadata.permissions_ref().mode()); + let mode_str = unix::mode_to_string(entry.metadata.permissions_ref().mode()); let mtime_str = format::mtime_to_string(entry.metadata.modified()); let size_str = format::file_size_to_string(entry.metadata.len()); diff --git a/src/util/format.rs b/src/util/format.rs index e7231df..b22d200 100644 --- a/src/util/format.rs +++ b/src/util/format.rs @@ -1,6 +1,6 @@ use std::time; -use super::unix; +use crate::util::unix; pub fn file_size_to_string(file_size: u64) -> String { const FILE_UNITS: [&str; 6] = ["B", "K", "M", "G", "T", "E"]; @@ -22,10 +22,6 @@ pub fn file_size_to_string(file_size: u64) -> String { } } -pub fn mode_to_string(mode: u32) -> String { - unix::mode_to_string(mode) -} - pub fn mtime_to_string(mtime: time::SystemTime) -> String { const MTIME_FORMATTING: &str = "%Y-%m-%d %H:%M"; |