summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Zhao <jeff.no.zhao@gmail.com>2021-04-30 21:25:57 -0400
committerJeff Zhao <jeff.no.zhao@gmail.com>2021-04-30 21:25:57 -0400
commit8eacec9b2392006bb90d14d5823be1829c021101 (patch)
tree8f01550ac5aff5f85fd918e3475af14dd67320da /src
parente17bf9d8cf283aaa02e2cee92331b593aba4b704 (diff)
fix reload_dir_list and reload_dirlist inconsistency
Diffstat (limited to 'src')
-rw-r--r--src/commands/commands.rs4
-rw-r--r--src/config/keymap/keymapping.rs2
-rw-r--r--src/error.rs10
-rw-r--r--src/ui/widgets/tui_footer.rs3
-rw-r--r--src/util/format.rs6
5 files changed, 9 insertions, 16 deletions
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";