[powerdebug,05/17] remove maxx and maxy global variables

Message ID 1308610705-23281-5-git-send-email-daniel.lezcano@linaro.org
State Accepted
Headers show

Commit Message

Daniel Lezcano June 20, 2011, 10:58 p.m.
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 <daniel.lezcano@linaro.org>
---
 display.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Patch

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;