mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-27 07:34:27 +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"
|
futures = "0.3.1"
|
||||||
heim = "0.0.9"
|
heim = "0.0.9"
|
||||||
log = "0.4"
|
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...
|
sysinfo = "0.9" #0.9 seems to be the last working version for my Ryzen PC...
|
||||||
tokio = "0.2.9"
|
tokio = "0.2.9"
|
||||||
winapi = "0.3"
|
winapi = "0.3"
|
||||||
|
@ -69,13 +69,13 @@ Run using `btm`.
|
|||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
- `q`, `Ctrl-c` to quit.
|
- `Ctrl-q`, `Ctrl-c` to quit.
|
||||||
|
|
||||||
- `Ctrl-r` to reset the screen and reset all collected data.
|
- `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.
|
- `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.
|
- `Esc` to close a dialog window.
|
||||||
|
|
||||||
@ -83,11 +83,11 @@ Run using `btm`.
|
|||||||
|
|
||||||
#### Scrollable Tables
|
#### 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.
|
- `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
|
#### Processes
|
||||||
|
|
||||||
|
23
src/app.rs
23
src/app.rs
@ -57,6 +57,7 @@ pub struct App {
|
|||||||
last_key_press: Instant,
|
last_key_press: Instant,
|
||||||
pub canvas_data: canvas::CanvasData,
|
pub canvas_data: canvas::CanvasData,
|
||||||
enable_grouping: bool,
|
enable_grouping: bool,
|
||||||
|
enable_searching: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
@ -96,6 +97,7 @@ impl App {
|
|||||||
last_key_press: Instant::now(),
|
last_key_press: Instant::now(),
|
||||||
canvas_data: canvas::CanvasData::default(),
|
canvas_data: canvas::CanvasData::default(),
|
||||||
enable_grouping: false,
|
enable_grouping: false,
|
||||||
|
enable_searching: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +105,7 @@ impl App {
|
|||||||
self.reset_multi_tap_keys();
|
self.reset_multi_tap_keys();
|
||||||
self.show_help = false;
|
self.show_help = false;
|
||||||
self.show_dd = false;
|
self.show_dd = false;
|
||||||
|
self.enable_searching = false;
|
||||||
self.to_delete_process_list = None;
|
self.to_delete_process_list = None;
|
||||||
self.dd_err = None;
|
self.dd_err = None;
|
||||||
}
|
}
|
||||||
@ -137,6 +140,18 @@ impl App {
|
|||||||
self.enable_grouping
|
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...
|
/// One of two functions allowed to run while in a dialog...
|
||||||
pub fn on_enter(&mut self) {
|
pub fn on_enter(&mut self) {
|
||||||
if self.show_dd {
|
if self.show_dd {
|
||||||
@ -167,6 +182,11 @@ impl App {
|
|||||||
self.last_key_press = current_key_press_inst;
|
self.last_key_press = current_key_press_inst;
|
||||||
|
|
||||||
match caught_char {
|
match caught_char {
|
||||||
|
'/' => {
|
||||||
|
if let ApplicationPosition::Process = self.current_application_position {
|
||||||
|
self.toggle_searching();
|
||||||
|
}
|
||||||
|
}
|
||||||
'd' => {
|
'd' => {
|
||||||
if let ApplicationPosition::Process = self.current_application_position {
|
if let ApplicationPosition::Process = self.current_application_position {
|
||||||
if self.awaiting_second_char && self.second_char == 'd' {
|
if self.awaiting_second_char && self.second_char == 'd' {
|
||||||
@ -214,6 +234,9 @@ impl App {
|
|||||||
self.second_char = 'g';
|
self.second_char = 'g';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'G' => self.skip_to_last(),
|
||||||
|
'k' => self.decrement_position_count(),
|
||||||
|
'j' => self.increment_position_count(),
|
||||||
'f' => {
|
'f' => {
|
||||||
self.is_frozen = !self.is_frozen;
|
self.is_frozen = !self.is_frozen;
|
||||||
}
|
}
|
||||||
|
56
src/main.rs
56
src/main.rs
@ -9,8 +9,8 @@ extern crate lazy_static;
|
|||||||
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{
|
event::{
|
||||||
self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent,
|
self, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyModifiers,
|
||||||
KeyModifiers, MouseEvent,
|
MouseEvent,
|
||||||
},
|
},
|
||||||
execute,
|
execute,
|
||||||
terminal::LeaveAlternateScreen,
|
terminal::LeaveAlternateScreen,
|
||||||
@ -213,16 +213,11 @@ fn main() -> error::Result<()> {
|
|||||||
if event.modifiers.is_empty() {
|
if event.modifiers.is_empty() {
|
||||||
// If only a code, and no modifiers, don't bother...
|
// If only a code, and no modifiers, don't bother...
|
||||||
match event.code {
|
match event.code {
|
||||||
KeyCode::Char('q') => break,
|
KeyCode::End => app.skip_to_last(),
|
||||||
KeyCode::Char('G') | KeyCode::End => app.skip_to_last(),
|
|
||||||
KeyCode::Home => app.skip_to_first(),
|
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::Up => app.decrement_position_count(),
|
||||||
KeyCode::Down => app.increment_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::Esc => app.reset(),
|
||||||
KeyCode::Enter => app.on_enter(),
|
KeyCode::Enter => app.on_enter(),
|
||||||
KeyCode::Tab => app.on_tab(),
|
KeyCode::Tab => app.on_tab(),
|
||||||
@ -230,38 +225,21 @@ fn main() -> error::Result<()> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, track the modifier as well...
|
// Otherwise, track the modifier as well...
|
||||||
match event {
|
if let KeyModifiers::CONTROL = event.modifiers {
|
||||||
KeyEvent {
|
match event.code {
|
||||||
modifiers: KeyModifiers::CONTROL,
|
KeyCode::Char('c') | KeyCode::Char('q') => break,
|
||||||
code: KeyCode::Char('c'),
|
KeyCode::Char('f') => app.on_char_key('/'), // Note that this is fine for now, assuming '/' does not do anything other than search.
|
||||||
} => break,
|
KeyCode::Left | KeyCode::Char('h') => app.on_left(),
|
||||||
KeyEvent {
|
KeyCode::Right | KeyCode::Char('l') => app.on_right(),
|
||||||
modifiers: KeyModifiers::CONTROL,
|
KeyCode::Up | KeyCode::Char('k') => app.on_up(),
|
||||||
code: KeyCode::Left,
|
KeyCode::Down | KeyCode::Char('j') => app.on_down(),
|
||||||
} => app.on_left(),
|
KeyCode::Char('r') => {
|
||||||
KeyEvent {
|
if rtx.send(ResetEvent::Reset).is_ok() {
|
||||||
modifiers: KeyModifiers::CONTROL,
|
app.reset();
|
||||||
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.");
|
|
||||||
}
|
}
|
||||||
debug!("Resetting begins...");
|
_ => {}
|
||||||
app.reset();
|
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user