Skip to content

Commit

Permalink
Issue 740 (#751)
Browse files Browse the repository at this point in the history
Allow rebinding the `esc` and `tab` keys, using the `:escape` and `:next_match` internals.

Fix #740
  • Loading branch information
Canop authored Sep 26, 2023
1 parent 6613a4a commit a898f33
Show file tree
Hide file tree
Showing 14 changed files with 763 additions and 664 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### next
- fix fuzzy patterns not case insensitive on some characters - Fix #746
- when given a path to a file at launch, broot now selects it in the tree and opens it in preview - Fix #729
- allow rebinding of the 'tab' and 'esc' keys with the `:next_match` and `:escape` internals - Fix #740

### v1.25.2 - 2023-09-20
<a name="v1.25.2"></a>
Expand Down
6 changes: 6 additions & 0 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ impl App {
HandleInApp(internal) => {
debug!("handling internal {internal:?} at app level");
match internal {
Internal::escape => {
let mode = self.panel().state().get_mode();
let cmd = self.mut_panel().input.escape(con, mode);
debug!("cmd on escape: {cmd:?}");
self.apply_command(w, cmd, panel_skin, app_state, con)?;
}
Internal::panel_left_no_open | Internal::panel_right_no_open => {
let new_active_panel_idx = if internal == Internal::panel_left_no_open {
// we're here because the state wants us to either move to the panel
Expand Down
4 changes: 2 additions & 2 deletions src/app/panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Panel {
pub areas: Areas,
status: Status,
pub purpose: PanelPurpose,
input: PanelInput,
pub input: PanelInput,
}

impl Panel {
Expand Down Expand Up @@ -251,7 +251,7 @@ impl Panel {
if let Some(area) = &self.areas.purpose {
let shortcut = con
.verb_store
.verbs
.verbs()
.iter()
.filter(|v| match &v.execution {
VerbExecution::Internal(exec) => exec.internal == Internal::start_end_panel,
Expand Down
7 changes: 5 additions & 2 deletions src/app/panel_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,9 @@ pub trait PanelState {
CmdResult::Keep
}
}
Internal::escape => {
CmdResult::HandleInApp(Internal::escape)
}
Internal::panel_left | Internal::panel_left_no_open => {
CmdResult::HandleInApp(Internal::panel_left_no_open)
}
Expand Down Expand Up @@ -749,11 +752,11 @@ pub trait PanelState {
}
}
Command::VerbTrigger {
index,
verb_id,
input_invocation,
} => self.execute_verb(
w,
&con.verb_store.verbs[*index],
&con.verb_store.verb(*verb_id),
input_invocation.as_ref(),
TriggerType::Other,
app_state,
Expand Down
4 changes: 2 additions & 2 deletions src/command/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
super::*,
crate::{
pattern::*,
verb::{Internal, VerbInvocation},
verb::{Internal, VerbInvocation, VerbId},
},
bet::BeTree,
};
Expand Down Expand Up @@ -35,7 +35,7 @@ pub enum Command {
/// call of a verb done without the input
/// (using a trigger key for example)
VerbTrigger {
index: usize,
verb_id: VerbId,
input_invocation: Option<VerbInvocation>,
},

Expand Down
Loading

0 comments on commit a898f33

Please sign in to comment.