From patchwork Mon Jun 20 22:58:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2095 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 920B923E52 for ; Mon, 20 Jun 2011 22:58:56 +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 62972A182D4 for ; Mon, 20 Jun 2011 22:58:56 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so4124077vws.11 for ; Mon, 20 Jun 2011 15:58:56 -0700 (PDT) Received: by 10.52.175.197 with SMTP id cc5mr4324584vdc.287.1308610736147; Mon, 20 Jun 2011 15:58:56 -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 em2cs32806vdc; Mon, 20 Jun 2011 15:58:55 -0700 (PDT) Received: by 10.216.231.165 with SMTP id l37mr5203425weq.78.1308610734313; Mon, 20 Jun 2011 15:58:54 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by mx.google.com with ESMTP id i13si13983583wed.119.2011.06.20.15.58.53; Mon, 20 Jun 2011 15:58:54 -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 yNyp1g00347kPVY03NytD2; Tue, 21 Jun 2011 00:58:53 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 08/17] Add the find callback Date: Tue, 21 Jun 2011 00:58:16 +0200 Message-Id: <1308610705-23281-8-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> Switch the keyboard callback when we switch to the find mode. Signed-off-by: Daniel Lezcano --- display.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) diff --git a/display.c b/display.c index d32783f..758d17e 100644 --- a/display.c +++ b/display.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "powerdebug.h" #include "mainloop.h" #include "regulator.h" @@ -266,6 +267,19 @@ int display_print_line(int win, int line, char *str, int bold, void *data) return 0; } +static int display_find_keystroke(int fd, void *data); + +static int display_switch_to_find(int fd) +{ + if (mainloop_del(fd)) + return -1; + + if (mainloop_add(fd, display_find_keystroke, NULL)) + return -1; + + return 0; +} + static int display_keystroke(int fd, void *data) { int keystroke = getch(); @@ -299,6 +313,9 @@ static int display_keystroke(int fd, void *data) case 'Q': return 1; + case '/': + return display_switch_to_find(fd); + case 'r': case 'R': /* refresh will be done after */ @@ -312,6 +329,35 @@ static int display_keystroke(int fd, void *data) return 0; } +static int display_switch_to_main(int fd) +{ + if (mainloop_del(fd)) + return -1; + + if (mainloop_add(fd, display_keystroke, NULL)) + return -1; + + display_refresh(current_win); + + return 0; +} + + +static int display_find_keystroke(int fd, void *data) +{ + int keystroke = getch(); + + switch (keystroke) { + + case '\e': + return display_switch_to_main(fd); + default: + break; + } + + return 0; +} + int display_init(int wdefault) { int i, maxx, maxy;