mirror of
https://github.com/orhun/kmon
synced 2024-07-08 20:06:03 +00:00
feat: Add ctrl-x key for changing the position of a block
This commit is contained in:
parent
e00a70fe8f
commit
b76594bfeb
|
@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Add alt-e/s keys for expanding/shrinking the selected block
|
||||
- Add alt-e/s keys for expanding/shrinking the selected block
|
||||
- Add ctrl-x key for changing the position of a block
|
||||
|
||||
### Fixed
|
||||
- Fix the percentage overflow in kernel module table
|
||||
|
|
14
README.md
14
README.md
|
@ -80,6 +80,7 @@ kmon is written in [Rust](https://www.rust-lang.org/) and uses [tui-rs](https://
|
|||
- [Scrolling Kernel Activities](#scrolling-kernel-activities)
|
||||
- [Smooth Scrolling](#smooth-scrolling)
|
||||
- [Block Sizes](#block-sizes)
|
||||
- [Block Positions](#block-positions)
|
||||
- [Kernel Information](#kernel-information)
|
||||
- [Module Information](#module-information)
|
||||
- [Displaying the dependent modules](#displaying-the-dependent-modules)
|
||||
|
@ -251,10 +252,11 @@ FLAGS:
|
|||
| `</>` | Scroll up/down [module information] |
|
||||
| `alt-h/l` | Scroll right/left [kernel activities] |
|
||||
| `ctrl-t/b, home/end` | Scroll to top/bottom [module list] |
|
||||
| `alt-e/s` | Expand/shrink the selected block |
|
||||
| `ctrl-l/u, alt-c` | Clear the kernel ring buffer |
|
||||
| `alt-e/s` | Expand/shrink the selected block |
|
||||
| `ctrl-x` | Change the block position |
|
||||
| `ctrl-l/u, alt-c` | Clear the kernel ring buffer |
|
||||
| `[d], alt-d` | Show the dependent modules |
|
||||
| `[1]..[9]` | Jump to the dependent module |
|
||||
| `[1]..[9]` | Jump to the dependent module |
|
||||
| `[\], tab, backtab` | Show the next kernel information |
|
||||
| `[/], s, enter` | Search a kernel module |
|
||||
| `[+], i, insert` | Load a kernel module |
|
||||
|
@ -298,6 +300,12 @@ Some kernel messages might be long enough for not fitting into the kernel activi
|
|||
|
||||
![Block Sizes](https://user-images.githubusercontent.com/24392180/89716231-f8841300-d9b3-11ea-9cea-ee9816174336.gif)
|
||||
|
||||
### Block Positions
|
||||
|
||||
`ctrl-x` key can be used for changing the positions of blocks.
|
||||
|
||||
![Block Positions](https://user-images.githubusercontent.com/24392180/90258934-e68dee80-de51-11ea-951a-ec5a301608a6.gif)
|
||||
|
||||
### Kernel Information
|
||||
|
||||
Use one of the `\, tab, backtab` keys to switch between kernel release, version and platform informations.
|
||||
|
|
|
@ -66,6 +66,9 @@ Scroll to top/bottom [module list]
|
|||
.B alt-e/s
|
||||
Expand/shrink the selected block
|
||||
.TP
|
||||
.B ctrl-x
|
||||
Change the block position
|
||||
.TP
|
||||
.B ctrl-l/u, alt-c
|
||||
Clear the kernel ring buffer
|
||||
.TP
|
||||
|
|
31
src/app.rs
31
src/app.rs
|
@ -2,6 +2,7 @@ use crate::event::Event;
|
|||
use crate::kernel::cmd::ModuleCommand;
|
||||
use crate::kernel::lkm::KernelModules;
|
||||
use crate::kernel::log::KernelLogs;
|
||||
use crate::kernel::Kernel;
|
||||
use crate::style::{Style, StyledText, Symbol};
|
||||
use crate::util;
|
||||
use clipboard::{ClipboardContext, ClipboardProvider};
|
||||
|
@ -122,6 +123,7 @@ pub struct App {
|
|||
pub selected_block: Block,
|
||||
pub default_block: Block,
|
||||
pub block_size: BlockSize,
|
||||
pub block_index: u8,
|
||||
pub input_mode: InputMode,
|
||||
pub input_query: String,
|
||||
style: Style,
|
||||
|
@ -140,6 +142,7 @@ impl App {
|
|||
selected_block: block,
|
||||
default_block: block,
|
||||
block_size: BlockSize::default(),
|
||||
block_index: 0,
|
||||
input_mode: InputMode::None,
|
||||
input_query: String::new(),
|
||||
style,
|
||||
|
@ -150,6 +153,7 @@ impl App {
|
|||
pub fn refresh(&mut self) {
|
||||
self.selected_block = self.default_block;
|
||||
self.block_size = BlockSize::default();
|
||||
self.block_index = 0;
|
||||
self.input_mode = InputMode::None;
|
||||
self.input_query = String::new();
|
||||
}
|
||||
|
@ -278,6 +282,33 @@ impl App {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a block according to the index.
|
||||
*
|
||||
* @param frame
|
||||
* @param area
|
||||
* @param kernel
|
||||
*/
|
||||
pub fn draw_dynamic_block<B>(
|
||||
&mut self,
|
||||
frame: &mut Frame<'_, B>,
|
||||
area: Rect,
|
||||
kernel: &mut Kernel,
|
||||
) where
|
||||
B: Backend,
|
||||
{
|
||||
match self.block_index {
|
||||
0 => self.draw_kernel_modules(frame, area, &mut kernel.modules),
|
||||
1 => self.draw_module_info(frame, area, &mut kernel.modules),
|
||||
_ => self.draw_kernel_activities(frame, area, &mut kernel.logs),
|
||||
}
|
||||
if self.block_index < 2 {
|
||||
self.block_index += 1;
|
||||
} else {
|
||||
self.block_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a paragraph widget for using as user input.
|
||||
*
|
||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -95,16 +95,14 @@ where
|
|||
);
|
||||
}
|
||||
if app.block_size.info != 100 {
|
||||
app.draw_kernel_modules(
|
||||
&mut f,
|
||||
chunks[1],
|
||||
&mut kernel.modules,
|
||||
);
|
||||
app.draw_dynamic_block(&mut f, chunks[1], &mut kernel);
|
||||
} else {
|
||||
app.block_index += 1;
|
||||
}
|
||||
}
|
||||
app.draw_module_info(&mut f, chunks[1], &mut kernel.modules);
|
||||
app.draw_dynamic_block(&mut f, chunks[1], &mut kernel);
|
||||
}
|
||||
app.draw_kernel_activities(&mut f, chunks[1], &mut kernel.logs);
|
||||
app.draw_dynamic_block(&mut f, chunks[1], &mut kernel);
|
||||
})?;
|
||||
/* Set cursor position if the input mode flag is set. */
|
||||
if !app.input_mode.is_none() {
|
||||
|
@ -207,6 +205,14 @@ where
|
|||
*block_size =
|
||||
(*block_size).checked_sub(5).unwrap_or_default()
|
||||
}
|
||||
/* Change the block position. */
|
||||
Key::Ctrl('x') => {
|
||||
if app.block_index == 2 {
|
||||
app.block_index = 0;
|
||||
} else {
|
||||
app.block_index += 1;
|
||||
}
|
||||
}
|
||||
/* Scroll to the top of the module list. */
|
||||
Key::Ctrl('t') | Key::Home => {
|
||||
app.selected_block = Block::ModuleTable;
|
||||
|
@ -535,6 +541,9 @@ mod tests {
|
|||
Key::Ctrl('b'),
|
||||
Key::Alt('e'),
|
||||
Key::Alt('s'),
|
||||
Key::Ctrl('x'),
|
||||
Key::Ctrl('x'),
|
||||
Key::Ctrl('x'),
|
||||
Key::Char('x'),
|
||||
Key::Char('n'),
|
||||
Key::Char('d'),
|
||||
|
|
|
@ -20,6 +20,7 @@ pub const KEY_BINDINGS: &[(&str, &str)] = &[
|
|||
("alt-h/l", "scroll right/left [kernel activities]"),
|
||||
("ctrl-t/b, home/end", "scroll to top/bottom [module list]"),
|
||||
("alt-e/s", "expand/shrink the selected block"),
|
||||
("ctrl-x", "change the block position"),
|
||||
("ctrl-l/u, alt-c", "clear the kernel ring buffer"),
|
||||
("d, alt-d", "show the dependent modules"),
|
||||
("1..9", "jump to the dependent module"),
|
||||
|
|
Loading…
Reference in New Issue
Block a user