diff mbox

[powerdebug,14/22] Encapsulate the display (7)

Message ID 1308145856-6112-14-git-send-email-daniel.lezcano@linaro.org
State Accepted
Headers show

Commit Message

Daniel Lezcano June 15, 2011, 1:50 p.m. UTC
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 display.c |   36 ++++++++++++++++++++++++++----------
 display.h |   15 +++++++++++++++
 2 files changed, 41 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/display.c b/display.c
index d55d748..92fc02a 100644
--- a/display.c
+++ b/display.c
@@ -218,6 +218,22 @@  int display_register(int win, struct display_ops *ops)
 	return 0;
 }
 
+int display_refresh(void)
+{
+	if (windata[current_win].ops && windata[current_win].ops->display)
+		return windata[current_win].ops->display();
+
+	return 0;
+}
+
+int display_select(void)
+{
+	if (windata[current_win].ops && windata[current_win].ops->select)
+		return windata[current_win].ops->select();
+
+	return 0;
+}
+
 int display_next_panel(void)
 {
 	current_win++;
@@ -241,8 +257,8 @@  int display_refresh_pad(int win)
 			0, 2, 0, maxy - 2, maxx);
 }
 
-static int inline display_un_select(int win, int line,
-					  bool highlight, bool bold)
+static int inline display_show_un_selection(int win, int line,
+					    bool highlight, bool bold)
 {
 	if (mvwchgat(windata[win].pad, line, 0, -1,
 		     highlight ? WA_STANDOUT :
@@ -252,14 +268,14 @@  static int inline display_un_select(int win, int line,
 	return display_refresh_pad(win);
 }
 
-int display_select(int win, int line)
+int display_show_selection(int win, int line)
 {
-	return display_un_select(win, line, true, false);
+	return display_show_un_selection(win, line, true, false);
 }
 
-int display_unselect(int win, int line, bool bold)
+int display_show_unselection(int win, int line, bool bold)
 {
-	return display_un_select(win, line, false, bold);
+	return display_show_un_selection(win, line, false, bold);
 }
 
 void *display_get_row_data(int win)
@@ -326,13 +342,13 @@  int display_next_line(void)
 	if (cursor >= nrdata)
 		return cursor;
 
-	display_unselect(current_win, cursor, rowdata[cursor].attr);
+	display_show_unselection(current_win, cursor, rowdata[cursor].attr);
 	if (cursor < nrdata - 1) {
 		if (cursor >= (maxy - 4 + scrolling))
 			scrolling++;
 		cursor++;
 	}
-	display_select(current_win, cursor);
+	display_show_selection(current_win, cursor);
 
 	windata[current_win].scrolling = scrolling;
 	windata[current_win].cursor = cursor;
@@ -350,13 +366,13 @@  int display_prev_line(void)
 	if (cursor >= nrdata)
 		return cursor;
 
-	display_unselect(current_win, cursor, rowdata[cursor].attr);
+	display_show_unselection(current_win, cursor, rowdata[cursor].attr);
 	if (cursor > 0) {
 		if (cursor <= scrolling)
 			scrolling--;
 		cursor--;
 	}
-	display_select(current_win, cursor);
+	display_show_selection(current_win, cursor);
 
 	windata[current_win].scrolling = scrolling;
 	windata[current_win].cursor = cursor;
diff --git a/display.h b/display.h
index 1222b44..7e6b199 100644
--- a/display.h
+++ b/display.h
@@ -13,11 +13,20 @@ 
  *       - initial API and implementation
  *******************************************************************************/
 
+#define TOTAL_FEATURE_WINS 3  /* Regulator, Clock and Sensor (for now) */
+
 struct display_ops {
 	int (*display)(void);
 	int (*select)(void);
 };
 
+extern int display_print_line(int window, int line, char *str,
+			      int bold, void *data);
+
+extern int display_refresh_pad(int window);
+extern int display_reset_cursor(int window);
+extern void *display_get_row_data(int window);
+
 extern int display_init(int wdefault);
 extern int display_register(int win, struct display_ops *ops);
 extern int display_next_panel(void);
@@ -25,3 +34,9 @@  extern int display_prev_panel(void);
 extern int display_next_line(void);
 extern int display_prev_line(void);
 extern int display_refresh(void);
+extern int display_select(void);
+
+/* FIXME */
+extern void print_sensor_header(void);
+extern void print_clock_header(void);
+extern void print_regulator_header(void);