add DB's (slightly tweaked) changes to make resizing more flexible, and

also add his replacement of RETSIGTYPE with void, which avoids some
potential problems


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2289 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-01-19 19:52:42 +00:00
parent b80077dae3
commit 5040666fbb
4 changed files with 62 additions and 60 deletions

View File

@ -128,6 +128,18 @@ CVS code -
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
@ -186,6 +198,7 @@ CVS code -
- 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

View File

@ -79,6 +79,11 @@ static filestruct *jusbottom = NULL;
/* 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)
{
@ -178,36 +183,17 @@ void die_save_file(const char *die_filename)
/* 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"));
}
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
}
/* 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();
fileage = NULL;
if (!save_cutbuffer)
cutbuffer = NULL;
current = NULL;
edittop = NULL;
totlines = 0;
totsize = 0;
placewewant = 0;
if (editwinrows < MIN_EDITOR_ROWS)
die(_("Window size is too small for nano...\n"));
}
/* Reassign variables that depend on the window size. That is, fill and
* hblank. */
void resize_variables(void)
{
#ifndef DISABLE_WRAPJUSTIFY
fill = wrap_at;
if (fill <= 0)
@ -216,16 +202,33 @@ void global_init(bool save_cutbuffer)
fill = 0;
#endif
hblank = charalloc(COLS + 1);
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)
{
check_die_too_small();
resize_variables();
fileage = NULL;
edittop = NULL;
current = NULL;
if (!save_cutbuffer)
cutbuffer = NULL;
current_x = 0;
placewewant = 0;
current_y = 0;
totlines = 0;
totsize = 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);
@ -237,7 +240,7 @@ void window_init(void)
/* 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);
@ -1054,7 +1057,7 @@ void nano_disabled_msg(void)
}
#ifndef NANO_SMALL
RETSIGTYPE cancel_fork(int signal)
void cancel_fork(int signal)
{
if (kill(pid, SIGKILL) == -1)
nperror("kill");
@ -3259,13 +3262,13 @@ void signal_init(void)
}
/* 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"));
@ -3285,7 +3288,7 @@ RETSIGTYPE do_suspend(int signal)
}
/* 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
@ -3321,21 +3324,9 @@ void handle_sigwinch(int s)
* 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)

View File

@ -501,10 +501,7 @@ typedef struct historyheadtype {
#define NOVIEW FALSE
/* Minimum editor window rows required for nano to work correctly. */
#define MIN_EDITOR_ROWS 3
/* Minimum editor window cols required for nano to work correctly. */
#define MIN_EDITOR_COLS 10
#define MIN_EDITOR_ROWS 1
/* Default number of characters from end-of-line where text wrapping
* occurs. */

View File

@ -343,11 +343,12 @@ void do_right(bool allow_update);
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
@ -380,7 +381,7 @@ int no_more_space(void);
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);
@ -428,9 +429,9 @@ void do_full_justify(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);