From patchwork Wed Jun 15 13:50:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1933 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 E78E424B34 for ; Wed, 15 Jun 2011 13:52:43 +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 B6293A18972 for ; Wed, 15 Jun 2011 13:52:43 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so416308vws.11 for ; Wed, 15 Jun 2011 06:52:43 -0700 (PDT) Received: by 10.52.168.65 with SMTP id zu1mr795648vdb.207.1308145963532; Wed, 15 Jun 2011 06:52:43 -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 em2cs126637vdc; Wed, 15 Jun 2011 06:52:43 -0700 (PDT) Received: by 10.227.170.74 with SMTP id c10mr621254wbz.104.1308145961906; Wed, 15 Jun 2011 06:52:41 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by mx.google.com with ESMTP id fs11si1368156wbb.137.2011.06.15.06.52.41; Wed, 15 Jun 2011 06:52:41 -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 wDsa1g00D1hMfSL03DsgCv; Wed, 15 Jun 2011 15:52:41 +0200 From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org Subject: [powerdebug 11/22] Encapsulate the display (4) Date: Wed, 15 Jun 2011 15:50:45 +0200 Message-Id: <1308145856-6112-11-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> Remove the old "findparent" code. Signed-off-by: Daniel Lezcano --- powerdebug.c | 60 +++++---------------------------------------------------- 1 files changed, 6 insertions(+), 54 deletions(-) diff --git a/powerdebug.c b/powerdebug.c index f73aafe..5109c90 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -153,13 +153,10 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) return 0; } -int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, - char *clkname_str, bool *refreshwin, - struct powerdebug_options *options) +int keystroke_callback(bool *enter_hit, struct powerdebug_options *options) { char keychar; int keystroke = getch(); - int oldselectedwin = options->selectedwindow; if (keystroke == EOF) exit(0); @@ -176,68 +173,24 @@ int keystroke_callback(bool *enter_hit, bool *findparent_ncurses, if (keystroke == KEY_UP) display_prev_line(); - if (options->selectedwindow == CLOCK) { - -#if 0 - /* TODO : fix with a new panel applicable for all subsystems */ - if (keystroke == '/') - *findparent_ncurses = true; -#endif - - if ((keystroke == '\e' || oldselectedwin != - options->selectedwindow) && *findparent_ncurses) { - *findparent_ncurses = false; - clkname_str[0] = '\0'; - } - - if (*findparent_ncurses && keystroke != '\r') { - int len = strlen(clkname_str); - char str[2]; - - if (keystroke == KEY_BACKSPACE) { - if (len > 0) - len--; - - clkname_str[len] = '\0'; - } else { - if (strlen(clkname_str) || - keystroke != '/') { - str[0] = keystroke; - str[1] = '\0'; - if (len < 63) - strcat(clkname_str, - str); - } - } - } - } - keychar = toupper(keystroke); -//#define DEBUG -#ifdef DEBUG - fini_curses(); - printf("key entered %d:%c\n", keystroke, keychar); - exit(1); -#endif if (keystroke == '\r') *enter_hit = true; - if (keychar == 'Q' && !*findparent_ncurses) + if (keychar == 'Q') return 1; + if (keychar == 'R') { - *refreshwin = true; + /* TODO refresh window */ options->ticktime = 3; - } else - *refreshwin = false; + } return 0; } int mainloop(struct powerdebug_options *options) { - bool findparent_ncurses = false; - bool refreshwin = false; bool enter_hit = false; char clkname_str[64]; @@ -278,8 +231,7 @@ int mainloop(struct powerdebug_options *options) break; } - if (keystroke_callback(&enter_hit, &findparent_ncurses, - clkname_str, &refreshwin, options)) + if (keystroke_callback(&enter_hit, options)) break; }