diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-13 08:12:05 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-02-13 08:16:27 -0500 |
commit | 89b08eb9905db22a3e9751f44440d22e114277a3 (patch) | |
tree | b5b858192aabf020aea039061d607e171cc3fb7b /src/commands | |
parent | 6042557a5e88601cb37b6067a5fdb547f6aca232 (diff) |
textfield progression
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/change_directory.rs | 12 | ||||
-rw-r--r-- | src/commands/command_line.rs | 11 |
2 files changed, 11 insertions, 12 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index 48cf901..cd761c9 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -19,10 +19,7 @@ impl ChangeDirectory { "cd" } - pub fn cd( - path: &path::Path, - context: &mut JoshutoContext, - ) -> std::io::Result<()> { + pub fn cd(path: &path::Path, context: &mut JoshutoContext) -> std::io::Result<()> { std::env::set_current_dir(path)?; let curr_tab = &mut context.tabs[context.curr_tab_index]; @@ -31,14 +28,17 @@ impl ChangeDirectory { Ok(()) } - pub fn change_directories(path: &path::Path, + pub fn change_directories( + path: &path::Path, context: &mut JoshutoContext, backend: &mut TuiBackend, ) -> std::io::Result<()> { Self::cd(path, context)?; let curr_tab = &mut context.tabs[context.curr_tab_index]; - curr_tab.history.populate_to_root(&path, &context.config_t.sort_option)?; + curr_tab + .history + .populate_to_root(&path, &context.config_t.sort_option)?; Ok(()) } diff --git a/src/commands/command_line.rs b/src/commands/command_line.rs index 5f5b9db..4d3c820 100644 --- a/src/commands/command_line.rs +++ b/src/commands/command_line.rs @@ -2,7 +2,6 @@ use crate::commands::{self, JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::textfield::TextField; -use crate::ui; use crate::ui::TuiBackend; #[derive(Clone, Debug)] @@ -24,18 +23,18 @@ impl CommandLine { context: &mut JoshutoContext, backend: &mut TuiBackend, ) -> JoshutoResult<()> { - // let mut textfield = - let mut textfield = TextField::new(backend, &context.events); - let user_input: Option<String> = None; //textfield.readline(); + let mut textfield = TextField::new(backend, &context.events); + let user_input: Option<String> = textfield.readline(); if let Some(s) = user_input { let trimmed = s.trim_start(); match trimmed.find(' ') { Some(ind) => { - let (command, xs) = trimmed.split_at(ind); + let (cmd, xs) = trimmed.split_at(ind); let xs = xs.trim_start(); let args: Vec<String> = vec![String::from(xs)]; - commands::from_args(String::from(command), args)?.execute(context, backend) + let command = commands::from_args(cmd.to_string(), args)?; + command.execute(context, backend) } None => commands::from_args(String::from(trimmed), Vec::new())? .execute(context, backend), |