diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-04 15:14:13 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-04 15:14:13 -0400 |
commit | fd4bd6f79ec8051c91f69543fc20d5e8d6607f13 (patch) | |
tree | dda624a98d9aec467f2b7a11375b682e38739169 /src | |
parent | a521ceb379c34c854fb4e9848c0bcb7d28b46f4f (diff) |
cargo fmt
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/mod.rs | 4 | ||||
-rw-r--r-- | src/commands/reload_dir.rs | 5 | ||||
-rw-r--r-- | src/preview.rs | 14 | ||||
-rw-r--r-- | src/structs/entry.rs | 17 | ||||
-rw-r--r-- | src/tab.rs | 9 | ||||
-rw-r--r-- | src/ui.rs | 10 |
6 files changed, 36 insertions, 23 deletions
diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 8e98072..e8d165f 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -38,9 +38,9 @@ pub use self::show_hidden::ToggleHiddenFiles; pub use self::tab_operations::{CloseTab, NewTab}; pub use self::tab_switch::TabSwitch; -use std::collections::HashMap; use std::path::PathBuf; +use crate::config::JoshutoCommandMapping; use crate::context::JoshutoContext; use crate::error::{JoshutoError, KeymapError}; use crate::window::JoshutoView; @@ -50,7 +50,7 @@ use crate::HOME_DIR; #[derive(Debug)] pub enum CommandKeybind { SimpleKeybind(Box<JoshutoCommand>), - CompositeKeybind(HashMap<i32, CommandKeybind>), + CompositeKeybind(JoshutoCommandMapping), } pub trait JoshutoRunnable { diff --git a/src/commands/reload_dir.rs b/src/commands/reload_dir.rs index df8e9d9..eb13d34 100644 --- a/src/commands/reload_dir.rs +++ b/src/commands/reload_dir.rs @@ -17,10 +17,7 @@ impl ReloadDirList { "reload_dir_list" } - pub fn reload( - index: usize, - context: &mut JoshutoContext - ) -> Result<(), std::io::Error> { + pub fn reload(index: usize, context: &mut JoshutoContext) -> Result<(), std::io::Error> { let curr_tab = &mut context.tabs[index]; let sort_option = &context.config_t.sort_option; curr_tab.curr_list.update_contents(sort_option)?; diff --git a/src/preview.rs b/src/preview.rs index 2c65e95..982dcf8 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -45,11 +45,21 @@ fn preview_directory( ) { match history.entry(path.to_path_buf().clone()) { Entry::Occupied(mut entry) => { - ui::display_contents(win, entry.get_mut(), config_t, &ui::SECONDARY_DISPLAY_OPTION); + ui::display_contents( + win, + entry.get_mut(), + config_t, + &ui::SECONDARY_DISPLAY_OPTION, + ); } Entry::Vacant(entry) => { if let Ok(s) = JoshutoDirList::new(path.to_path_buf().clone(), &config_t.sort_option) { - ui::display_contents(win, entry.insert(s), config_t, &ui::SECONDARY_DISPLAY_OPTION); + ui::display_contents( + win, + entry.insert(s), + config_t, + &ui::SECONDARY_DISPLAY_OPTION, + ); } } } diff --git a/src/structs/entry.rs b/src/structs/entry.rs index 8c52731..86c7209 100644 --- a/src/structs/entry.rs +++ b/src/structs/entry.rs @@ -15,10 +15,12 @@ impl JoshutoDirEntry { pub fn from(direntry: &fs::DirEntry) -> Result<Self, io::Error> { let file_name = match direntry.file_name().into_string() { Ok(s) => s, - Err(e) => return Err(std::io::Error::new( - std::io::ErrorKind::Other, - "Failed converting OsString to String", - )), + Err(_) => { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + "Failed converting OsString to String", + )) + } }; let path = direntry.path(); @@ -37,7 +39,10 @@ impl JoshutoDirEntry { impl std::fmt::Debug for JoshutoDirEntry { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { - write!(f, "JoshutoDirEntry {{\n\tfile_name: {:?}, \n\tpath: {:?} \n}}", - self.file_name, self.path) + write!( + f, + "JoshutoDirEntry {{\n\tfile_name: {:?}, \n\tpath: {:?} \n}}", + self.file_name, self.path + ) } } @@ -1,12 +1,12 @@ use std::path::PathBuf; -use crate::JoshutoConfig; use crate::history::{DirectoryHistory, JoshutoHistory}; use crate::preview; use crate::sort; use crate::structs::JoshutoDirList; use crate::ui; use crate::window::{JoshutoPanel, JoshutoView}; +use crate::JoshutoConfig; use crate::{HOSTNAME, USERNAME}; @@ -44,7 +44,12 @@ impl JoshutoTab { } pub fn refresh_curr(&mut self, win: &JoshutoPanel, config_t: &JoshutoConfig) { - ui::display_contents(win, &mut self.curr_list, config_t, &ui::PRIMARY_DISPLAY_OPTION); + ui::display_contents( + win, + &mut self.curr_list, + config_t, + &ui::PRIMARY_DISPLAY_OPTION, + ); } pub fn refresh_parent(&mut self, win: &JoshutoPanel, config_t: &JoshutoConfig) { @@ -206,12 +206,9 @@ pub fn display_contents( }; let curr_index = dirlist.index.unwrap(); - dirlist.pagestate.update_page_state( - curr_index, - win.rows, - dir_len, - config_t.scroll_offset, - ); + dirlist + .pagestate + .update_page_state(curr_index, win.rows, dir_len, config_t.scroll_offset); let (start, end) = (dirlist.pagestate.start, dirlist.pagestate.end); let dir_contents = &dirlist.contents[start..end]; @@ -224,7 +221,6 @@ pub fn display_contents( ncurses::wmove(win.win, coord.0, coord.1); - let mut attr: ncurses::attr_t = 0; let attr = if i + start == curr_index { ncurses::A_STANDOUT() } else { |