PowerTOP UI navigation enhancement(v2).
Chris Ferron
This patch add more ui navigation features allowing for the scrolling of PowerTop content for each tab. This is done by controlling the location of the winpad, and refreshing the terminal window when needed. To do this, the navigation keys have been updated as follows.
"Arrow Keys" now scroll the tab windows
"Page up/down" scroll tab windows up and down "TAB" cycles the next window tab
"SHIFT+TAB" cycles the previous window tab "ENTER" toggles tunables
"SPACE BAR" toggles tunables
"r KEY" refresh results and resets view of tab window.
Known issues:
There is no handler for terminal re-sizing. The workaround is to use "r KEY" to refresh if terminal windows size is changed mid session.
--- src/cpu/abstract_cpu.cpp | 6 --- src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 41 deletions(-)
src/cpu/abstract_cpu.cpp +0 -6
@@ -421,12 +421,6 @@ void abstract_cpu::validate(void) for (i = 0; i < children.size(); i++) { if (children[i]) { - if (my_time != children[i]->total_pstate_time()) - printf("My (%i) time %llu is not the same as child (%i) time %llu\n", - first_cpu, - (unsigned long long)my_time, - children[i]->number, - (unsigned long long)children[i]->total_pstate_time()); children[i]->validate(); } }
src/display.cpp +70 -28
156 lines not on this page · raw message
src/display.h +11 -2
@@ -41,6 +41,8 @@ extern void show_prev_tab(void);extern void show_cur_tab (void );extern void cursor_up (void );extern void cursor_down (void ); +extern void cursor_right (void ); +extern void cursor_left (void );extern void cursor_enter (void );extern void window_refresh (void );
@@ -48,10 +50,17 @@ class tab_window { public:int cursor_pos;int cursor_max; +int xpad_pos, ypad_pos;WINDOW *win; - virtual void cursor_down(void) { if (cursor_pos < cursor_max ) cursor_pos++; repaint(); } ; - virtual void cursor_up(void) { if (cursor_pos > 0) cursor_pos--; repaint(); }; + virtual void cursor_down(void) { +if (cursor_pos < cursor_max ) cursor_pos++;repaint (); + } ; + virtual void cursor_up(void) { +if (cursor_pos >0 ) cursor_pos--;repaint (); + }; + virtual void cursor_left(void) { }; + virtual void cursor_right(void) { }; virtual void cursor_enter(void) { }; virtual void window_refresh() { };
src/main.cpp +12 -5
@@ -135,22 +135,29 @@ static void do_sleep(int seconds) halfdelay(delta * 10); c = getch(); - + printf("c (%i)", c); switch (c) { - case KEY_NPAGE: + case 353: + show_prev_tab(); + break; + case 9: + show_next_tab(); + break; case KEY_RIGHT: - show_next_tab(); + cursor_right(); break; - case KEY_PPAGE: case KEY_LEFT: - show_prev_tab(); + cursor_left(); break; + case KEY_NPAGE: case KEY_DOWN: cursor_down(); break; + case KEY_PPAGE: case KEY_UP: cursor_up(); break; + case 32: case 10: cursor_enter(); break;