allow unjustifying if we resize the window immediately after justifying,
as Pico does, and make input handling across resizes more consistent git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3495 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
d29e861376
commit
fc0f8f8c57
|
@ -70,6 +70,11 @@ CVS code -
|
||||||
text and the first and last file in the file browser via
|
text and the first and last file in the file browser via
|
||||||
Meta-\ (Meta-|) and Meta-/ (Meta-?). Changes to do_browser(),
|
Meta-\ (Meta-|) and Meta-/ (Meta-?). Changes to do_browser(),
|
||||||
shortcut_init(), and do_help(). (DLR)
|
shortcut_init(), and do_help(). (DLR)
|
||||||
|
- Allow unjustifying if we resize the window immediately after
|
||||||
|
justifying, as Pico does, and make input handling across
|
||||||
|
resizes more consistent. Changes to handle_sigwinch(),
|
||||||
|
main(), get_kbinput(), parse_kbinput(), get_byte_kbinput(),
|
||||||
|
and get_unicode_kbinput(); removal of reset_kbinput(). (DLR)
|
||||||
- browser.c:
|
- browser.c:
|
||||||
do_browser()
|
do_browser()
|
||||||
- Reference NANO_GOTODIR_(ALT|F)?KEY instead of
|
- Reference NANO_GOTODIR_(ALT|F)?KEY instead of
|
||||||
|
|
10
src/global.c
10
src/global.c
|
@ -23,7 +23,13 @@
|
||||||
|
|
||||||
#include "proto.h"
|
#include "proto.h"
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables. */
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
sigjmp_buf jmpbuf;
|
||||||
|
/* Used to return to main() or the unjustify routine in
|
||||||
|
* do_justify() after a SIGWINCH. */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_WRAPJUSTIFY
|
#ifndef DISABLE_WRAPJUSTIFY
|
||||||
ssize_t fill = 0;
|
ssize_t fill = 0;
|
||||||
/* The column where we will wrap lines. */
|
/* The column where we will wrap lines. */
|
||||||
|
@ -188,7 +194,7 @@ filestruct *replacebot = NULL;
|
||||||
/* The bottom of the replace string history list. */
|
/* The bottom of the replace string history list. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Regular expressions */
|
/* Regular expressions. */
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
regex_t search_regexp;
|
regex_t search_regexp;
|
||||||
/* The compiled regular expression to use in searches. */
|
/* The compiled regular expression to use in searches. */
|
||||||
|
|
32
src/nano.c
32
src/nano.c
|
@ -40,10 +40,6 @@
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
#include <setjmp.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ENABLE_NANORC
|
#ifdef ENABLE_NANORC
|
||||||
static bool no_rcfiles = FALSE;
|
static bool no_rcfiles = FALSE;
|
||||||
/* Should we ignore all rcfiles? */
|
/* Should we ignore all rcfiles? */
|
||||||
|
@ -53,11 +49,6 @@ static struct termios oldterm;
|
||||||
static struct sigaction act;
|
static struct sigaction act;
|
||||||
/* For all our fun signal handlers. */
|
/* For all our fun signal handlers. */
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
static sigjmp_buf jmpbuf;
|
|
||||||
/* Used to return to main() after a SIGWINCH. */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Create a new filestruct node. Note that we specifically do not set
|
/* Create a new filestruct node. Note that we specifically do not set
|
||||||
* prevnode->next equal to the new line. */
|
* prevnode->next equal to the new line. */
|
||||||
filestruct *make_new_node(filestruct *prevnode)
|
filestruct *make_new_node(filestruct *prevnode)
|
||||||
|
@ -1060,16 +1051,6 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||||
if (filepart != NULL)
|
if (filepart != NULL)
|
||||||
unpartition_filestruct(&filepart);
|
unpartition_filestruct(&filepart);
|
||||||
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
|
||||||
/* If the justify buffer isn't empty, blow away the text in it and
|
|
||||||
* display the shortcut list with UnCut. */
|
|
||||||
if (jusbuffer != NULL) {
|
|
||||||
free_filestruct(jusbuffer);
|
|
||||||
jusbuffer = NULL;
|
|
||||||
shortcut_init(FALSE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_SLANG
|
#ifdef USE_SLANG
|
||||||
/* Slang curses emulation brain damage, part 1: If we just do what
|
/* Slang curses emulation brain damage, part 1: If we just do what
|
||||||
* curses does here, it'll only work properly if the resize made the
|
* curses does here, it'll only work properly if the resize made the
|
||||||
|
@ -1100,9 +1081,6 @@ RETSIGTYPE handle_sigwinch(int signal)
|
||||||
currshortcut = main_list;
|
currshortcut = main_list;
|
||||||
total_refresh();
|
total_refresh();
|
||||||
|
|
||||||
/* Reset all the input routines that rely on character sequences. */
|
|
||||||
reset_kbinput();
|
|
||||||
|
|
||||||
/* Jump back to the main loop. */
|
/* Jump back to the main loop. */
|
||||||
siglongjmp(jmpbuf, 1);
|
siglongjmp(jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
@ -2147,11 +2125,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
display_main_list();
|
display_main_list();
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
/* Return here after a SIGWINCH. */
|
|
||||||
sigsetjmp(jmpbuf, 1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
display_buffer();
|
display_buffer();
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
@ -2160,6 +2133,11 @@ int main(int argc, char **argv)
|
||||||
/* Make sure the cursor is in the edit window. */
|
/* Make sure the cursor is in the edit window. */
|
||||||
reset_cursor();
|
reset_cursor();
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
/* Return here after a SIGWINCH. */
|
||||||
|
sigsetjmp(jmpbuf, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* If constant cursor position display is on, and there are no
|
/* If constant cursor position display is on, and there are no
|
||||||
* keys waiting in the input buffer, display the current cursor
|
* keys waiting in the input buffer, display the current cursor
|
||||||
* position on the statusbar. */
|
* position on the statusbar. */
|
||||||
|
|
|
@ -100,6 +100,9 @@
|
||||||
#ifdef HAVE_REGEX_H
|
#ifdef HAVE_REGEX_H
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
#include <setjmp.h>
|
||||||
|
#endif
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/* If no vsnprintf(), use the version from glib 2.x. */
|
/* If no vsnprintf(), use the version from glib 2.x. */
|
||||||
|
@ -412,6 +415,7 @@ typedef struct rcoption {
|
||||||
#define NANO_CONTROL_7 31
|
#define NANO_CONTROL_7 31
|
||||||
#define NANO_CONTROL_8 127
|
#define NANO_CONTROL_8 127
|
||||||
|
|
||||||
|
/* Meta key sequences. */
|
||||||
#define NANO_ALT_SPACE ' '
|
#define NANO_ALT_SPACE ' '
|
||||||
#define NANO_ALT_LPARENTHESIS '('
|
#define NANO_ALT_LPARENTHESIS '('
|
||||||
#define NANO_ALT_RPARENTHESIS ')'
|
#define NANO_ALT_RPARENTHESIS ')'
|
||||||
|
@ -607,11 +611,12 @@ typedef struct rcoption {
|
||||||
#define TOGGLE_MAC_KEY NANO_ALT_M
|
#define TOGGLE_MAC_KEY NANO_ALT_M
|
||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
|
|
||||||
#define MAIN_VISIBLE 12
|
|
||||||
|
|
||||||
#define VIEW TRUE
|
#define VIEW TRUE
|
||||||
#define NOVIEW FALSE
|
#define NOVIEW FALSE
|
||||||
|
|
||||||
|
/* The maximum number of entries displayed in the main shortcut list. */
|
||||||
|
#define MAIN_VISIBLE 12
|
||||||
|
|
||||||
/* The minimum editor window columns and rows required for nano to work
|
/* The minimum editor window columns and rows required for nano to work
|
||||||
* correctly. */
|
* correctly. */
|
||||||
#define MIN_EDITOR_COLS 4
|
#define MIN_EDITOR_COLS 4
|
||||||
|
|
25
src/proto.h
25
src/proto.h
|
@ -27,6 +27,10 @@
|
||||||
#include "nano.h"
|
#include "nano.h"
|
||||||
|
|
||||||
/* Public externs. See global.c for descriptions of them. */
|
/* Public externs. See global.c for descriptions of them. */
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
extern sigjmp_buf jmpbuf;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_WRAPJUSTIFY
|
#ifndef DISABLE_WRAPJUSTIFY
|
||||||
extern ssize_t fill;
|
extern ssize_t fill;
|
||||||
extern ssize_t wrap_at;
|
extern ssize_t wrap_at;
|
||||||
|
@ -708,33 +712,18 @@ void dump_filestruct_reverse(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Public functions in winio.c. */
|
/* Public functions in winio.c. */
|
||||||
#ifndef NANO_TINY
|
|
||||||
void reset_kbinput(void);
|
|
||||||
#endif
|
|
||||||
void get_key_buffer(WINDOW *win);
|
void get_key_buffer(WINDOW *win);
|
||||||
size_t get_key_buffer_len(void);
|
size_t get_key_buffer_len(void);
|
||||||
void unget_input(int *input, size_t input_len);
|
void unget_input(int *input, size_t input_len);
|
||||||
void unget_kbinput(int kbinput, bool meta_key, bool func_key);
|
void unget_kbinput(int kbinput, bool meta_key, bool func_key);
|
||||||
int *get_input(WINDOW *win, size_t input_len);
|
int *get_input(WINDOW *win, size_t input_len);
|
||||||
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||||
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key
|
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||||
#ifndef NANO_TINY
|
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool
|
int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool
|
||||||
*ignore_seq);
|
*ignore_seq);
|
||||||
int get_escape_seq_abcd(int kbinput);
|
int get_escape_seq_abcd(int kbinput);
|
||||||
int get_byte_kbinput(int kbinput
|
int get_byte_kbinput(int kbinput);
|
||||||
#ifndef NANO_TINY
|
long get_unicode_kbinput(int kbinput);
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
long get_unicode_kbinput(int kbinput
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
int get_control_kbinput(int kbinput);
|
int get_control_kbinput(int kbinput);
|
||||||
void unparse_kbinput(char *output, size_t output_len);
|
void unparse_kbinput(char *output, size_t output_len);
|
||||||
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
|
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
|
||||||
|
|
|
@ -1655,6 +1655,11 @@ void do_justify(bool full_justify)
|
||||||
|
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
/* Return here after a SIGWINCH. */
|
||||||
|
sigsetjmp(jmpbuf, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
statusbar(_("Can now UnJustify!"));
|
statusbar(_("Can now UnJustify!"));
|
||||||
|
|
||||||
/* If constant cursor position display is on, make sure the current
|
/* If constant cursor position display is on, make sure the current
|
||||||
|
|
77
src/winio.c
77
src/winio.c
|
@ -106,16 +106,6 @@ static bool disable_cursorpos = FALSE;
|
||||||
* Note that Center (5) on the numeric keypad with NumLock off can also
|
* Note that Center (5) on the numeric keypad with NumLock off can also
|
||||||
* be the Begin key. */
|
* be the Begin key. */
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
/* Reset all the input routines that rely on character sequences. */
|
|
||||||
void reset_kbinput(void)
|
|
||||||
{
|
|
||||||
parse_kbinput(NULL, NULL, NULL, TRUE);
|
|
||||||
get_byte_kbinput(0, TRUE);
|
|
||||||
get_unicode_kbinput(0, TRUE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Read in a sequence of keystrokes from win and save them in the
|
/* Read in a sequence of keystrokes from win and save them in the
|
||||||
* default keystroke buffer. This should only be called when the
|
* default keystroke buffer. This should only be called when the
|
||||||
* default keystroke buffer is empty. */
|
* default keystroke buffer is empty. */
|
||||||
|
@ -327,11 +317,7 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
|
|
||||||
/* Read in a character and interpret it. Continue doing this until
|
/* Read in a character and interpret it. Continue doing this until
|
||||||
* we get a recognized value or sequence. */
|
* we get a recognized value or sequence. */
|
||||||
while ((kbinput = parse_kbinput(win, meta_key, func_key
|
while ((kbinput = parse_kbinput(win, meta_key, func_key)) == ERR);
|
||||||
#ifndef NANO_TINY
|
|
||||||
, FALSE
|
|
||||||
#endif
|
|
||||||
)) == ERR);
|
|
||||||
|
|
||||||
return kbinput;
|
return kbinput;
|
||||||
}
|
}
|
||||||
|
@ -340,24 +326,11 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
* sequences into their corresponding key values. Set meta_key to TRUE
|
* sequences into their corresponding key values. Set meta_key to TRUE
|
||||||
* when we get a meta key sequence, and set func_key to TRUE when we get
|
* when we get a meta key sequence, and set func_key to TRUE when we get
|
||||||
* a function key. Assume nodelay(win) is FALSE. */
|
* a function key. Assume nodelay(win) is FALSE. */
|
||||||
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key
|
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
#ifndef NANO_TINY
|
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
static int escapes = 0, byte_digits = 0;
|
static int escapes = 0, byte_digits = 0;
|
||||||
int *kbinput, retval = ERR;
|
int *kbinput, retval = ERR;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
if (reset) {
|
|
||||||
escapes = 0;
|
|
||||||
byte_digits = 0;
|
|
||||||
return ERR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
*meta_key = FALSE;
|
*meta_key = FALSE;
|
||||||
*func_key = FALSE;
|
*func_key = FALSE;
|
||||||
|
|
||||||
|
@ -584,11 +557,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key
|
||||||
int byte;
|
int byte;
|
||||||
|
|
||||||
byte_digits++;
|
byte_digits++;
|
||||||
byte = get_byte_kbinput(*kbinput
|
byte = get_byte_kbinput(*kbinput);
|
||||||
#ifndef NANO_TINY
|
|
||||||
, FALSE
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
if (byte != ERR) {
|
if (byte != ERR) {
|
||||||
char *byte_mb;
|
char *byte_mb;
|
||||||
|
@ -1193,23 +1162,11 @@ int get_escape_seq_abcd(int kbinput)
|
||||||
|
|
||||||
/* Translate a byte sequence: turn a three-digit decimal number from
|
/* Translate a byte sequence: turn a three-digit decimal number from
|
||||||
* 000 to 255 into its corresponding byte value. */
|
* 000 to 255 into its corresponding byte value. */
|
||||||
int get_byte_kbinput(int kbinput
|
int get_byte_kbinput(int kbinput)
|
||||||
#ifndef NANO_TINY
|
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
static int byte_digits = 0, byte = 0;
|
static int byte_digits = 0, byte = 0;
|
||||||
int retval = ERR;
|
int retval = ERR;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
if (reset) {
|
|
||||||
byte_digits = 0;
|
|
||||||
byte = 0;
|
|
||||||
return ERR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Increment the byte digit counter. */
|
/* Increment the byte digit counter. */
|
||||||
byte_digits++;
|
byte_digits++;
|
||||||
|
|
||||||
|
@ -1277,24 +1234,12 @@ int get_byte_kbinput(int kbinput
|
||||||
/* Translate a Unicode sequence: turn a six-digit hexadecimal number
|
/* Translate a Unicode sequence: turn a six-digit hexadecimal number
|
||||||
* from 000000 to 10FFFF (case-insensitive) into its corresponding
|
* from 000000 to 10FFFF (case-insensitive) into its corresponding
|
||||||
* multibyte value. */
|
* multibyte value. */
|
||||||
long get_unicode_kbinput(int kbinput
|
long get_unicode_kbinput(int kbinput)
|
||||||
#ifndef NANO_TINY
|
|
||||||
, bool reset
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
static int uni_digits = 0;
|
static int uni_digits = 0;
|
||||||
static long uni = 0;
|
static long uni = 0;
|
||||||
long retval = ERR;
|
long retval = ERR;
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
|
||||||
if (reset) {
|
|
||||||
uni_digits = 0;
|
|
||||||
uni = 0;
|
|
||||||
return ERR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Increment the Unicode digit counter. */
|
/* Increment the Unicode digit counter. */
|
||||||
uni_digits++;
|
uni_digits++;
|
||||||
|
|
||||||
|
@ -1499,11 +1444,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
|
||||||
while ((kbinput = get_input(win, 1)) == NULL);
|
while ((kbinput = get_input(win, 1)) == NULL);
|
||||||
|
|
||||||
/* Check whether the first keystroke is a hexadecimal digit. */
|
/* Check whether the first keystroke is a hexadecimal digit. */
|
||||||
uni = get_unicode_kbinput(*kbinput
|
uni = get_unicode_kbinput(*kbinput);
|
||||||
#ifndef NANO_TINY
|
|
||||||
, FALSE
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
/* If the first keystroke isn't a hexadecimal digit, put back the
|
/* If the first keystroke isn't a hexadecimal digit, put back the
|
||||||
* first keystroke. */
|
* first keystroke. */
|
||||||
|
@ -1518,11 +1459,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
|
||||||
while (uni == ERR) {
|
while (uni == ERR) {
|
||||||
while ((kbinput = get_input(win, 1)) == NULL);
|
while ((kbinput = get_input(win, 1)) == NULL);
|
||||||
|
|
||||||
uni = get_unicode_kbinput(*kbinput
|
uni = get_unicode_kbinput(*kbinput);
|
||||||
#ifndef NANO_TINY
|
|
||||||
, FALSE
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put back the multibyte equivalent of the Unicode value. */
|
/* Put back the multibyte equivalent of the Unicode value. */
|
||||||
|
|
Loading…
Reference in New Issue