From 1bbd0487b06605899df5fe03741d47d15cf97f5a Mon Sep 17 00:00:00 2001 From: Felix Lu Date: Thu, 24 Mar 2016 11:41:51 -0400 Subject: [PATCH] Monitor mode: add faster output scrolling hotkeys --- man/stap.1.in | 4 ++-- staprun/monitor.c | 32 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/man/stap.1.in b/man/stap.1.in index c91717d8f..0252da136 100644 --- a/man/stap.1.in +++ b/man/stap.1.in @@ -813,8 +813,8 @@ Hides/shows the status window. This allows for more output to be seen. .TP .BI navigation-keys The j/k/ArrowDown/ArrowUp keys can be used to scroll through the probe -list and the d/u/PageDown/PageUp keys can be used to scroll through the -module output. +list and the d,D/u,U/PageDown,End/PageUp,Home keys can be used to scroll +through the module output. .RE .SH ARGUMENTS diff --git a/staprun/monitor.c b/staprun/monitor.c index 006f0bfca..3a4df704c 100644 --- a/staprun/monitor.c +++ b/staprun/monitor.c @@ -233,7 +233,7 @@ void monitor_render(void) if (resized) handle_resize(); - /* Adjust scrolling to window height */ + /* Bound scrolling by window height and entry count */ getmaxyx(monitor_output, max_rows, max_cols); output_scroll = MIN(MAX(0, h_queue.count-max_rows+1), output_scroll); @@ -269,10 +269,9 @@ void monitor_render(void) wprintw(monitor_status, "p/r - Pause/Resume script by toggling off/on all probes.\n"); wprintw(monitor_status, "x - Hide/Show the status window.\n"); wprintw(monitor_status, "q - Quit script.\n"); - wprintw(monitor_status, "j/DownArrow - Scroll down the probe list.\n"); - wprintw(monitor_status, "k/UpArrow - Scroll up the probe list.\n"); - wprintw(monitor_status, "d/PageDown - Scroll down the output by one page.\n"); - wprintw(monitor_status, "u/PageUp - Scroll up the probe list by one page.\n"); + wprintw(monitor_status, "j,k/DownArrow,UpArrow - Scroll down/up the probe list.\n"); + wprintw(monitor_status, "d,D/PageDown,End - Scroll down the output by one page/end.\n"); + wprintw(monitor_status, "u,U/PageUp,Home - Scroll up the output by one page/beginning.\n"); mvwprintw(monitor_status, max_rows-1, 0, "press h to go back\n"); wrefresh(monitor_status); } @@ -285,10 +284,9 @@ void monitor_render(void) wprintw(monitor_status, "h - Display help page.\n"); wprintw(monitor_status, "s - Rotate sort columns for probes.\n"); wprintw(monitor_status, "q - Quit script.\n"); - wprintw(monitor_status, "j/DownArrow - Scroll down the probe list.\n"); - wprintw(monitor_status, "k/UpArrow - Scroll up the probe list.\n"); - wprintw(monitor_status, "d/PageDown - Scroll down the output by one page.\n"); - wprintw(monitor_status, "u/PageUp - Scroll up the probe list by one page.\n"); + wprintw(monitor_status, "j,k/DownArrow,UpArrow - Scroll down/up the probe list.\n"); + wprintw(monitor_status, "d,D/PageDown,End - Scroll down the output by one page/end.\n"); + wprintw(monitor_status, "u,U/PageUp,Home - Scroll up the output by one page/beginning.\n"); mvwprintw(monitor_status, max_rows-1, 0, "press h to go back\n"); wrefresh(monitor_status); } @@ -534,24 +532,32 @@ void monitor_input(void) ch = getch(); switch (ch) { - case 'j': /* Fallthrough */ + case 'j': case KEY_DOWN: probe_scroll++; break; - case 'k': /* Fallthrough */ + case 'k': case KEY_UP: probe_scroll--; probe_scroll = MAX(0, probe_scroll); break; - case 'd': /* Fallthrough */ + case 'd': case KEY_NPAGE: output_scroll -= max_rows-1; output_scroll = MAX(0, output_scroll); break; - case 'u': /* Fallthrough */ + case 'u': case KEY_PPAGE: output_scroll += max_rows-1; break; + case KEY_HOME: + case 'U': + output_scroll = h_queue.count-max_rows+1; + break; + case KEY_END: + case 'D': + output_scroll = 0; + break; case 's': comp_fn_index++; if (comp_fn_index == COMP_FNS) -- 2.43.5