mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-04-08 17:05:59 +02:00
Change of hjkl navigation and removal of q to quit (replaced by Ctrl-[char]) variants. This is required for a less confusing use of upcoming search functionality
This commit is contained in:
parent
0e35d30068
commit
545cb8b8b1
@ -29,7 +29,7 @@ futures-timer = "2.0.2"
|
||||
futures = "0.3.1"
|
||||
heim = "0.0.9"
|
||||
log = "0.4"
|
||||
regex = "1.3.1"
|
||||
regex = "1.3.3"
|
||||
sysinfo = "0.9" #0.9 seems to be the last working version for my Ryzen PC...
|
||||
tokio = "0.2.9"
|
||||
winapi = "0.3"
|
||||
|
@ -69,13 +69,13 @@ Run using `btm`.
|
||||
|
||||
#### General
|
||||
|
||||
- `q`, `Ctrl-c` to quit.
|
||||
- `Ctrl-q`, `Ctrl-c` to quit.
|
||||
|
||||
- `Ctrl-r` to reset the screen and reset all collected data.
|
||||
|
||||
- `f` to freeze the screen from updating with new data. Press `f` again to unfreeze. Note that monitoring will still continue in the background.
|
||||
|
||||
- `Ctrl+Up/k`, `Ctrl+Down/j`, `Ctrl+Left/h`, `Ctrl+Right/l` to navigate between widgets.
|
||||
- `Ctrl-Up/Ctrl-k`, `Ctrl-Down/Ctrl-j`, `Ctrl-Left/Ctrl-h`, `Ctrl-Right/Ctrl-l` to navigate between widgets.
|
||||
|
||||
- `Esc` to close a dialog window.
|
||||
|
||||
@ -83,11 +83,11 @@ Run using `btm`.
|
||||
|
||||
#### Scrollable Tables
|
||||
|
||||
- `Up` and `Down` scrolls through the list if the widget is a table (Temperature, Disks, Processes).
|
||||
- `Up/k` and `Down/j` scrolls through the list if the widget is a table (Temperature, Disks, Processes).
|
||||
|
||||
- `gg` or `Home` to jump to the first entry of the current table.
|
||||
|
||||
- `G` (`Shift+g`) or `End` to jump to the last entry of the current table.
|
||||
- `G` (`Shift-g`) or `End` to jump to the last entry of the current table.
|
||||
|
||||
#### Processes
|
||||
|
||||
|
23
src/app.rs
23
src/app.rs
@ -57,6 +57,7 @@ pub struct App {
|
||||
last_key_press: Instant,
|
||||
pub canvas_data: canvas::CanvasData,
|
||||
enable_grouping: bool,
|
||||
enable_searching: bool,
|
||||
}
|
||||
|
||||
impl App {
|
||||
@ -96,6 +97,7 @@ impl App {
|
||||
last_key_press: Instant::now(),
|
||||
canvas_data: canvas::CanvasData::default(),
|
||||
enable_grouping: false,
|
||||
enable_searching: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,6 +105,7 @@ impl App {
|
||||
self.reset_multi_tap_keys();
|
||||
self.show_help = false;
|
||||
self.show_dd = false;
|
||||
self.enable_searching = false;
|
||||
self.to_delete_process_list = None;
|
||||
self.dd_err = None;
|
||||
}
|
||||
@ -137,6 +140,18 @@ impl App {
|
||||
self.enable_grouping
|
||||
}
|
||||
|
||||
pub fn toggle_searching(&mut self) {
|
||||
if !self.is_in_dialog() {
|
||||
if let ApplicationPosition::Process = self.current_application_position {
|
||||
self.enable_searching = !(self.enable_searching);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_searching(&self) -> bool {
|
||||
self.enable_searching
|
||||
}
|
||||
|
||||
/// One of two functions allowed to run while in a dialog...
|
||||
pub fn on_enter(&mut self) {
|
||||
if self.show_dd {
|
||||
@ -167,6 +182,11 @@ impl App {
|
||||
self.last_key_press = current_key_press_inst;
|
||||
|
||||
match caught_char {
|
||||
'/' => {
|
||||
if let ApplicationPosition::Process = self.current_application_position {
|
||||
self.toggle_searching();
|
||||
}
|
||||
}
|
||||
'd' => {
|
||||
if let ApplicationPosition::Process = self.current_application_position {
|
||||
if self.awaiting_second_char && self.second_char == 'd' {
|
||||
@ -214,6 +234,9 @@ impl App {
|
||||
self.second_char = 'g';
|
||||
}
|
||||
}
|
||||
'G' => self.skip_to_last(),
|
||||
'k' => self.decrement_position_count(),
|
||||
'j' => self.increment_position_count(),
|
||||
'f' => {
|
||||
self.is_frozen = !self.is_frozen;
|
||||
}
|
||||
|
56
src/main.rs
56
src/main.rs
@ -9,8 +9,8 @@ extern crate lazy_static;
|
||||
|
||||
use crossterm::{
|
||||
event::{
|
||||
self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent,
|
||||
KeyModifiers, MouseEvent,
|
||||
self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyModifiers,
|
||||
MouseEvent,
|
||||
},
|
||||
execute,
|
||||
terminal::LeaveAlternateScreen,
|
||||
@ -213,16 +213,11 @@ fn main() -> error::Result<()> {
|
||||
if event.modifiers.is_empty() {
|
||||
// If only a code, and no modifiers, don't bother...
|
||||
match event.code {
|
||||
KeyCode::Char('q') => break,
|
||||
KeyCode::Char('G') | KeyCode::End => app.skip_to_last(),
|
||||
KeyCode::End => app.skip_to_last(),
|
||||
KeyCode::Home => app.skip_to_first(),
|
||||
KeyCode::Char('h') => app.on_left(),
|
||||
KeyCode::Char('l') => app.on_right(),
|
||||
KeyCode::Char('k') => app.on_up(),
|
||||
KeyCode::Char('j') => app.on_down(),
|
||||
KeyCode::Up => app.decrement_position_count(),
|
||||
KeyCode::Down => app.increment_position_count(),
|
||||
KeyCode::Char(uncaught_char) => app.on_char_key(uncaught_char),
|
||||
KeyCode::Char(character) => app.on_char_key(character),
|
||||
KeyCode::Esc => app.reset(),
|
||||
KeyCode::Enter => app.on_enter(),
|
||||
KeyCode::Tab => app.on_tab(),
|
||||
@ -230,38 +225,21 @@ fn main() -> error::Result<()> {
|
||||
}
|
||||
} else {
|
||||
// Otherwise, track the modifier as well...
|
||||
match event {
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Char('c'),
|
||||
} => break,
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Left,
|
||||
} => app.on_left(),
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Right,
|
||||
} => app.on_right(),
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Up,
|
||||
} => app.on_up(),
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Down,
|
||||
} => app.on_down(),
|
||||
KeyEvent {
|
||||
modifiers: KeyModifiers::CONTROL,
|
||||
code: KeyCode::Char('r'),
|
||||
} => {
|
||||
while rtx.send(ResetEvent::Reset).is_err() {
|
||||
debug!("Sent reset message.");
|
||||
if let KeyModifiers::CONTROL = event.modifiers {
|
||||
match event.code {
|
||||
KeyCode::Char('c') | KeyCode::Char('q') => break,
|
||||
KeyCode::Char('f') => app.on_char_key('/'), // Note that this is fine for now, assuming '/' does not do anything other than search.
|
||||
KeyCode::Left | KeyCode::Char('h') => app.on_left(),
|
||||
KeyCode::Right | KeyCode::Char('l') => app.on_right(),
|
||||
KeyCode::Up | KeyCode::Char('k') => app.on_up(),
|
||||
KeyCode::Down | KeyCode::Char('j') => app.on_down(),
|
||||
KeyCode::Char('r') => {
|
||||
if rtx.send(ResetEvent::Reset).is_ok() {
|
||||
app.reset();
|
||||
}
|
||||
}
|
||||
debug!("Resetting begins...");
|
||||
app.reset();
|
||||
_ => {}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user