diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-12-11 21:07:13 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-12-11 21:07:13 -0500 |
commit | 916d72c42cfc7bcb8fc560e17cb3bd75c00757da (patch) | |
tree | a8024fc9bd9a48065cd6b65375109482ac9b7983 /src/commands | |
parent | bf9c102a4cfb85a9fd910195e6372dcd1d062c16 (diff) |
add a view for showing worker progress
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/key_command.rs | 4 | ||||
-rw-r--r-- | src/commands/mod.rs | 1 | ||||
-rw-r--r-- | src/commands/search.rs | 4 | ||||
-rw-r--r-- | src/commands/show_workers.rs | 14 | ||||
-rw-r--r-- | src/commands/tab_ops.rs | 2 |
5 files changed, 22 insertions, 3 deletions
diff --git a/src/commands/key_command.rs b/src/commands/key_command.rs index e5a2514..1c32470 100644 --- a/src/commands/key_command.rs +++ b/src/commands/key_command.rs @@ -51,6 +51,7 @@ pub enum KeyCommand { SelectFiles { toggle: bool, all: bool }, SetMode, ShellCommand(Vec<String>), + ShowWorkers, ToggleHiddenFiles, @@ -105,6 +106,7 @@ impl KeyCommand { Self::SelectFiles { toggle: _, all: _ } => "select", Self::SetMode => "set_mode", Self::ShellCommand(_) => "shell", + Self::ShowWorkers => "show_workers", Self::ToggleHiddenFiles => "toggle_hidden", @@ -263,6 +265,7 @@ impl KeyCommand { format!("{}: {}", arg, e), )), }, + "show_workers" => Ok(Self::ShowWorkers), "sort" => match arg { "reverse" => Ok(Self::SortReverse), arg => match SortType::parse(arg) { @@ -341,6 +344,7 @@ impl JoshutoRunnable for KeyCommand { Self::SelectFiles { toggle, all } => selection::select_files(context, *toggle, *all), Self::SetMode => set_mode::set_mode(context, backend), Self::ShellCommand(v) => shell::shell(context, backend, v.as_slice()), + Self::ShowWorkers => show_workers::show_workers(context, backend), Self::ToggleHiddenFiles => show_hidden::toggle_hidden(context), diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 18b7579..eba4b99 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -16,6 +16,7 @@ pub mod selection; pub mod set_mode; pub mod shell; pub mod show_hidden; +pub mod show_workers; pub mod sort; pub mod tab_ops; diff --git a/src/commands/search.rs b/src/commands/search.rs index eba9650..168153e 100644 --- a/src/commands/search.rs +++ b/src/commands/search.rs @@ -38,7 +38,7 @@ pub fn _search_rev(curr_tab: &JoshutoTab, pattern: &str) -> Option<usize> { pub fn search(context: &mut JoshutoContext, pattern: &str) -> JoshutoResult<()> { let index = _search(context.tab_context_ref().curr_tab_ref(), pattern); if let Some(index) = index { - cursor_move::cursor_move(index, context); + let _ = cursor_move::cursor_move(index, context); } context.set_search_state(pattern.to_string()); Ok(()) @@ -51,7 +51,7 @@ fn search_with_func( if let Some(s) = context.get_search_state() { let index = search_func(context.tab_context_ref().curr_tab_ref(), s); if let Some(index) = index { - cursor_move::cursor_move(index, context); + let _ = cursor_move::cursor_move(index, context); } } } diff --git a/src/commands/show_workers.rs b/src/commands/show_workers.rs new file mode 100644 index 0000000..04e6b84 --- /dev/null +++ b/src/commands/show_workers.rs @@ -0,0 +1,14 @@ +use crate::commands::KeyCommand; +use crate::context::JoshutoContext; +use crate::error::JoshutoResult; + +use crate::ui::views::TuiWorkerView; +use crate::ui::TuiBackend; + +use super::JoshutoRunnable; + +pub fn show_workers(context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { + let view = TuiWorkerView::new(); + view.display(context, backend); + Ok(()) +} diff --git a/src/commands/tab_ops.rs b/src/commands/tab_ops.rs index 4bf415e..a5789cf 100644 --- a/src/commands/tab_ops.rs +++ b/src/commands/tab_ops.rs @@ -20,7 +20,7 @@ fn _tab_switch(new_index: usize, context: &mut JoshutoContext) -> std::io::Resul .tab_context_mut() .curr_tab_mut() .history_mut() - .create_or_soft_update(path.as_path(), &options); + .create_or_soft_update(path.as_path(), &options)?; Ok(()) } |