summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/browser/browser_state.rs1
-rw-r--r--src/command/event.rs32
-rw-r--r--src/verb/internal.rs11
3 files changed, 43 insertions, 1 deletions
diff --git a/src/browser/browser_state.rs b/src/browser/browser_state.rs
index dea0b5b..9fedacd 100644
--- a/src/browser/browser_state.rs
+++ b/src/browser/browser_state.rs
@@ -593,6 +593,7 @@ impl AppState for BrowserState {
}
}
Internal::quit => AppStateCmdResult::Quit,
+ _ => AppStateCmdResult::Keep,
})
}
diff --git a/src/command/event.rs b/src/command/event.rs
index b431d89..7a5bbbe 100644
--- a/src/command/event.rs
+++ b/src/command/event.rs
@@ -9,7 +9,7 @@ use {
errors::ProgramError,
keys,
skin::PanelSkin,
- verb::Internal,
+ verb::{Internal, Verb, VerbExecution},
},
termimad::{Area, Event, InputField},
};
@@ -69,6 +69,33 @@ impl PanelInput {
Ok(cmd)
}
+ /// check whether the verb is an action on the input (like
+ /// deleting a word) and if it's the case, applies it and
+ /// return true
+ fn handle_input_related_verb(
+ &mut self,
+ verb: &Verb,
+ _con: &AppContext,
+ ) -> bool {
+ if let VerbExecution::Internal(internal_exec) = &verb.execution {
+ match internal_exec.internal {
+ Internal::input_del_char_left => self.input_field.del_char_left(),
+ Internal::input_del_char_below => self.input_field.del_char_below(),
+ Internal::input_del_word_left => self.input_field.del_word_left(),
+ Internal::input_del_word_right => self.input_field.del_word_right(),
+ Internal::input_go_left => self.input_field.move_left(),
+ Internal::input_go_right => self.input_field.move_right(),
+ Internal::input_go_word_left => self.input_field.move_word_left(),
+ Internal::input_go_word_right => self.input_field.move_word_right(),
+ Internal::input_go_to_start => self.input_field.move_to_start(),
+ Internal::input_go_to_end => self.input_field.move_to_end(),
+ _ => false,
+ }
+ } else {
+ false
+ }
+ }
+
/// consume the event to
/// - maybe change the input
/// - build a command
@@ -177,6 +204,9 @@ impl PanelInput {
for (index, verb) in con.verb_store.verbs.iter().enumerate() {
for verb_key in &verb.keys {
if *verb_key == key {
+ if self.handle_input_related_verb(verb, con) {
+ return Command::from_raw(self.input_field.get_content(), false);
+ }
if selection_type.respects(verb.selection_condition) {
return Command::VerbTrigger {
index,
diff --git a/src/verb/internal.rs b/src/verb/internal.rs
index e9cc3ae..58a9b30 100644
--- a/src/verb/internal.rs
+++ b/src/verb/internal.rs
@@ -51,12 +51,23 @@ macro_rules! Internals {
}
}
+
Internals! {
back: "revert to the previous state (mapped to *esc*)",
close_panel_ok: "close the panel, validating the selected path",
close_panel_cancel: "close the panel, not using the selected path",
focus: "display the directory (mapped to *enter*)",
help: "display broot's help",
+ input_del_char_left: "delete the char left of the cursor",
+ input_del_char_below: "delete the char left at the cursor's position",
+ input_del_word_left: "delete the word left of the cursor",
+ input_del_word_right: "delete the word right of the cursor",
+ input_go_to_end: "move the cursor to the end of input",
+ input_go_left: "move the cursor to the left",
+ input_go_right: "move the cursor to the right",
+ input_go_to_start: "move the cursor to the start of input",
+ input_go_word_left: "move the cursor one word to the left",
+ input_go_word_right: "move the cursor one word to the right",
line_down: "move one line down",
line_up: "move one line up",
open_stay: "open file or directory according to OS (stay in broot)",