PowerTOP UI navigation enhancement.
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 | 1 - src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 36 deletions(-)
src/cpu/abstract_cpu.cpp +0 -1
@@ -422,7 +422,6 @@ void abstract_cpu::validate(void) 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,
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;
Sergey Senozhatsky
Quoted 31 lines · 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 | 1 - src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 36 deletions(-)src/cpu/abstract_cpu.cpp +0
-0
src/cpu/abstract_cpu.cpp void abstract_cpu::validate(void) · line 427
Quoted 7 lines
src/cpu/abstract_cpu.cpp +0
-1@@ -422,7 +422,6 @@ void abstract_cpu::validate(void) 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,
not sure this will compile.
-ss
Quoted 239 lines
src/display.cpp +70
-28@@ -95,7 +95,7 @@ static int current_tab; void show_tab(unsigned int tab) { - WINDOW *win; + class tab_window *win; unsigned int i; int tab_pos = 17; const char *c;@@ -145,11 +145,11 @@ void show_tab(unsigned int tab) wrefresh(tab_bar); wrefresh(bottom_line); - win = get_ncurses_win(tab_names[tab]); + win = tab_windows[tab_names[tab]]; if (!win) return; - prefresh(win, 0, 0, 1, 0, LINES - 3, COLS - 1); + prefresh(win->win, win->ypad_pos, win->xpad_pos, 1, 0, LINES - 3, COLS - 1); } WINDOW *get_ncurses_win(const char *name)@@ -185,42 +185,41 @@ WINDOW *get_ncurses_win(const string &name) return get_ncurses_win(name.c_str()); } - -void show_next_tab(void) +void show_prev_tab(void) { - class tab_window *w; + class tab_window *w; - if (!display) - return; + if (!display) + return; + w = tab_windows[tab_names[current_tab]]; + if (w) + w->hide(); - w = tab_windows[tab_names[current_tab]]; - if (w) - w->hide(); + current_tab --; + if (current_tab < 0) + current_tab = tab_names.size() - 1; - current_tab ++; - if (current_tab >= (int)tab_names.size()) - current_tab = 0; - - w = tab_windows[tab_names[current_tab]]; - if (w) - w->expose(); + w = tab_windows[tab_names[current_tab]]; + if (w) + w->expose(); - show_tab(current_tab); + show_tab(current_tab); } -void show_prev_tab(void) +void show_next_tab(void) { class tab_window *w; if (!display) return; + w = tab_windows[tab_names[current_tab]]; if (w) w->hide(); - current_tab --; - if (current_tab < 0) - current_tab = tab_names.size() - 1; + current_tab ++; + if (current_tab >= (int)tab_names.size()) + current_tab = 0; w = tab_windows[tab_names[current_tab]]; if (w)@@ -241,8 +240,16 @@ void cursor_down(void) class tab_window *w; w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_down(); + if (w) { + if (tab_names[current_tab] == "Tunables") { + if ((w->cursor_pos + 7) >= LINES) { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + w->cursor_down(); + } else { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } show_cur_tab(); }@@ -253,12 +260,45 @@ void cursor_up(void) w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_up(); - + if (w) { + w->cursor_up(); + if(w->ypad_pos > 0) { + if (tab_names[current_tab] == "Tunables") { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } else { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } + } + show_cur_tab(); } +void cursor_left(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + if (w->xpad_pos > 0) { + prefresh(w->win, w->ypad_pos,--w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } +} + +void cursor_right(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + prefresh(w->win, w->ypad_pos, ++w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + +} + void cursor_enter(void) { class tab_window *w;@@ -279,6 +319,8 @@ void window_refresh() w = tab_windows[tab_names[current_tab]]; if (w) { + w->ypad_pos = 0; + w->xpad_pos = 0; w->window_refresh(); w->repaint(); }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;
Chris Ferron
Quoted 42 lines · Sergey Senozhatsky
Quoted 30 lines · 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 | 1 - src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 36 deletions(-)src/cpu/abstract_cpu.cpp +0
-0src/cpu/abstract_cpu.cpp void abstract_cpu::validate(void) · line 427
Quoted 7 lines
src/cpu/abstract_cpu.cpp +0
-1@@ -422,7 +422,6 @@ void abstract_cpu::validate(void) 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,not sure this will compile.
Quoted 1 line
-ss
Crap thanks, v2 on the way.
-C
Quoted 240 lines
Quoted 240 lines
src/display.cpp +70
-28@@ -95,7 +95,7 @@ static int current_tab; void show_tab(unsigned int tab) { - WINDOW *win; + class tab_window *win; unsigned int i; int tab_pos = 17; const char *c;@@ -145,11 +145,11 @@ void show_tab(unsigned int tab) wrefresh(tab_bar); wrefresh(bottom_line); - win = get_ncurses_win(tab_names[tab]); + win = tab_windows[tab_names[tab]]; if (!win) return; - prefresh(win, 0, 0, 1, 0, LINES - 3, COLS - 1); + prefresh(win->win, win->ypad_pos, win->xpad_pos, 1, 0, LINES - 3, COLS - 1); } WINDOW *get_ncurses_win(const char *name)@@ -185,42 +185,41 @@ WINDOW *get_ncurses_win(const string &name) return get_ncurses_win(name.c_str()); } - -void show_next_tab(void) +void show_prev_tab(void) { - class tab_window *w; + class tab_window *w; - if (!display) - return; + if (!display) + return; + w = tab_windows[tab_names[current_tab]]; + if (w) + w->hide(); - w = tab_windows[tab_names[current_tab]]; - if (w) - w->hide(); + current_tab --; + if (current_tab < 0) + current_tab = tab_names.size() - 1; - current_tab ++; - if (current_tab >= (int)tab_names.size()) - current_tab = 0; - - w = tab_windows[tab_names[current_tab]]; - if (w) - w->expose(); + w = tab_windows[tab_names[current_tab]]; + if (w) + w->expose(); - show_tab(current_tab); + show_tab(current_tab); } -void show_prev_tab(void) +void show_next_tab(void) { class tab_window *w; if (!display) return; + w = tab_windows[tab_names[current_tab]]; if (w) w->hide(); - current_tab --; - if (current_tab < 0) - current_tab = tab_names.size() - 1; + current_tab ++; + if (current_tab >= (int)tab_names.size()) + current_tab = 0; w = tab_windows[tab_names[current_tab]]; if (w)@@ -241,8 +240,16 @@ void cursor_down(void) class tab_window *w; w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_down(); + if (w) { + if (tab_names[current_tab] == "Tunables") { + if ((w->cursor_pos + 7) >= LINES) { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + w->cursor_down(); + } else { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } show_cur_tab(); }@@ -253,12 +260,45 @@ void cursor_up(void) w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_up(); - + if (w) { + w->cursor_up(); + if(w->ypad_pos > 0) { + if (tab_names[current_tab] == "Tunables") { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } else { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } + } + show_cur_tab(); } +void cursor_left(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + if (w->xpad_pos > 0) { + prefresh(w->win, w->ypad_pos,--w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } +} + +void cursor_right(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + prefresh(w->win, w->ypad_pos, ++w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + +} + void cursor_enter(void) { class tab_window *w;@@ -279,6 +319,8 @@ void window_refresh() w = tab_windows[tab_names[current_tab]]; if (w) { + w->ypad_pos = 0; + w->xpad_pos = 0; w->window_refresh(); w->repaint(); }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;
Sergey Senozhatsky
Quoted 42 lines · Chris Ferron
Quoted 41 lines · Sergey Senozhatsky
Quoted 30 lines · 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 | 1 - src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 36 deletions(-)src/cpu/abstract_cpu.cpp +0
-0src/cpu/abstract_cpu.cpp void abstract_cpu::validate(void) · line 426
Quoted 6 lines
src/cpu/abstract_cpu.cpp +0
-1@@ -422,7 +422,6 @@ void abstract_cpu::validate(void) 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,not sure this will compile.
Quoted 3 lines
Quoted 1 line
-ssCrap thanks, v2 on the way.
-C
no problem
Quoted 180 lines
Quoted 180 lines
Quoted 180 lines
src/display.cpp +70
-28@@ -95,7 +95,7 @@ static int current_tab; void show_tab(unsigned int tab) { - WINDOW *win; + class tab_window *win; unsigned int i; int tab_pos = 17; const char *c;@@ -145,11 +145,11 @@ void show_tab(unsigned int tab) wrefresh(tab_bar); wrefresh(bottom_line); - win = get_ncurses_win(tab_names[tab]); + win = tab_windows[tab_names[tab]]; if (!win) return; - prefresh(win, 0, 0, 1, 0, LINES - 3, COLS - 1); + prefresh(win->win, win->ypad_pos, win->xpad_pos, 1, 0, LINES - 3, COLS - 1); } WINDOW *get_ncurses_win(const char *name)@@ -185,42 +185,41 @@ WINDOW *get_ncurses_win(const string &name) return get_ncurses_win(name.c_str()); } - -void show_next_tab(void) +void show_prev_tab(void) { - class tab_window *w; + class tab_window *w; - if (!display) - return; + if (!display) + return; + w = tab_windows[tab_names[current_tab]]; + if (w) + w->hide(); - w = tab_windows[tab_names[current_tab]]; - if (w) - w->hide(); + current_tab --; + if (current_tab < 0) + current_tab = tab_names.size() - 1; - current_tab ++; - if (current_tab >= (int)tab_names.size()) - current_tab = 0; - - w = tab_windows[tab_names[current_tab]]; - if (w) - w->expose(); + w = tab_windows[tab_names[current_tab]]; + if (w) + w->expose(); - show_tab(current_tab); + show_tab(current_tab); } -void show_prev_tab(void) +void show_next_tab(void) { class tab_window *w; if (!display) return; + w = tab_windows[tab_names[current_tab]]; if (w) w->hide(); - current_tab --; - if (current_tab < 0) - current_tab = tab_names.size() - 1; + current_tab ++; + if (current_tab >= (int)tab_names.size()) + current_tab = 0; w = tab_windows[tab_names[current_tab]]; if (w)@@ -241,8 +240,16 @@ void cursor_down(void) class tab_window *w; w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_down(); + if (w) { + if (tab_names[current_tab] == "Tunables") { + if ((w->cursor_pos + 7) >= LINES) { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + w->cursor_down(); + } else { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } show_cur_tab(); }@@ -253,12 +260,45 @@ void cursor_up(void) w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_up(); - + if (w) { + w->cursor_up(); + if(w->ypad_pos > 0) { + if (tab_names[current_tab] == "Tunables") { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } else { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } + } + show_cur_tab(); } +void cursor_left(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + if (w->xpad_pos > 0) { + prefresh(w->win, w->ypad_pos,--w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } +} + +void cursor_right(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + prefresh(w->win, w->ypad_pos, ++w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + +} + void cursor_enter(void) { class tab_window *w;@@ -279,6 +319,8 @@ void window_refresh() w = tab_windows[tab_names[current_tab]]; if (w) { + w->ypad_pos = 0; + w->xpad_pos = 0; w->window_refresh(); w->repaint(); }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 +0
-0
Quoted 8 lines
Quoted 8 lines
src/main.cpp static void do_sleep(int seconds) · line 137
Quoted 8 lines
index cf47b4e..edc4147 100644
src/main.cpp +1
-1@@ -135,22 +135,29 @@ static void do_sleep(int seconds) halfdelay(delta * 10); c = getch(); - + printf("c (%i)", c);
could we please push debug output to stderr, for example, and run 'powertop 2 > cursor_pos_log'. printf() just messes with ncurses output.
-ss
Quoted 31 lines
Quoted 30 lines
Quoted 30 lines
src/main.cpp +11
-4switch (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;
Ferron
Quoted 244 lines · Sergey Senozhatsky
Quoted 42 lines · Chris Ferron
Quoted 41 lines · Sergey Senozhatsky
Quoted 30 lines · 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 | 1 - src/display.cpp | 98 ++++++++++++++++++++++++++++++++++-------------- src/display.h | 13 ++++++- src/main.cpp | 17 ++++++--- 4 files changed, 93 insertions(+), 36 deletions(-)src/cpu/abstract_cpu.cpp +0
-0src/cpu/abstract_cpu.cpp void abstract_cpu::validate(void) · line 426
Quoted 6 lines
src/cpu/abstract_cpu.cpp +0
-1@@ -422,7 +422,6 @@ void abstract_cpu::validate(void) 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,not sure this will compile.
Quoted 3 lines
Quoted 1 line
-ssCrap thanks, v2 on the way.
-Cno problem
Quoted 180 lines
Quoted 180 lines
Quoted 180 lines
src/display.cpp +70
-28@@ -95,7 +95,7 @@ static int current_tab; void show_tab(unsigned int tab) { - WINDOW *win; + class tab_window *win; unsigned int i; int tab_pos = 17; const char *c;@@ -145,11 +145,11 @@ void show_tab(unsigned int tab) wrefresh(tab_bar); wrefresh(bottom_line); - win = get_ncurses_win(tab_names[tab]); + win = tab_windows[tab_names[tab]]; if (!win) return; - prefresh(win, 0, 0, 1, 0, LINES - 3, COLS - 1); + prefresh(win->win, win->ypad_pos, win->xpad_pos, 1, 0, LINES - 3, COLS - 1); } WINDOW *get_ncurses_win(const char *name)@@ -185,42 +185,41 @@ WINDOW *get_ncurses_win(const string &name) return get_ncurses_win(name.c_str()); } - -void show_next_tab(void) +void show_prev_tab(void) { - class tab_window *w; + class tab_window *w; - if (!display) - return; + if (!display) + return; + w = tab_windows[tab_names[current_tab]]; + if (w) + w->hide(); - w = tab_windows[tab_names[current_tab]]; - if (w) - w->hide(); + current_tab --; + if (current_tab < 0) + current_tab = tab_names.size() - 1; - current_tab ++; - if (current_tab >= (int)tab_names.size()) - current_tab = 0; - - w = tab_windows[tab_names[current_tab]]; - if (w) - w->expose(); + w = tab_windows[tab_names[current_tab]]; + if (w) + w->expose(); - show_tab(current_tab); + show_tab(current_tab); } -void show_prev_tab(void) +void show_next_tab(void) { class tab_window *w; if (!display) return; + w = tab_windows[tab_names[current_tab]]; if (w) w->hide(); - current_tab --; - if (current_tab < 0) - current_tab = tab_names.size() - 1; + current_tab ++; + if (current_tab >= (int)tab_names.size()) + current_tab = 0; w = tab_windows[tab_names[current_tab]]; if (w)@@ -241,8 +240,16 @@ void cursor_down(void) class tab_window *w; w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_down(); + if (w) { + if (tab_names[current_tab] == "Tunables") { + if ((w->cursor_pos + 7) >= LINES) { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + w->cursor_down(); + } else { + prefresh(w->win, ++w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } show_cur_tab(); }@@ -253,12 +260,45 @@ void cursor_up(void) w = tab_windows[tab_names[current_tab]]; - if (w) - w->cursor_up(); - + if (w) { + w->cursor_up(); + if(w->ypad_pos > 0) { + if (tab_names[current_tab] == "Tunables") { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } else { + prefresh(w->win, --w->ypad_pos, w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } + } + show_cur_tab(); } +void cursor_left(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + if (w->xpad_pos > 0) { + prefresh(w->win, w->ypad_pos,--w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + } +} + +void cursor_right(void) +{ + class tab_window *w; + + w = tab_windows[tab_names[current_tab]]; + + if (w) { + prefresh(w->win, w->ypad_pos, ++w->xpad_pos, 1, 0, LINES - 3, COLS - 1); + } + +} + void cursor_enter(void) { class tab_window *w;@@ -279,6 +319,8 @@ void window_refresh() w = tab_windows[tab_names[current_tab]]; if (w) { + w->ypad_pos = 0; + w->xpad_pos = 0; w->window_refresh(); w->repaint(); }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 +0
-0Quoted 8 lines
Quoted 8 lines
src/main.cpp static void do_sleep(int seconds) · line 137
Quoted 8 lines
index cf47b4e..edc4147 100644
src/main.cpp +1
-1@@ -135,22 +135,29 @@ static void do_sleep(int seconds) halfdelay(delta * 10); c = getch(); - + printf("c (%i)", c);could we please push debug output to stderr, for example, and run 'powertop 2 >
cursor_pos_log'.printf()just messes with ncurses output.
Quoted 1 line
-ss
Yes absolutely.
-C
Quoted 37 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
src/main.cpp +10
-4switch (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:Quoted 9 lines
Quoted 8 lines
src/main.cpp static void do_sleep(int seconds)
Quoted 8 lines
src/main.cpp +1
-0case KEY_UP: cursor_up(); break; + case 32: case 10: cursor_enter(); break;_______________________________________________
PowerTop mailing list
PowerTop(a)lists.01.org
https://lists.01.org/mailman/listinfo/powertop