diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-07-19 21:33:08 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-07-19 22:18:23 -0400 |
commit | 0b8747eb37d6d943d90e15ed82858d99d1800425 (patch) | |
tree | 6cb910dc37343000296c2951e0f67ff269ee3efd /src/commands/rename_file.rs | |
parent | 98e9665e59d7af0b2c002f0e6007578b3e90aa69 (diff) |
changed how commands are handled
- arguments no longer go through wordexp (still working on a good alternative)
other changes:
- changed update_contents to reload_contents
- opening files with mimetype entries are now moved from unix.rs
to mimetypes.rs
Diffstat (limited to 'src/commands/rename_file.rs')
-rw-r--r-- | src/commands/rename_file.rs | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 02eadfb..4686b2f 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -5,16 +5,6 @@ use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::window::JoshutoView; -use rustyline::completion::{escape, Quote}; - -#[cfg(unix)] -static DEFAULT_BREAK_CHARS: [u8; 18] = [ - b' ', b'\t', b'\n', b'"', b'\\', b'\'', b'`', b'@', b'$', b'>', b'<', b'=', b';', b'|', b'&', - b'{', b'(', b'\0', -]; -#[cfg(unix)] -static ESCAPE_CHAR: Option<char> = Some('\\'); - #[derive(Clone, Debug)] pub struct RenameFile { path: path::PathBuf, @@ -44,7 +34,7 @@ impl RenameFile { let curr_tab = &mut context.tabs[context.curr_tab_index]; curr_tab .curr_list - .update_contents(&context.config_t.sort_option)?; + .reload_contents(&context.config_t.sort_option)?; curr_tab.refresh_curr(&view.mid_win, &context.config_t); curr_tab.refresh_preview(&view.right_win, &context.config_t); Ok(()) @@ -119,18 +109,9 @@ impl std::fmt::Display for RenameFileAppend { impl JoshutoRunnable for RenameFileAppend { fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { let curr_list = &context.tabs[context.curr_tab_index].curr_list; - let file_name = match curr_list.get_curr_ref() { - Some(s) => { - let escaped = escape( - String::from(s.file_name()), - ESCAPE_CHAR, - &DEFAULT_BREAK_CHARS, - Quote::None, - ); - Some(escaped) - } - None => None, - }; + let file_name = curr_list + .get_curr_ref() + .and_then(|s| Some(String::from(s.file_name()))); if let Some(file_name) = file_name { self.rename_file(context, view, file_name)?; @@ -176,18 +157,9 @@ impl std::fmt::Display for RenameFilePrepend { impl JoshutoRunnable for RenameFilePrepend { fn execute(&self, context: &mut JoshutoContext, view: &JoshutoView) -> JoshutoResult<()> { let curr_list = &context.tabs[context.curr_tab_index].curr_list; - let file_name = match curr_list.get_curr_ref() { - Some(s) => { - let escaped = escape( - String::from(s.file_name()), - ESCAPE_CHAR, - &DEFAULT_BREAK_CHARS, - Quote::None, - ); - Some(escaped) - } - None => None, - }; + let file_name = curr_list + .get_curr_ref() + .and_then(|s| Some(String::from(s.file_name()))); if let Some(file_name) = file_name { self.rename_file(context, view, file_name)?; |