statusbar prompt. New functions do_statusbar_next_word() and
do_statusbar_prev_word(); changes to do_statusbar_input().
(DLR)
+ - Make resizing more flexible. We now can work with as few as
+ one row, and with no limit on the number of columns (except of
+ course the curses-imposed limit that it be greater than zero).
+ New function resize_variables(); changes to die_too_small()
+ (renamed check_die_too_small()), global_init(), window_init(),
+ and handle_sigwinch(). (David Benbennick) DLR: Tweak the
+ coordinate formula in window_init() so that the statusbar
+ prompt is always visible.
+ - Use void instead of RETSIGTYPE, as signal handlers are
+ supposed to return void anyway. Also, the value of RETSIGTYPE
+ is sometimes misdetected as int, leading to compilation
+ warnings or errors. (David Benbennick)
- cut.c:
do_cut_text()
- If keep_cutbuffer is FALSE, only blow away the text in the
- nano.h:
- Remove now-unneeded #defines for functions that now have
multibyte equivalents. (DLR)
+ - Remove now-unneeded MIN_EDITOR_COLS. (David Benbennick)
- utils.c:
regexec_safe()
- Remove redundant regexec #define, and move the regexec #undef
/* Pointer to end of justify buffer. */
#endif
+void print_view_warning(void)
+{
+ statusbar(_("Key illegal in VIEW mode"));
+}
+
/* What we do when we're all set to exit. */
void finish(void)
{
/* Die with an error message that the screen was too small if, well, the
* screen is too small. */
-void die_too_small(void)
+void check_die_too_small(void)
{
- die(_("Window size is too small for nano...\n"));
+ editwinrows = LINES - 5 + no_more_space() + no_help();
+ if (editwinrows < MIN_EDITOR_ROWS)
+ die(_("Window size is too small for nano...\n"));
}
-void print_view_warning(void)
+/* Reassign variables that depend on the window size. That is, fill and
+ * hblank. */
+void resize_variables(void)
{
- statusbar(_("Key illegal in VIEW mode"));
+#ifndef DISABLE_WRAPJUSTIFY
+ fill = wrap_at;
+ if (fill <= 0)
+ fill += COLS;
+ if (fill < 0)
+ fill = 0;
+#endif
+
+ hblank = charealloc(hblank, COLS + 1);
+ memset(hblank, ' ', COLS);
+ hblank[COLS] = '\0';
}
/* Initialize global variables -- no better way for now. If
* save_cutbuffer is TRUE, don't set cutbuffer to NULL. */
void global_init(bool save_cutbuffer)
{
- current_x = 0;
- current_y = 0;
-
- editwinrows = LINES - 5 + no_more_space() + no_help();
- if (editwinrows < MIN_EDITOR_ROWS || COLS < MIN_EDITOR_COLS)
- die_too_small();
+ check_die_too_small();
+ resize_variables();
fileage = NULL;
+ edittop = NULL;
+ current = NULL;
if (!save_cutbuffer)
cutbuffer = NULL;
- current = NULL;
- edittop = NULL;
+ current_x = 0;
+ placewewant = 0;
+ current_y = 0;
totlines = 0;
totsize = 0;
- placewewant = 0;
-
-#ifndef DISABLE_WRAPJUSTIFY
- fill = wrap_at;
- if (fill <= 0)
- fill += COLS;
- if (fill < 0)
- fill = 0;
-#endif
-
- hblank = charalloc(COLS + 1);
- memset(hblank, ' ', COLS);
- hblank[COLS] = '\0';
}
void window_init(void)
{
- editwinrows = LINES - 5 + no_more_space() + no_help();
- if (editwinrows < MIN_EDITOR_ROWS)
- die_too_small();
+ check_die_too_small();
if (topwin != NULL)
delwin(topwin);
/* Set up the windows. */
topwin = newwin(2 - no_more_space(), COLS, 0, 0);
edit = newwin(editwinrows, COLS, 2 - no_more_space(), 0);
- bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
+ bottomwin = newwin(3 - no_help(), COLS, editwinrows + 1, 0);
/* Turn the keypad back on. */
keypad(edit, TRUE);
}
#ifndef NANO_SMALL
-RETSIGTYPE cancel_fork(int signal)
+void cancel_fork(int signal)
{
if (kill(pid, SIGKILL) == -1)
nperror("kill");
}
/* Handler for SIGHUP (hangup) and SIGTERM (terminate). */
-RETSIGTYPE handle_hupterm(int signal)
+void handle_hupterm(int signal)
{
die(_("Received SIGHUP or SIGTERM\n"));
}
/* Handler for SIGTSTP (suspend). */
-RETSIGTYPE do_suspend(int signal)
+void do_suspend(int signal)
{
endwin();
printf("\n\n\n\n\n%s\n", _("Use \"fg\" to return to nano"));
}
/* Handler for SIGCONT (continue after suspend). */
-RETSIGTYPE do_cont(int signal)
+void do_cont(int signal)
{
#ifndef NANO_SMALL
/* Perhaps the user resized the window while we slept. Handle it
* But not in all cases, argh. */
COLS = win.ws_col;
LINES = win.ws_row;
- editwinrows = LINES - 5 + no_more_space() + no_help();
- if (editwinrows < MIN_EDITOR_ROWS || COLS < MIN_EDITOR_COLS)
- die_too_small();
-
-#ifndef DISABLE_WRAPJUSTIFY
- fill = wrap_at;
- if (fill <= 0)
- fill += COLS;
- if (fill < 0)
- fill = 0;
-#endif
- hblank = charealloc(hblank, COLS + 1);
- memset(hblank, ' ', COLS);
- hblank[COLS] = '\0';
+ check_die_too_small();
+ resize_variables();
/* If we've partitioned the filestruct, unpartition it now. */
if (filepart != NULL)
void do_right_void(void);
/* Public functions in nano.c. */
+void print_view_warning(void);
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename);
-void die_too_small(void);
-void print_view_warning(void);
+void check_die_too_small(void);
+void resize_variables(void);
void global_init(bool save_cutbuffer);
void window_init(void);
#ifndef DISABLE_MOUSE
int no_help(void);
void nano_disabled_msg(void);
#ifndef NANO_SMALL
-RETSIGTYPE cancel_fork(int signal);
+void cancel_fork(int signal);
bool open_pipe(const char *command);
#endif
void do_verbatim_input(void);
#endif /* !DISABLE_JUSTIFY */
void do_exit(void);
void signal_init(void);
-RETSIGTYPE handle_hupterm(int signal);
-RETSIGTYPE do_suspend(int signal);
-RETSIGTYPE do_cont(int signal);
+void handle_hupterm(int signal);
+void do_suspend(int signal);
+void do_cont(int signal);
#ifndef NANO_SMALL
void handle_sigwinch(int s);
void allow_pending_sigwinch(bool allow);