feat: ctrl scroll modifier

Use the `ctrl` button to scroll by a factor of ten
This commit is contained in:
Jack Wills
2025-08-21 15:19:10 +00:00
parent 8939ac0345
commit c5bbffdb5f
18 changed files with 249 additions and 130 deletions
+41 -16
View File
@@ -109,13 +109,18 @@ impl HelpInfo {
button_item("PgUp PgDown"),
or(),
button_item("Home End"),
button_desc("change selected line"),
button_desc("scroll vertically"),
]),
Line::from(vec![
space(),
button_item("← →"),
button_desc("horizontal scroll across logs"),
]),
Line::from(vec![
space(),
button_item("ctrl"),
button_desc("increase scroll speed, used in conjuction scroll keys"),
]),
Line::from(vec![
space(),
button_item("enter"),
@@ -280,6 +285,11 @@ impl HelpInfo {
or_secondary(km.scroll_start, "scroll list to start"),
or_secondary(km.log_scroll_forward, "horizontal scroll logs right"),
or_secondary(km.log_scroll_back, "horizontal scroll logs left"),
Line::from(vec![
space(),
button_item(km.scroll_many.to_string().as_str()),
button_desc("increase scroll speed, used in conjuction scroll keys"),
]),
Line::from(vec![
space(),
button_item("enter"),
@@ -440,7 +450,7 @@ pub fn draw(
#[allow(clippy::unwrap_used, clippy::too_many_lines)]
mod tests {
use crate::config::{AppColors, Keymap};
use crossterm::event::KeyCode;
use crossterm::event::{KeyCode, KeyModifiers};
use insta::assert_snapshot;
use jiff::tz::TimeZone;
use ratatui::style::{Color, Modifier};
@@ -449,9 +459,10 @@ mod tests {
#[test]
/// This will cause issues once the version has more than the current 5 chars (0.5.0)
/// This test is incredibly annoying
/// println!("{} {} {} {} {}", row_index, result_cell_index, result_cell.symbol(), result_cell.bg, result_cell.fg);
fn test_draw_blocks_help() {
let mut setup = test_setup(87, 36, true, true);
let mut setup = test_setup(87, 37, true, true);
let tz = setup.app_data.lock().config.timezone.clone();
setup
@@ -471,9 +482,17 @@ mod tests {
for (row_index, result_row) in get_result(&setup) {
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
println!(
"{} {} {} {} {}",
row_index,
result_cell_index,
result_cell.symbol(),
result_cell.bg,
result_cell.fg
);
match (row_index, result_cell_index) {
// first & last row, and first & last char on each row, is reset/reset, making sure that the help info is centered in the given area
(0 | 35, _) | (0..=34, 0 | 86) => {
(0 | 36, _) | (0..=35, 0 | 86) => {
assert_eq!(result_cell.bg, Color::Reset);
assert_eq!(result_cell.fg, Color::Reset);
}
@@ -487,15 +506,16 @@ mod tests {
| (12, 19..=66)
| (14, 2..=10 | 13..=27)
| (15, 2..=10 | 13..=21 | 24..=40 | 43..=56)
| (16 | 26 | 28, 2..=10)
| (17 | 25, 2..=12)
| (18 | 19 | 20 | 21 | 22 | 24 | 27 | 29, 2..=8)
| (23, 2..=9 | 12..=18) => {
| (16 | 27 | 29, 2..=10)
| (17, 2..=11)
| (18 | 26, 2..=12)
| (19 | 20 | 21 | 22 | 24 | 25 | 28 | 23 | 30, 2..=8)
| (24, 2..=9 | 12..=18) => {
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(result_cell.fg, Color::White);
}
// The URL is yellow and underlined
(32, 25..=60) => {
(33, 25..=60) => {
assert_eq!(result_cell.bg, Color::Magenta);
assert_eq!(result_cell.fg, Color::White);
assert_eq!(result_cell.modifier, Modifier::UNDERLINED);
@@ -512,9 +532,10 @@ mod tests {
#[test]
/// Test that the help panel gets drawn with custom colors
/// This test is incredibly annoying
/// println!("{} {} {} {} {}", row_index, result_cell_index, result_cell.symbol(), result_cell.bg, result_cell.fg);
fn test_draw_blocks_help_custom_colors() {
let mut setup = test_setup(87, 36, true, true);
let mut setup = test_setup(87, 37, true, true);
let mut colors = AppColors::new();
let tz = setup.app_data.lock().config.timezone.clone();
@@ -540,7 +561,7 @@ mod tests {
for (result_cell_index, result_cell) in result_row.iter().enumerate() {
match (row_index, result_cell_index) {
// first & last row, and first & last char on each row, is reset/reset, making sure that the help info is centered in the given area
(0 | 35, _) | (0..=34, 0 | 86) => {
(0 | 36, _) | (0..=35, 0 | 86) => {
assert_eq!(result_cell.bg, Color::Reset);
assert_eq!(result_cell.fg, Color::Reset);
}
@@ -554,15 +575,16 @@ mod tests {
| (12, 19..=66)
| (14, 2..=10 | 13..=27)
| (15, 2..=10 | 13..=21 | 24..=40 | 43..=56)
| (16 | 26 | 28, 2..=10)
| (17 | 25, 2..=12)
| (18 | 19 | 20 | 21 | 22 | 24 | 27 | 29, 2..=8)
| (23, 2..=9 | 12..=18) => {
| (16 | 27 | 29, 2..=10)
| (17, 2..=11)
| (18 | 26, 2..=12)
| (19 | 20 | 21 | 22 | 24 | 25 | 28 | 23 | 30, 2..=8)
| (24, 2..=9 | 12..=18) => {
assert_eq!(result_cell.bg, Color::Black);
assert_eq!(result_cell.fg, Color::Yellow);
}
// The URL is yellow and underlined
(32, 25..=60) => {
(33, 25..=60) => {
assert_eq!(result_cell.bg, Color::Black);
assert_eq!(result_cell.fg, Color::Yellow);
assert_eq!(result_cell.modifier, Modifier::UNDERLINED);
@@ -599,6 +621,7 @@ mod tests {
scroll_down_many: (KeyCode::Char('n'), None),
scroll_down_one: (KeyCode::Char('o'), None),
scroll_end: (KeyCode::Char('p'), None),
scroll_many: KeyModifiers::ALT,
scroll_start: (KeyCode::Char('q'), None),
scroll_up_many: (KeyCode::Char('r'), None),
scroll_up_one: (KeyCode::Char('s'), None),
@@ -650,6 +673,7 @@ mod tests {
scroll_down_many: (KeyCode::Char('m'), Some(KeyCode::Char('M'))),
scroll_down_one: (KeyCode::Char('n'), Some(KeyCode::Char('N'))),
scroll_end: (KeyCode::Char('o'), Some(KeyCode::Char('O'))),
scroll_many: KeyModifiers::ALT,
scroll_start: (KeyCode::Char('p'), Some(KeyCode::Char('P'))),
scroll_up_many: (KeyCode::Char('q'), Some(KeyCode::Char('Q'))),
scroll_up_one: (KeyCode::Char('r'), Some(KeyCode::Char('R'))),
@@ -701,6 +725,7 @@ mod tests {
scroll_down_many: (KeyCode::Char('n'), None),
scroll_down_one: (KeyCode::Char('o'), Some(KeyCode::Char('O'))),
scroll_end: (KeyCode::Char('p'), None),
scroll_many: KeyModifiers::ALT,
scroll_start: (KeyCode::Char('q'), Some(KeyCode::Char('Q'))),
scroll_up_many: (KeyCode::Char('r'), None),
scroll_up_one: (KeyCode::Char('s'), Some(KeyCode::Char('S'))),
@@ -17,8 +17,9 @@ expression: setup.terminal.backend()
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) scroll vertically │ "
" │ ( ← → ) horizontal scroll across logs │ "
" │ ( ctrl ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( f ) force clear the screen & redraw the gui │ "
@@ -17,8 +17,9 @@ expression: setup.terminal.backend()
" │ A simple tui to view & control docker containers │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) scroll vertically │ "
" │ ( ← → ) horizontal scroll across logs │ "
" │ ( ctrl ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( f ) force clear the screen & redraw the gui │ "
@@ -25,6 +25,7 @@ expression: setup.terminal.backend()
" │ ( q ) scroll list to start │ "
" │ ( h ) horizontal scroll logs right │ "
" │ ( g ) horizontal scroll logs left │ "
" │ ( Alt ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( d ) exec into a container │ "
" │ ( f ) force clear the screen & redraw the gui │ "
@@ -50,5 +51,4 @@ expression: setup.terminal.backend()
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" ╰────────────────────────────────────────────────────────────────────────────────────╯ "
@@ -25,6 +25,7 @@ expression: setup.terminal.backend()
" │ ( p ) or ( P ) scroll list to start │ "
" │ ( g ) or ( G ) horizontal scroll logs right │ "
" │ ( f ) or ( F ) horizontal scroll logs left │ "
" │ ( Alt ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( d ) or ( D ) exec into a container │ "
" │ ( f ) or ( F ) force clear the screen & redraw the gui │ "
@@ -50,5 +51,4 @@ expression: setup.terminal.backend()
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯ "
@@ -25,6 +25,7 @@ expression: setup.terminal.backend()
" │ ( q ) or ( Q ) scroll list to start │ "
" │ ( h ) horizontal scroll logs right │ "
" │ ( g ) or ( G ) horizontal scroll logs left │ "
" │ ( Alt ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( d ) exec into a container │ "
" │ ( f ) force clear the screen & redraw the gui │ "
@@ -50,5 +51,4 @@ expression: setup.terminal.backend()
" │ │ "
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" ╰────────────────────────────────────────────────────────────────────────────────────────────╯ "
@@ -18,8 +18,9 @@ expression: setup.terminal.backend()
" │ logs timezone: Asia/Tokyo │ "
" │ │ "
" │ ( tab ) or ( shift+tab ) change panels │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ "
" │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) scroll vertically │ "
" │ ( ← → ) horizontal scroll across logs │ "
" │ ( ctrl ) increase scroll speed, used in conjuction scroll keys │ "
" │ ( enter ) send docker container command │ "
" │ ( e ) exec into a container │ "
" │ ( f ) force clear the screen & redraw the gui │ "
@@ -37,5 +38,4 @@ expression: setup.terminal.backend()
" │ currently an early work in progress, all and any input appreciated │ "
" │ https://github.com/mrjackwills/oxker │ "
" │ │ "
" │ │ "
" ╰───────────────────────────────────────────────────────────────────────────────────╯ "
@@ -4,23 +4,23 @@ expression: setup.terminal.backend()
---
" name state status cpu memory/limit id image ↓ rx ↑ tx ( h ) exit help "
"╭ Containers 1/3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮╭──────────────╮"
"│⚪ container_1 ✓ running Up 1 hour 03.00% 30.00 kB / 30.00 kB 1 image_1 0.00 kB 0.00 kB ││▶ pause │" Hidden by multi-width symbols: [(2, " ")]
"│ container_2 ✓ running Up 2 ho╭ 0.00.000 ──────────────────────────────────────────────────────────────────────────╮ ││ restart │"
"│ container_3 ✓ running Up 3 ho│ │ ││ stop │"
"│⚪ container_1 ✓ running Up 1 ho 0.00.000 ──────────────────────────────────────────────────────────────────────────╮ ││▶ pause │" Hidden by multi-width symbols: [(2, " ")]
"│ container_2 ✓ running Up 2 ho│ │ ││ restart │"
"│ container_3 ✓ running Up 3 ho│ 88 │ ││ stop │"
"│ │ 88 │ ││ delete │"
"│ │ 88 │ ││ │"
"╰────────────────────────────────────│ 88 │────────────────────╯╰──────────────╯"
"╭ Logs 3/3 - container_1 - image_1 ──│ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │────────────────────────────────────╮"
"│ line 1 │ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │ │"
"│ line 2 │ 8b d8 )888( 8888[ 8PP""""""" 88 │ │"
"│▶ line 3 │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ │"
"│ │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ │"
"╰────────────────────────────────────│ ,adPPYba, 8b, ,d8 88 ,d8 ,adPPYba, 8b,dPPYba, │────────────────────╯╰──────────────╯"
"╭ Logs 3/3 - container_1 - image_1 ──│ a8" "8a `Y8, ,8P' 88 ,a8" a8P_____88 88P' "Y8 │────────────────────────────────────╮"
"│ line 1 │ 8b d8 )888( 8888[ 8PP""""""" 88 │ │"
"│ line 2 │ "8a, ,a8" ,d8" "8b, 88`"Yba, "8b, ,aa 88 │ │"
"│▶ line 3 │ `"YbbdP"' 8P' `Y8 88 `Y8a `"Ybbd8"' 88 │ │"
"│ │ │ │"
"│ │ A simple tui to view & control docker containers │ │"
"│ │ │ │"
"│ │ ( tab ) or ( shift+tab ) change panels │ │"
"│ │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) change selected line │ │"
"│ │ ( ↑ ↓ ) or ( j k ) or ( PgUp PgDown ) or ( Home End ) scroll vertically │ │"
"│ │ ( ← → ) horizontal scroll across logs │ │"
"│ │ ( ctrl ) increase scroll speed, used in conjuction scroll keys │ │"
"│ │ ( enter ) send docker container command │ │"
"│ │ ( e ) exec into a container │ │"
"│ │ ( f ) force clear the screen & redraw the gui │ │"
@@ -38,7 +38,7 @@ expression: setup.terminal.backend()
"│ │ •• • │ currently an early work in progress, all and any input appreciated │ ││127.0.0.1 8003 8003│"
"│ │ • • │ https://github.com/mrjackwills/oxker │ ││ │"
"│ │ •• • • │ │ ││ │"
"│ │• •• ╰────────────────────────────────────────────────────────────────────────────────────╯ ││ │"
"│ │• • ││ │• • ││ │"
"│ │• •• │ │ ││ │"
"│ │• • ╰────────────────────────────────────────────────────────────────────────────────────╯ ││ │"
"│ │ ││ │ ││ │"
"╰───────────────────────────────────────────────────────────────╯╰───────────────────────────────────────────────────────────────╯╰────────────────────────────╯"
+4 -1
View File
@@ -255,7 +255,10 @@ impl Ui {
event::MouseEventKind::Down(_)
| event::MouseEventKind::ScrollDown
| event::MouseEventKind::ScrollUp => {
self.input_tx.send(InputMessages::MouseEvent(m)).await.ok();
self.input_tx
.send(InputMessages::MouseEvent((m, m.modifiers)))
.await
.ok();
}
_ => (),
}