Skip to content

Commit

Permalink
implement tab key
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 4, 2019
1 parent 9fcc4fe commit 1d1c351
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/interactive/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl From<WalkOptions> for DisplayOptions {
}
}

#[derive(Copy, Clone)]
pub enum FocussedPane {
Main,
Help,
Expand Down Expand Up @@ -122,17 +123,13 @@ impl TerminalApp {
for key in keys.filter_map(Result::ok) {
self.update_message();
match key {
Char('?') => {
self.state.focussed = match self.state.focussed {
Main => {
self.state.help_pane = Some(HelpPaneState);
Help
}
Help => {
self.state.help_pane = None;
Main
}
}
Char('?') => self.toggle_help_pane(),
Char('\t') => {
self.state.focussed = match (self.state.focussed, self.state.help_pane) {
(Main, Some(_)) => Help,
(Help, _) => Main,
_ => Main,
};
}
Ctrl('c') => break,
Char('q') => match self.state.focussed {
Expand Down Expand Up @@ -168,6 +165,20 @@ impl TerminalApp {
})
}

fn toggle_help_pane(&mut self) {
use FocussedPane::*;
self.state.focussed = match self.state.focussed {
Main => {
self.state.help_pane = Some(HelpPaneState);
Help
}
Help => {
self.state.help_pane = None;
Main
}
}
}

fn update_message(&mut self) {
self.state.message = None;
}
Expand Down
1 change: 1 addition & 0 deletions src/interactive/widgets/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Widget for HelpPane {
)
.iter(),
)
.chain(hotkey("<tab>", "Cycle between all open panes").iter())
.chain(hotkey("?", "Show the help pane").iter())
.chain(spacer().iter())
.chain(
Expand Down

0 comments on commit 1d1c351

Please sign in to comment.