From df7353b312412e61653b11c76cd5b9f6adfff3a6 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 27 Jul 2016 12:25:18 +0200 Subject: [PATCH] tweaks: compute the sizes of the subwindows in a more direct manner --- src/nano.c | 27 +++++++-------------------- src/proto.h | 2 -- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/nano.c b/src/nano.c index 74e1e60a..062c97c4 100644 --- a/src/nano.c +++ b/src/nano.c @@ -689,11 +689,14 @@ void die_save_file(const char *die_filename free(targetname); } +#define TOP_ROWS (ISSET(MORE_SPACE) ? 1 : 2) +#define BOTTOM_ROWS (ISSET(NO_HELP) ? 1 : 3) + /* Initialize the three window portions nano uses. */ void window_init(void) { /* If the screen height is too small, get out. */ - editwinrows = LINES - 5 + more_space() + no_help(); + editwinrows = LINES - TOP_ROWS - BOTTOM_ROWS; if (COLS < MIN_EDITOR_COLS || editwinrows < MIN_EDITOR_ROWS) die(_("Window size is too small for nano...\n")); @@ -714,10 +717,9 @@ void window_init(void) delwin(bottomwin); /* Set up the windows. */ - topwin = newwin(2 - more_space(), COLS, 0, 0); - edit = newwin(editwinrows, COLS, 2 - more_space(), 0); - bottomwin = newwin(3 - no_help(), COLS, editwinrows + (2 - - more_space()), 0); + topwin = newwin(TOP_ROWS, COLS, 0, 0); + edit = newwin(editwinrows, COLS, TOP_ROWS, 0); + bottomwin = newwin(BOTTOM_ROWS, COLS, TOP_ROWS + editwinrows, 0); /* Turn the keypad on for the windows, if necessary. */ if (!ISSET(REBIND_KEYPAD)) { @@ -1043,21 +1045,6 @@ void version(void) printf("\n"); } -/* Return 1 if the MORE_SPACE flag is set, and 0 otherwise. This is - * used to calculate the sizes and Y coordinates of the subwindows. */ -int more_space(void) -{ - return ISSET(MORE_SPACE) ? 1 : 0; -} - -/* Return 2 if the NO_HELP flag is set, and 0 otherwise. This is used - * to calculate the sizes and Y coordinates of the subwindows, because - * having NO_HELP adds two lines to the edit window. */ -int no_help(void) -{ - return ISSET(NO_HELP) ? 2 : 0; -} - /* Indicate that the current file has no name, in a way that gets the * user's attention. This is used when trying to save a file with no * name with the TEMP_FILE flag set, just before the filename prompt. */ diff --git a/src/proto.h b/src/proto.h index 0d5bb34b..90e74ebd 100644 --- a/src/proto.h +++ b/src/proto.h @@ -476,8 +476,6 @@ void print_opt_full(const char *shortflag , const char *desc); void usage(void); void version(void); -int more_space(void); -int no_help(void); void no_current_file_name_warning(void); void do_exit(void); void close_and_go(void);