Skip to content

Commit

Permalink
tools/thermal: tmon: tui: don't hard-code dialog window size assumptions
Browse files Browse the repository at this point in the history
We can use the ncurses API to get the number of rows.

Signed-off-by: Brian Norris <[email protected]>
Acked-by: Jacob Pan <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Signed-off-by: Zhang Rui <[email protected]>
  • Loading branch information
computersforpeace authored and zhang-rui committed Feb 28, 2015
1 parent a90b6b0 commit 0e7b766
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/thermal/tmon/tui.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,14 @@ const char DIAG_TITLE[] = "[ TUNABLES ]";
void show_dialogue(void)
{
int j, x = 0, y = 0;
int rows, cols;
WINDOW *w = dialogue_window;

if (tui_disabled || !w)
return;

getmaxyx(w, rows, cols);

werase(w);
box(w, 0, 0);
mvwprintw(w, 0, maxx/4, DIAG_TITLE);
Expand All @@ -297,10 +300,8 @@ void show_dialogue(void)
wattron(w, A_BOLD);
mvwprintw(w, DIAG_DEV_ROWS+1, 1, "Enter Choice [A-Z]?");
wattroff(w, A_BOLD);
/* y size of dialogue win is nr cdev + 5, so print legend
* at the bottom line
*/
mvwprintw(w, ptdata.nr_cooling_dev+3, 1,
/* print legend at the bottom line */
mvwprintw(w, rows - 2, 1,
"Legend: A=Active, P=Passive, C=Critical");

wrefresh(dialogue_window);
Expand Down

0 comments on commit 0e7b766

Please sign in to comment.