- Added message for when keypad goes awry. Added code in main and
function print_numlock_warning() to notify user, and added an
apropriate section in the faq to refer to this brokenness.
+ - Added macros in nano.h for magic values that might be unclear in
+ nano.c:global_init().
- configure.in:
- Fix for _use_keypad check breaking slang support (Christian
Weisgerber).
usage()
- Alternate speller option no longer valid if DISABLE_SPELLER is
active. (Rocco)
+ window_init(), handle_sigwinch()
+ - Added check for not having enough LINES to do anything useful,
+ if so die with an error. (Rocco)
+ die_too_small()
+ - Function to print the window too small error message, avoids
+ repeated string defs and globals.
- fi.po:
- Update by Pauli Virtanen.
exit(1); /* We have a problem: exit w/ errorlevel(1) */
}
+/* Die with an error message that the screen was too small if, well, the
+ screen is too small */
+void die_too_small(void)
+{
+ char *too_small_msg = _("Window size is too small for Nano...");
+
+ die(too_small_msg);
+
+}
+
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
center_y = LINES / 2;
current_x = 0;
current_y = 0;
- editwinrows = LINES - 5 + no_help();
+
+ if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
+ die_too_small();
+
fileage = NULL;
cutbuffer = NULL;
current = NULL;
editbot = NULL;
totlines = 0;
placewewant = 0;
+
if (!fill)
- fill = COLS - 8;
+ fill = COLS - CHARS_FROM_EOL;
+
+ if (fill < MIN_FILL_LENGTH)
+ die_too_small();
+
hblank = nmalloc(COLS + 1);
/* Thanks BG for this bit... */
center_x = COLS / 2;
center_y = LINES / 2;
- editwinrows = LINES - 5 + no_help();
- fill = COLS - 8;
+
+ if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
+ die_too_small();
+
+ if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH)
+ die_too_small();
free(hblank);
hblank = nmalloc(COLS + 1);
void window_init(void)
{
- editwinrows = LINES - 5 + no_help();
+ if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
+ die_too_small();
/* Setup up the main text window */
edit = newwin(editwinrows, COLS, 2, 0);
#define TOP 2
#define CENTER 1
#define BOTTOM 0
-#endif
+
+/* Minimum editor window rows required for Nano to work correctly */
+#define MIN_EDITOR_ROWS 3
+
+/* Default number of characters from end-of-line where text wrapping occurs */
+#define CHARS_FROM_EOL 8
+
+/* Minimum fill length (space available for text before wrapping occurs) */
+#define MIN_FILL_LENGTH 10
+
+#endif /* ifndef NANO_H */