aboutsummaryrefslogtreecommitdiff
path: root/display.c
diff options
context:
space:
mode:
authorAmit Arora <amit.arora@linaro.org>2010-10-07 13:51:53 +0530
committerAmit Arora <amit.arora@linaro.org>2010-10-07 13:51:53 +0530
commitc93e07180c85ff75949238d681caf88c09da3e5e (patch)
treea06dfc58a93831b7c31dc11fdef46433b48bf6a2 /display.c
parent6a943ecbcd933e2c40973590db7255e8dd9102ff (diff)
Add Tabs for various features
Diffstat (limited to 'display.c')
-rw-r--r--display.c162
1 files changed, 58 insertions, 104 deletions
diff --git a/display.c b/display.c
index bb5fb69..11bf45e 100644
--- a/display.c
+++ b/display.c
@@ -23,6 +23,7 @@ static WINDOW *header_win;
static WINDOW *regulator_win;
static WINDOW *clock_win;
static WINDOW *sensor_win;
+static WINDOW *selected_win;
static WINDOW *footer_win;
int maxx, maxy;
@@ -33,9 +34,10 @@ void fini_curses(void) {
endwin();
}
-void killall_windows(void)
+/* "all" : Kill header and footer windows too ? */
+void killall_windows(int all)
{
- if (header_win) {
+ if (all && header_win) {
delwin(header_win);
header_win = NULL;
}
@@ -51,7 +53,7 @@ void killall_windows(void)
delwin(sensor_win);
sensor_win = NULL;
}
- if (footer_win) {
+ if (all && footer_win) {
delwin(footer_win);
footer_win = NULL;
}
@@ -70,7 +72,8 @@ void init_curses(void)
init_pair(PT_COLOR_DEFAULT, COLOR_WHITE, COLOR_BLACK);
init_pair(PT_COLOR_ERROR, COLOR_BLACK, COLOR_RED);
- init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
+ //init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_WHITE);
+ init_pair(PT_COLOR_HEADER_BAR, COLOR_BLACK, COLOR_GREEN);
init_pair(PT_COLOR_YELLOW, COLOR_WHITE, COLOR_YELLOW);
init_pair(PT_COLOR_GREEN, COLOR_WHITE, COLOR_GREEN);
init_pair(PT_COLOR_BRIGHT, COLOR_WHITE, COLOR_BLACK);
@@ -85,7 +88,7 @@ void create_windows(void)
{
getmaxyx(stdscr, maxy, maxx);
- killall_windows();
+ killall_windows(1);
header_win = subwin(stdscr, 1, maxx, 0, 0);
// regulator_win = subwin(stdscr, maxy/2 - 2, maxx, 1, 0);
@@ -101,98 +104,59 @@ void create_windows(void)
}
-/*
- * maxrows is the MAXIMUM number of rows we need for this window
- * pshare is the minimum number of rows we should have for this (in %age)
- * maxrows prevails in case of an argument !
- */
-int create_regulator_win(int row, int maxrows, int *pshare)
+void create_selectedwindow(void)
{
- int numrows;
- int idealrows; // Based on pshare provided to us
+ WINDOW *win;
- if (regulator_win) {
- delwin(regulator_win);
- regulator_win = NULL;
- }
+ killall_windows(0);
getmaxyx(stdscr, maxy, maxx);
- idealrows = ((maxy - 2) * (*pshare)) / 100;
- if (maxrows < idealrows) {
- numrows = maxrows;
- *pshare = (numrows * 100) / maxy;
- } else
- numrows = idealrows;
- regulator_win = subwin(stdscr, numrows, maxx, row, 0);
-
- refresh();
-
- return numrows + row;
-}
-
-int create_clock_win(int row, int maxrows, int *pshare)
-{
- int numrows;
- int idealrows;
-
- if (clock_win) {
- delwin(clock_win);
- clock_win = NULL;
- }
-
- getmaxyx(stdscr, maxy, maxx);
- idealrows = ((maxy - 2) * (*pshare)) / 100;
-
- if (maxrows < idealrows)
- numrows = maxrows;
- else
- numrows = idealrows;
- clock_win = subwin(stdscr, numrows, maxx, row, 0);
-
- refresh();
+ win = subwin(stdscr, maxy - 2, maxx, 1, 0);
- return numrows + row;
-}
+ switch (selectedwindow) {
+ case REGULATOR: regulator_win = win;
+ break;
-int create_sensor_win(int row, int maxrows, int *pshare)
-{
- int numrows;
- int idealrows;
+ case CLOCK: clock_win = win;
+ break;
- if (sensor_win) {
- delwin(sensor_win);
- sensor_win = NULL;
+ case SENSOR: sensor_win = win;
+ break;
}
- getmaxyx(stdscr, maxy, maxx);
- idealrows = ((maxy - 2) * (*pshare)) / 100;
-
- if (maxrows < idealrows)
- numrows = maxrows;
- else
- numrows = idealrows;
- sensor_win = subwin(stdscr, numrows, maxx, row, 0);
-
+ selected_win = win;
+
refresh();
-
- return numrows + row;
}
void show_header(void)
{
int i, j = 0;
+ //char format[64];
wattrset(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR));
wbkgd(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR));
werase(header_win);
- print(header_win, 0, 0, "PowerDebug version %s (C) Linaro",
+ print(header_win, 0, 0, "PowerDebug %s",
VERSION);
- print(header_win, 50, 0, "Refresh Rate %4.2f Secs",
- ticktime);
+ //print(header_win, 50, 0, "Refresh Rate %4.2f Secs", ticktime);
+
+ for (i = 0; i < TOTAL_FEATURE_WINS; i++) {
+ if (selectedwindow == i)
+ wattron(header_win, A_REVERSE);
+ else
+ wattroff(header_win, A_REVERSE);
+
+ //sprintf(format, " %%-%ds ", sizeof(win_names[i]) + 2);
+ //sprintf(format, " %%s ");
+
+ print(header_win, i*(maxx / TOTAL_FEATURE_WINS) + 20, 0,
+ " %s ", win_names[i]);
+ }
+ wrefresh(header_win);
- wrefresh(header_win);
werase(footer_win);
@@ -210,21 +174,18 @@ void show_header(void)
void show_regulator_info(int verbose)
{
- int i, count = 2;
+ int i, count = 1;
werase(regulator_win);
wattron(regulator_win, A_BOLD);
- wattron(regulator_win, A_STANDOUT);
- print(regulator_win, 0, 0, "Regulator Information");
- wattroff(regulator_win, A_STANDOUT);
- print(regulator_win, 0, 1, "Name");
- print(regulator_win, 12, 1, "Status");
- print(regulator_win, 24, 1, "State");
- print(regulator_win, 36, 1, "Type");
- print(regulator_win, 48, 1, "Users");
- print(regulator_win, 60, 1, "Microvolts");
- print(regulator_win, 72, 1, "Min u-volts");
- print(regulator_win, 84, 1, "Max u-volts");
+ print(regulator_win, 0, 0, "Name");
+ print(regulator_win, 12, 0, "Status");
+ print(regulator_win, 24, 0, "State");
+ print(regulator_win, 36, 0, "Type");
+ print(regulator_win, 48, 0, "Users");
+ print(regulator_win, 60, 0, "Microvolts");
+ print(regulator_win, 72, 0, "Min u-volts");
+ print(regulator_win, 84, 0, "Max u-volts");
wattroff(regulator_win, A_BOLD);
for (i=0; i<numregulators; i++) {
@@ -273,14 +234,10 @@ void print_clock_header(int level)
sprintf(lev, "(Level %d)\n", level);
werase(clock_win);
wattron(clock_win, A_BOLD);
- wattron(clock_win, A_STANDOUT);
- print(clock_win, 0, 0, "Clock Information");
- wattroff(clock_win, A_STANDOUT);
- print(clock_win, 0, 1, "Name");
- print(clock_win, 24, 1, "Flags");
- print(clock_win, 36, 1, "Rate");
- print(clock_win, 48, 1, "Usecount");
- print(clock_win, 60, 1, lev);
+ print(clock_win, 0, 0, "Name %s", lev);
+ print(clock_win, 48, 0, "Flags");
+ print(clock_win, 60, 0, "Rate");
+ print(clock_win, 72, 0, "Usecount");
wattroff(clock_win, A_BOLD);
wrefresh(clock_win);
}
@@ -289,14 +246,11 @@ void print_sensor_header(void)
{
werase(sensor_win);
wattron(sensor_win, A_BOLD);
- wattron(sensor_win, A_STANDOUT);
- print(sensor_win, 0, 0, "Sensor Information");
- wattroff(sensor_win, A_STANDOUT);
- print(sensor_win, 0, 1, "Name");
- print(sensor_win, 36, 1, "Temperature");
+ print(sensor_win, 0, 0, "Name");
+ print(sensor_win, 36, 0, "Temperature");
wattroff(sensor_win, A_BOLD);
wattron(sensor_win, A_BLINK);
- print(sensor_win, 0, 2, "Currently Sensor information available"
+ print(sensor_win, 0, 1, "Currently Sensor information available"
" only in Dump mode!");
wattroff(sensor_win, A_BLINK);
wrefresh(sensor_win);
@@ -317,11 +271,11 @@ void print_clock_info_line(int line, char *clockname, int flags, int rate,
else
wattroff(clock_win, WA_REVERSE);
- print(clock_win, 0, line + 2, "%s", clockname);
+ print(clock_win, 0, line + 1, "%s", clockname);
if (strcmp(clockname, "..")) {
- print(clock_win, 24, line + 2, "%d", flags);
- print(clock_win, 36, line + 2, "%d", rate);
- print(clock_win, 48, line + 2, "%d", usecount);
+ print(clock_win, 48, line + 1, "%d", flags);
+ print(clock_win, 60, line + 1, "%d", rate);
+ print(clock_win, 72, line + 1, "%d", usecount);
}
if (highlight)