Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0ea97f

Browse files
author
Sebastian Thiel
committed
Cycle through graph and bar options
1 parent 5551c01 commit b0ea97f

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/interactive/app.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ impl Default for ByteVisualization {
5252
}
5353

5454
impl ByteVisualization {
55+
pub fn cycle(&mut self) {
56+
use ByteVisualization::*;
57+
*self = match self {
58+
Bars => Percentage,
59+
Percentage => Bars,
60+
}
61+
}
5562
pub fn display(&self, percentage: f64, length: usize) -> DisplayByteVisualization {
5663
DisplayByteVisualization {
5764
format: *self,
@@ -187,11 +194,7 @@ impl TerminalApp {
187194
match key {
188195
Char('?') => self.toggle_help_pane(),
189196
Char('\t') => {
190-
self.state.focussed = match (self.state.focussed, self.state.help_pane) {
191-
(Main, Some(_)) => Help,
192-
(Help, _) => Main,
193-
_ => Main,
194-
};
197+
self.cycle_focus();
195198
}
196199
Ctrl('c') => break,
197200
Char('q') => match self.state.focussed {
@@ -221,6 +224,7 @@ impl TerminalApp {
221224
Char('j') => self.change_entry_selection(CursorDirection::Down),
222225
Ctrl('d') => self.change_entry_selection(CursorDirection::PageDown),
223226
Char('s') => self.state.sorting.toggle_size(),
227+
Char('g') => self.display.byte_vis.cycle(),
224228
_ => {}
225229
},
226230
};
@@ -231,6 +235,15 @@ impl TerminalApp {
231235
})
232236
}
233237

238+
fn cycle_focus(&mut self) {
239+
use FocussedPane::*;
240+
self.state.focussed = match (self.state.focussed, self.state.help_pane) {
241+
(Main, Some(_)) => Help,
242+
(Help, _) => Main,
243+
_ => Main,
244+
};
245+
}
246+
234247
fn toggle_help_pane(&mut self) {
235248
use FocussedPane::*;
236249
self.state.focussed = match self.state.focussed {

src/interactive/widgets/help.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ impl Widget for HelpPane {
7272
hotkey("Ctrl + u", "move up 10 entries at once");
7373
spacer();
7474
}
75-
title("Keys for sorting");
75+
title("Keys for display");
7676
{
7777
hotkey("s", "toggle sort by size ascending/descending");
78+
hotkey("g", "cycle through percentage display options");
7879
spacer();
7980
}
8081
title("Keys for entry operations");

0 commit comments

Comments
 (0)