From patchwork Mon Jun 20 22:58:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2100 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 BD9D123E52 for ; Mon, 20 Jun 2011 22:58:59 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 8E433A18276 for ; Mon, 20 Jun 2011 22:58:59 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so4124077vws.11 for ; Mon, 20 Jun 2011 15:58:59 -0700 (PDT) Received: by 10.52.98.97 with SMTP id eh1mr8205134vdb.7.1308610739341; Mon, 20 Jun 2011 15:58:59 -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 em2cs32815vdc; Mon, 20 Jun 2011 15:58:59 -0700 (PDT) Received: by 10.216.236.157 with SMTP id w29mr57158weq.18.1308610736859; Mon, 20 Jun 2011 15:58:56 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by mx.google.com with ESMTP id t71si14003738weq.17.2011.06.20.15.58.56; Mon, 20 Jun 2011 15:58:56 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.125 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.125; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.125 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.95.191]) by mwinf5d06 with ME id yNyp1g00347kPVY03NyvDH; Tue, 21 Jun 2011 00:58:56 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 13/17] add a select callback on a clock from the search result Date: Tue, 21 Jun 2011 00:58:21 +0200 Message-Id: <1308610705-23281-13-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308610705-23281-1-git-send-email-daniel.lezcano@linaro.org> References: <1308610705-23281-1-git-send-email-daniel.lezcano@linaro.org> Signed-off-by: Daniel Lezcano --- clocks.c | 28 +++++++++++++++++++++------- display.c | 11 ++++++++--- display.h | 1 + 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/clocks.c b/clocks.c index 2ae2f5a..6943b70 100644 --- a/clocks.c +++ b/clocks.c @@ -243,6 +243,10 @@ static int _clock_print_info_cb(struct tree *t, void *data) int *line = data; char *buffer; + /* we skip the root node of the tree */ + if (!t->parent) + return 0; + buffer = clock_line(t); if (!buffer) return -1; @@ -258,10 +262,6 @@ static int _clock_print_info_cb(struct tree *t, void *data) static int clock_print_info_cb(struct tree *t, void *data) { - /* we skip the root node of the tree */ - if (!t->parent) - return 0; - /* show the clock when *all* its parent is expanded */ if (tree_for_each_parent(t->parent, is_collapsed, NULL)) return 0; @@ -300,7 +300,7 @@ static int clock_print_info(struct tree *tree) return ret; } -static int clock_toggle_expanded(void) +static int clock_select(void) { struct tree *t = display_get_row_data(CLOCK); struct clock_info *clk = t->private; @@ -323,7 +323,7 @@ static int clock_display(void) return clock_print_info(clock_tree); } -int clock_find(const char *name) +static int clock_find(const char *name) { struct tree **ptree = NULL; int i, nr, line = 0, ret = 0; @@ -350,6 +350,19 @@ int clock_find(const char *name) return ret; } +static int clock_selectf(void) +{ + struct tree *t = display_get_row_data(CLOCK); + int line = 0; + + display_reset_cursor(CLOCK); + + if (tree_for_each_parent(t, _clock_print_info_cb, &line)) + return -1; + + return display_refresh_pad(CLOCK); +} + /* * Read the clock information and fill the tree with the information * found in the files. Then dump to stdout a formatted result. @@ -379,8 +392,9 @@ int clock_dump(char *clk) static struct display_ops clock_ops = { .display = clock_display, - .select = clock_toggle_expanded, + .select = clock_select, .find = clock_find, + .selectf = clock_selectf, }; /* diff --git a/display.c b/display.c index 1dc11dd..38596b0 100644 --- a/display.c +++ b/display.c @@ -447,9 +447,14 @@ static int display_find_keystroke(int fd, void *data) string[strlen(string) - 1] = '\0'; break; - case KEY_ENTER: - /* next patch */ - break; + case '\r': + if (!windata[current_win].ops || !windata[current_win].ops->selectf) + return 0; + + if (windata[current_win].ops->selectf()) + return -1; + + return 0; default: diff --git a/display.h b/display.h index fe084cb..7fa5361 100644 --- a/display.h +++ b/display.h @@ -19,6 +19,7 @@ struct display_ops { int (*display)(void); int (*select)(void); int (*find)(const char *); + int (*selectf)(void); }; extern int display_print_line(int window, int line, char *str,