From patchwork Mon Jun 20 22:58:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 2092 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 06BE423E52 for ; Mon, 20 Jun 2011 22:58:55 +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 CBFA5A182CD for ; Mon, 20 Jun 2011 22:58:54 +0000 (UTC) Received: by vxd7 with SMTP id 7so2987210vxd.11 for ; Mon, 20 Jun 2011 15:58:54 -0700 (PDT) Received: by 10.52.168.65 with SMTP id zu1mr3860074vdb.207.1308610734288; Mon, 20 Jun 2011 15:58:54 -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 em2cs32802vdc; Mon, 20 Jun 2011 15:58:53 -0700 (PDT) Received: by 10.227.55.74 with SMTP id t10mr271341wbg.91.1308610732791; Mon, 20 Jun 2011 15:58:52 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp03.smtpout.orange.fr [80.12.242.125]) by mx.google.com with ESMTP id d13si10245137wbh.132.2011.06.20.15.58.52; Mon, 20 Jun 2011 15:58:52 -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 yNyp1g00347kPVY03NyrCr; Tue, 21 Jun 2011 00:58:52 +0200 From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 05/17] remove maxx and maxy global variables Date: Tue, 21 Jun 2011 00:58:13 +0200 Message-Id: <1308610705-23281-5-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> The maxx and maxy variables are already global functions defined in the ncurses library. They are accessible through the getmaxyx macro. Is it not needed to add two more global variables to our code, let's use the code ncurses gives to us. Signed-off-by: Daniel Lezcano --- display.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/display.c b/display.c index 1af12a3..bd5971a 100644 --- a/display.c +++ b/display.c @@ -37,8 +37,6 @@ static WINDOW *footer_win; static WINDOW *main_win; static int current_win; -int maxx, maxy; - /* Number of lines in the virtual window */ static const int maxrows = 1024; @@ -119,6 +117,10 @@ int display_refresh(int win) int display_refresh_pad(int win) { + int maxx, maxy; + + getmaxyx(stdscr, maxy, maxx); + return prefresh(windata[win].pad, windata[win].scrolling, 0, 2, 0, maxy - 2, maxx); } @@ -168,11 +170,14 @@ static int display_prev_panel(void) static int display_next_line(void) { + int maxx, maxy; int cursor = windata[current_win].cursor; int nrdata = windata[current_win].nrdata; int scrolling = windata[current_win].scrolling; struct rowdata *rowdata = windata[current_win].rowdata; + getmaxyx(stdscr, maxy, maxx); + if (cursor >= nrdata) return cursor; @@ -309,7 +314,7 @@ static int display_keystroke(int fd, void *data) int display_init(int wdefault) { - int i; + int i, maxx, maxy; size_t array_size = sizeof(windata) / sizeof(windata[0]); current_win = wdefault;