From patchwork Wed Jun 15 13:50:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1936 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1CED724B1C for ; Wed, 15 Jun 2011 13:52:45 +0000 (UTC) Received: from mail-vx0-f180.google.com (mail-vx0-f180.google.com [209.85.220.180]) by fiordland.canonical.com (Postfix) with ESMTP id DFE64A186F5 for ; Wed, 15 Jun 2011 13:52:44 +0000 (UTC) Received: by mail-vx0-f180.google.com with SMTP id 12so410110vxk.11 for ; Wed, 15 Jun 2011 06:52:44 -0700 (PDT) Received: by 10.52.95.194 with SMTP id dm2mr535803vdb.47.1308145964697; Wed, 15 Jun 2011 06:52:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.52.183.130 with SMTP id em2cs126642vdc; Wed, 15 Jun 2011 06:52:44 -0700 (PDT) Received: by 10.213.102.13 with SMTP id e13mr1159444ebo.23.1308145963260; Wed, 15 Jun 2011 06:52:43 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by mx.google.com with ESMTP id n24si1375717weq.143.2011.06.15.06.52.42; Wed, 15 Jun 2011 06:52:43 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.127; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.76.78]) by mwinf5d28 with ME id wDsa1g00D1hMfSL03DsiDH; Wed, 15 Jun 2011 15:52:42 +0200 From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org Subject: [powerdebug 14/22] Encapsulate the display (7) Date: Wed, 15 Jun 2011 15:50:48 +0200 Message-Id: <1308145856-6112-14-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> References: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano --- display.c | 36 ++++++++++++++++++++++++++---------- display.h | 15 +++++++++++++++ 2 files changed, 41 insertions(+), 10 deletions(-) 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);