diff options
author | qkzk <qu3nt1n@gmail.com> | 2022-12-11 13:51:06 +0100 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2022-12-11 13:51:06 +0100 |
commit | 935f4cfe47e4670aa23aad10ebbad788ce292432 (patch) | |
tree | 2dd6ab4228e90f7643467a381e75a99d0a3a0c8e /src/actioner.rs | |
parent | ba3c218ac7aa99177fe6fcbca878d72667161605 (diff) |
move all event to event exec
Diffstat (limited to 'src/actioner.rs')
-rw-r--r-- | src/actioner.rs | 175 |
1 files changed, 18 insertions, 157 deletions
diff --git a/src/actioner.rs b/src/actioner.rs index 002be24..3ca019d 100644 --- a/src/actioner.rs +++ b/src/actioner.rs @@ -68,117 +68,33 @@ impl Actioner { /// Move one line up fn up(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal | Mode::Preview | Mode::Help => { - EventExec::event_up_one_row(status.selected()) - } - Mode::Jump => EventExec::event_jumplist_prev(status), - Mode::History => EventExec::event_history_prev(status.selected()), - Mode::Shortcut => EventExec::event_shortcut_prev(status.selected()), - Mode::Goto | Mode::Exec | Mode::Search => { - status.selected().completion.prev(); - } - _ => (), - }; - Ok(()) + EventExec::event_move_up(status) } /// Move one line down fn down(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal | Mode::Preview | Mode::Help => { - EventExec::event_down_one_row(status.selected()) - } - Mode::Jump => EventExec::event_jumplist_next(status), - Mode::History => EventExec::event_history_next(status.selected()), - Mode::Shortcut => EventExec::event_shortcut_next(status.selected()), - Mode::Goto | Mode::Exec | Mode::Search => { - status.selected().completion.next(); - } - _ => (), - }; - Ok(()) + EventExec::event_move_down(status) } /// Move left in a string, move to parent in normal mode fn left(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal => EventExec::event_move_to_parent(status.selected()), - Mode::Rename - | Mode::Chmod - | Mode::Newdir - | Mode::Newfile - | Mode::Exec - | Mode::Search - | Mode::Goto - | Mode::RegexMatch - | Mode::Filter => { - EventExec::event_move_cursor_left(status.selected()); - Ok(()) - } - - _ => Ok(()), - } + EventExec::event_move_left(status) } /// Move right in a string, move to children in normal mode. fn right(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal => EventExec::exec_file(status.selected()), - Mode::Rename - | Mode::Chmod - | Mode::Newdir - | Mode::Newfile - | Mode::Exec - | Mode::Search - | Mode::Goto - | Mode::RegexMatch - | Mode::Filter => { - EventExec::event_move_cursor_right(status.selected()); - Ok(()) - } - _ => Ok(()), - } + EventExec::event_move_right(status) } /// Deletes a char in input string fn backspace(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Rename - | Mode::Newdir - | Mode::Chmod - | Mode::Newfile - | Mode::Exec - | Mode::Search - | Mode::Goto - | Mode::RegexMatch - | Mode::Filter => { - EventExec::event_delete_char_left(status.selected()); - Ok(()) - } - Mode::Normal => Ok(()), - _ => Ok(()), - } + EventExec::event_backspace(status) } /// Deletes chars right of cursor in input string. /// Remove current tab in normal mode. fn delete(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Rename - | Mode::Newdir - | Mode::Chmod - | Mode::Newfile - | Mode::Exec - | Mode::Search - | Mode::Goto - | Mode::RegexMatch - | Mode::Filter => { - EventExec::event_delete_chars_right(status.selected()); - Ok(()) - } - _ => Ok(()), - } + EventExec::event_delete(status) } /// Move to top or beggining of line. @@ -192,59 +108,22 @@ impl Actioner { /// Move to end or end of line. fn end(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal | Mode::Preview | Mode::Help => { - EventExec::event_go_bottom(status.selected()) - } - _ => EventExec::event_cursor_end(status.selected()), - }; - Ok(()) + EventExec::event_end(status) } /// Move down 10 rows fn page_down(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal | Mode::Preview | Mode::Help => { - EventExec::event_page_down(status.selected()) - } - _ => (), - }; - Ok(()) + EventExec::page_down(status) } /// Move up 10 rows fn page_up(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Normal | Mode::Preview | Mode::Help => { - EventExec::event_page_up(status.selected()) - } - _ => (), - }; - Ok(()) + EventExec::page_up(status) } /// Execute a command fn enter(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Rename => EventExec::exec_rename(status.selected())?, - Mode::Newfile => EventExec::exec_newfile(status.selected())?, - Mode::Newdir => EventExec::exec_newdir(status.selected())?, - Mode::Chmod => EventExec::exec_chmod(status)?, - Mode::Exec => EventExec::exec_exec(status.selected())?, - Mode::Search => EventExec::exec_search(status.selected()), - Mode::Goto => EventExec::exec_goto(status.selected())?, - Mode::RegexMatch => EventExec::exec_regex(status)?, - Mode::Jump => EventExec::exec_jump(status)?, - Mode::History => EventExec::exec_history(status.selected())?, - Mode::Shortcut => EventExec::exec_shortcut(status.selected())?, - Mode::Filter => EventExec::exec_filter(status.selected())?, - Mode::Normal => EventExec::exec_file(status.selected())?, - Mode::NeedConfirmation | Mode::Help | Mode::Sort | Mode::Preview | Mode::Marks(_) => (), - }; - - status.selected().input.reset(); - status.selected().mode = Mode::Normal; - Ok(()) + EventExec::enter(status) } /// Select this file @@ -264,54 +143,36 @@ impl Actioner { /// Select next completion and insert it /// Select next tab fn tab(status: &mut Status) -> FmResult<()> { - match status.selected().mode { - Mode::Goto | Mode::Exec | Mode::Search => { - EventExec::event_replace_input_with_completion(status.selected()) - } - Mode::Normal => status.next(), - _ => (), - }; - Ok(()) + EventExec::tab(status) } /// Select previous tab fn backtab(status: &mut Status) -> FmResult<()> { - if let Mode::Normal = status.selected().mode { - status.prev() - } - Ok(()) + EventExec::backtab(status) } fn ctrl_f(status: &mut Status) -> FmResult<()> { - status.create_tabs_from_skim()?; - Ok(()) + EventExec::ctrl_f(status) } fn ctrl_c(status: &mut Status) -> FmResult<()> { - if let Mode::Normal = status.selected_non_mut().mode { - return EventExec::event_filename_to_clipboard(status.selected()); - } - Ok(()) + EventExec::ctrl_c(status) } fn ctrl_p(status: &mut Status) -> FmResult<()> { - if let Mode::Normal = status.selected_non_mut().mode { - return EventExec::event_filepath_to_clipboard(status.selected()); - } - Ok(()) + EventExec::ctrl_p(status) } fn ctrl_r(status: &mut Status) -> FmResult<()> { - EventExec::refresh_selected_view(status) + EventExec::ctrl_r(status) } fn ctrl_x(status: &mut Status) -> FmResult<()> { - EventExec::event_decompress(status.selected()) + EventExec::ctrl_x(status) } fn ctrl_e(status: &mut Status) -> FmResult<()> { - status.display_full = !status.display_full; - Ok(()) + EventExec::ctrl_e(status) } /// Match read key to a relevent event, depending on keybindings. |