Skip to content

Commit

Permalink
fix sorting; add some alternate keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thiel committed Jun 5, 2019
1 parent 37ce7fe commit f2e4504
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/interactive/app/eventloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TerminalApp {
B: Backend,
R: io::Read + TermReadEventsAndRaw,
{
use termion::event::Key::{Char, Ctrl};
use termion::event::Key::{Char, Ctrl, Down, Esc, PageDown, PageUp, Up};
use FocussedPane::*;

self.draw(terminal)?;
Expand All @@ -89,7 +89,7 @@ impl TerminalApp {
self.cycle_focus();
}
Ctrl('c') => break,
Char('q') => match self.state.focussed {
Char('q') | Esc => match self.state.focussed {
Main => break,
Help => {
self.state.focussed = Main;
Expand All @@ -101,10 +101,10 @@ impl TerminalApp {

match self.state.focussed {
FocussedPane::Help => match key {
Ctrl('u') => self.scroll_help(CursorDirection::PageUp),
Char('k') => self.scroll_help(CursorDirection::Up),
Char('j') => self.scroll_help(CursorDirection::Down),
Ctrl('d') => self.scroll_help(CursorDirection::PageDown),
Ctrl('u') | PageUp => self.scroll_help(CursorDirection::PageUp),
Char('k') | Up => self.scroll_help(CursorDirection::Up),
Char('j') | Down => self.scroll_help(CursorDirection::Down),
Ctrl('d') | PageDown => self.scroll_help(CursorDirection::PageDown),
_ => {}
},
FocussedPane::Main => match key {
Expand All @@ -115,7 +115,7 @@ impl TerminalApp {
Char('k') => self.change_entry_selection(CursorDirection::Up),
Char('j') => self.change_entry_selection(CursorDirection::Down),
Ctrl('d') => self.change_entry_selection(CursorDirection::PageDown),
Char('s') => self.state.sorting.toggle_size(),
Char('s') => self.cycle_sorting(),
Char('g') => self.display.byte_vis.cycle(),
_ => {}
},
Expand Down
6 changes: 6 additions & 0 deletions src/interactive/app/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ impl TerminalApp {
.map(|b| b.index)
.or(self.state.selected)
}

pub fn cycle_sorting(&mut self) {
self.state.sorting.toggle_size();
self.state.entries =
sorted_entries(&self.traversal.tree, self.state.root, self.state.sorting);
}
}
10 changes: 6 additions & 4 deletions src/interactive/widgets/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ToplevelComponent for ReactHelpPane {
let hotkey = |keys, description| {
count(1);
lines.borrow_mut().push(Text::Styled(
format!("{:>10}", keys).into(),
format!("{:>11}", keys).into(),
Style {
fg: Color::Green,
..Default::default()
Expand All @@ -59,7 +59,7 @@ impl ToplevelComponent for ReactHelpPane {
title("Keys for pane control");
{
hotkey(
"q",
"q/<ESC>",
"close the current pane. Closes the application if no pane is open.",
);
hotkey("<tab>", "Cycle between all open panes");
Expand All @@ -68,12 +68,14 @@ impl ToplevelComponent for ReactHelpPane {
}
title("Keys for Navigation");
{
hotkey("j", "move down an entry");
hotkey("k", "move up an entry");
hotkey("j/<down>", "move down an entry");
hotkey("k/<up>", "move up an entry");
hotkey("o", "descent into the selected directory");
hotkey("u", "ascent one level into the parent directory");
hotkey("Ctrl + d", "move down 10 entries at once");
hotkey("<Page Down>", "^");
hotkey("Ctrl + u", "move up 10 entries at once");
hotkey("<Page Up>", "^");
spacer();
}
title("Keys for display");
Expand Down

0 comments on commit f2e4504

Please sign in to comment.