commit 0dd2a5528499efbcc07f1666eac2bd2e7822b077
parent 49fc528d88c6b11670fe213c66c93a1d06d14b80
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 15 Aug 2016 12:55:03 +0200
screen: don't die when the window is narrower than four columns
This fixes https://savannah.gnu.org/bugs/?48520.
Diffstat:
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -692,9 +692,11 @@ void die_save_file(const char *die_filename, struct stat *die_stat)
/* Initialize the three window portions nano uses. */
void window_init(void)
{
- /* If the screen height is too small, get out. */
+ /* Compute how many lines the edit subwindow will have. */
editwinrows = LINES - TOP_ROWS - BOTTOM_ROWS;
- if (COLS < MIN_EDITOR_COLS || editwinrows < MIN_EDITOR_ROWS)
+
+ /* If there is no room to show anything, give up. */
+ if (editwinrows <= 0)
die(_("Window size is too small for nano...\n"));
#ifndef DISABLE_WRAPJUSTIFY
diff --git a/src/nano.h b/src/nano.h
@@ -576,11 +576,6 @@ enum
/* The maximum number of entries displayed in the main shortcut list. */
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
-/* The minimum editor window columns and rows required for nano to work
- * correctly. Don't make these smaller than 4 and 1. */
-#define MIN_EDITOR_COLS 4
-#define MIN_EDITOR_ROWS 1
-
/* The default number of characters from the end of the line where
* wrapping occurs. */
#define CHARS_FROM_EOL 8
diff --git a/src/winio.c b/src/winio.c
@@ -2048,12 +2048,13 @@ void bottombars(int menu)
slen = MAIN_VISIBLE;
}
- /* There will be this many characters per column, except for the
- * last two, which will be longer by (COLS % colwidth) columns so as
- * to not waste space. We need at least three columns to display
- * anything properly. */
+ /* Compute the width of each keyname-plus-explanation pair. */
colwidth = COLS / ((slen / 2) + (slen % 2));
+ /* If there is no room, don't print anything. */
+ if (colwidth == 0)
+ return;
+
blank_bottombars();
#ifdef DEBUG