From patchwork Mon Jun 20 22:58:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2106 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 8DBA823E52 for ; Mon, 20 Jun 2011 22:59:02 +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 5E856A1805E for ; Mon, 20 Jun 2011 22:59:02 +0000 (UTC) Received: by mail-vx0-f180.google.com with SMTP id 7so2987210vxd.11 for ; Mon, 20 Jun 2011 15:59:02 -0700 (PDT) Received: by 10.52.168.65 with SMTP id zu1mr3860215vdb.207.1308610742082; Mon, 20 Jun 2011 15:59:02 -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 em2cs32820vdc; Mon, 20 Jun 2011 15:59:01 -0700 (PDT) Received: by 10.227.172.78 with SMTP id k14mr5484665wbz.1.1308610739726; Mon, 20 Jun 2011 15:58:59 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by mx.google.com with ESMTP id fr1si10269039wbb.73.2011.06.20.15.58.58; Mon, 20 Jun 2011 15:58:58 -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 yNyp1g00347kPVY03NyxDa; Tue, 21 Jun 2011 00:58:58 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 17/17] handle the scrolling with the search result list Date: Tue, 21 Jun 2011 00:58:25 +0200 Message-Id: <1308610705-23281-17-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 --- display.c | 29 +++++++++++++++++++++-------- 1 files changed, 21 insertions(+), 8 deletions(-) diff --git a/display.c b/display.c index e1d1325..8f442c1 100644 --- a/display.c +++ b/display.c @@ -281,9 +281,10 @@ struct find_data { char *string; regex_t *reg; int ocursor; + int oscrolling; }; -struct find_data *display_find_form_init(void) +struct find_data *display_find_init(void) { const char *regexp = "^[a-z|0-9|_|-|.]"; struct find_data *findd; @@ -318,8 +319,12 @@ struct find_data *display_find_form_init(void) * browse the search result */ findd->ocursor = windata[current_win].cursor; + findd->oscrolling = windata[current_win].scrolling; + windata[current_win].cursor = 0; + windata[current_win].scrolling = 0; + curs_set(1); out: return findd; @@ -333,12 +338,13 @@ out_free_reg: goto out; } -static void display_find_form_fini(struct find_data *fd) +static void display_find_fini(struct find_data *findd) { - windata[current_win].cursor = fd->ocursor; - regfree(fd->reg); - free(fd->string); - free(fd); + windata[current_win].cursor = findd->ocursor; + windata[current_win].scrolling = findd->oscrolling; + regfree(findd->reg); + free(findd->string); + free(findd); curs_set(0); } @@ -346,7 +352,7 @@ static int display_switch_to_find(int fd) { struct find_data *findd; - findd = display_find_form_init(); + findd = display_find_init(); if (!findd) return -1; @@ -439,7 +445,7 @@ static int display_find_keystroke(int fd, void *data) switch (keystroke) { case '\e': - display_find_form_fini(findd); + display_find_fini(findd); return display_switch_to_main(fd); case KEY_DOWN: @@ -453,6 +459,10 @@ static int display_find_keystroke(int fd, void *data) case KEY_BACKSPACE: if (strlen(string)) string[strlen(string) - 1] = '\0'; + + windata[current_win].cursor = 0; + windata[current_win].scrolling = 0; + break; case '\r': @@ -473,6 +483,9 @@ static int display_find_keystroke(int fd, void *data) if (strlen(string) < findd->len - 1) string[strlen(string)] = (char)keystroke; + windata[current_win].cursor = 0; + windata[current_win].scrolling = 0; + break; }