remove malfunctioning wide character support, and add a few
miscellaneous fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2152 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
63e73cbd14
commit
1483ee3db1
29
ChangeLog
29
ChangeLog
|
@ -58,17 +58,38 @@ CVS code -
|
||||||
instead of setting it to 0. (DLR)
|
instead of setting it to 0. (DLR)
|
||||||
- winio.c:
|
- winio.c:
|
||||||
unget_kbinput()
|
unget_kbinput()
|
||||||
- Free s after the wctomb() call, since we don't need it after
|
- Remove the wide character handling, as it didn't work properly
|
||||||
that. (DLR)
|
with respect to function keys. (DLR)
|
||||||
get_kbinput(), get_translated_kbinput(), get_ascii_kbinput(),
|
get_kbinput(), get_translated_kbinput(), get_ascii_kbinput(),
|
||||||
get_untranslated_kbinput()
|
get_untranslated_kbinput()
|
||||||
- Make the ascii_digits variables ints instead of size_t's,
|
- Make the ascii_digits variables ints instead of size_t's,
|
||||||
since they will only hold very small values. (DLR)
|
since they will only hold very small values. (DLR)
|
||||||
|
get_kbinput()
|
||||||
|
- Remove the wide character handling, as it didn't work properly
|
||||||
|
with respect to adding multiple wide characters at once, and
|
||||||
|
ungetting them just caused other problems elsewhere. (DLR)
|
||||||
|
get_translated_kbinput()
|
||||||
|
- Remove the wide character handling, as it didn't work properly
|
||||||
|
with respect to adding multiple wide characters at once, and
|
||||||
|
ungetting them just caused other problems elsewhere. (DLR)
|
||||||
|
- Use if statements instead of switch/case statements to handle
|
||||||
|
ASCII character sequence mode, as they take up less room.
|
||||||
|
get_ascii_kbinput()
|
||||||
|
- Use if statements instead of switch/case statements to handle
|
||||||
|
ASCII character sequence mode, as they take up less room.
|
||||||
get_verbatim_kbinput()
|
get_verbatim_kbinput()
|
||||||
- Don't pass v_kbinput in as a parameter, since we're
|
- Don't pass v_kbinput in as a parameter, since we're
|
||||||
dynamically allocating it and then returning it. (DLR)
|
dynamically allocating it and then returning it. (DLR)
|
||||||
get_shortcut(), get_toggle()
|
- Remove v_first parameter, and go back to the old behavior of
|
||||||
- Add debug messages. (DLR)
|
putting back the first character of the escape sequence, as it
|
||||||
|
worked just as well and was less complicated. (DLR)
|
||||||
|
get_shortcut()
|
||||||
|
- Add debug message. (DLR)
|
||||||
|
- Take kbinput as a reference instead of a value, so that it's
|
||||||
|
translated when the key is translated to its equivalent
|
||||||
|
control key or meta key shortcut. (DLR)
|
||||||
|
get_toggle()
|
||||||
|
- Add debug message. (DLR)
|
||||||
- configure.ac:
|
- configure.ac:
|
||||||
- Remove specific references to control key shortcuts. (DLR)
|
- Remove specific references to control key shortcuts. (DLR)
|
||||||
|
|
||||||
|
|
|
@ -2583,7 +2583,7 @@ char *do_browser(const char *inpath)
|
||||||
selected = numents - 1;
|
selected = numents - 1;
|
||||||
else if (selectedbackup == selected)
|
else if (selectedbackup == selected)
|
||||||
/* Put back the 'select' key */
|
/* Put back the 'select' key */
|
||||||
unget_kbinput('s', FALSE, FALSE);
|
unget_kbinput('s', FALSE);
|
||||||
} else {
|
} else {
|
||||||
/* Must be clicking a shortcut */
|
/* Must be clicking a shortcut */
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
|
|
|
@ -1225,7 +1225,7 @@ void do_verbatim_input(void)
|
||||||
|
|
||||||
statusbar(_("Verbatim input"));
|
statusbar(_("Verbatim input"));
|
||||||
|
|
||||||
v_kbinput = get_verbatim_kbinput(edit, ERR, &v_len, TRUE);
|
v_kbinput = get_verbatim_kbinput(edit, &v_len, TRUE);
|
||||||
|
|
||||||
/* Turn on DISABLE_CURPOS while inserting character(s) and turn it
|
/* Turn on DISABLE_CURPOS while inserting character(s) and turn it
|
||||||
* off afterwards, so that if constant cursor position display is
|
* off afterwards, so that if constant cursor position display is
|
||||||
|
@ -3082,7 +3082,7 @@ void do_justify(bool full_justify)
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
unget_kbinput(kbinput, meta_key, func_key);
|
unget_kbinput(kbinput, meta_key);
|
||||||
|
|
||||||
/* Blow away the text in the justify buffer. */
|
/* Blow away the text in the justify buffer. */
|
||||||
free_filestruct(jusbuffer);
|
free_filestruct(jusbuffer);
|
||||||
|
|
|
@ -157,10 +157,6 @@ typedef enum {
|
||||||
TOP, CENTER, NONE
|
TOP, CENTER, NONE
|
||||||
} topmidnone;
|
} topmidnone;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NO_SEQ, ESCAPE_SEQ, UTF8_SEQ
|
|
||||||
} seq_type;
|
|
||||||
|
|
||||||
/* Structure types. */
|
/* Structure types. */
|
||||||
typedef struct filestruct {
|
typedef struct filestruct {
|
||||||
char *data;
|
char *data;
|
||||||
|
|
|
@ -524,9 +524,9 @@ int check_wildcard_match(const char *text, const char *pattern);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
void reset_kbinput(void);
|
void reset_kbinput(void);
|
||||||
#endif
|
#endif
|
||||||
void unget_kbinput(int kbinput, bool meta_key, bool func_key);
|
void unget_kbinput(int kbinput, bool meta_key);
|
||||||
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||||
int get_translated_kbinput(int kbinput, seq_type *seq
|
int get_translated_kbinput(int kbinput, bool *escape_seq
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
, bool reset
|
, bool reset
|
||||||
#endif
|
#endif
|
||||||
|
@ -540,8 +540,7 @@ int get_control_kbinput(int kbinput);
|
||||||
int get_escape_seq_kbinput(const int *escape_seq, size_t es_len, bool
|
int get_escape_seq_kbinput(const int *escape_seq, size_t es_len, bool
|
||||||
*ignore_seq);
|
*ignore_seq);
|
||||||
int get_escape_seq_abcd(int kbinput);
|
int get_escape_seq_abcd(int kbinput);
|
||||||
int *get_verbatim_kbinput(WINDOW *win, int v_first, size_t *v_len, bool
|
int *get_verbatim_kbinput(WINDOW *win, size_t *v_len, bool allow_ascii);
|
||||||
allow_ascii);
|
|
||||||
int get_untranslated_kbinput(int kbinput, size_t position, bool
|
int get_untranslated_kbinput(int kbinput, size_t position, bool
|
||||||
allow_ascii
|
allow_ascii
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -551,7 +550,7 @@ int get_untranslated_kbinput(int kbinput, size_t position, bool
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
||||||
#endif
|
#endif
|
||||||
const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
|
const shortcut *get_shortcut(const shortcut *s_list, int *kbinput, bool
|
||||||
*meta_key, bool *func_key);
|
*meta_key, bool *func_key);
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
const toggle *get_toggle(int kbinput, bool meta_key);
|
const toggle *get_toggle(int kbinput, bool meta_key);
|
||||||
|
|
285
src/winio.c
285
src/winio.c
|
@ -113,28 +113,8 @@ void reset_kbinput(void)
|
||||||
|
|
||||||
/* Put back the input character stored in kbinput. If meta_key is TRUE,
|
/* Put back the input character stored in kbinput. If meta_key is TRUE,
|
||||||
* put back the Escape character after putting back kbinput. */
|
* put back the Escape character after putting back kbinput. */
|
||||||
void unget_kbinput(int kbinput, bool meta_key, bool func_key)
|
void unget_kbinput(int kbinput, bool meta_key)
|
||||||
{
|
{
|
||||||
/* If this character is outside the ASCII range and func_key is
|
|
||||||
* FALSE, treat it as a wide character and put back its equivalent
|
|
||||||
* UTF-8 sequence. */
|
|
||||||
if (kbinput > 255 && !func_key)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *s = charalloc(MB_CUR_MAX + 1);
|
|
||||||
wchar_t wc = (wchar_t)kbinput;
|
|
||||||
|
|
||||||
i = wctomb(s, wc);
|
|
||||||
free(s);
|
|
||||||
|
|
||||||
if (i == -1)
|
|
||||||
/* This wide character is unrecognized. Send it back. */
|
|
||||||
ungetch(kbinput);
|
|
||||||
else {
|
|
||||||
for (; i > 0; i--)
|
|
||||||
ungetch(s[i - 1]);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
ungetch(kbinput);
|
ungetch(kbinput);
|
||||||
if (meta_key)
|
if (meta_key)
|
||||||
ungetch(NANO_CONTROL_3);
|
ungetch(NANO_CONTROL_3);
|
||||||
|
@ -152,7 +132,7 @@ void unget_kbinput(int kbinput, bool meta_key, bool func_key)
|
||||||
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
{
|
{
|
||||||
int kbinput, retval = ERR;
|
int kbinput, retval = ERR;
|
||||||
seq_type seq;
|
bool escape_seq;
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
allow_pending_sigwinch(TRUE);
|
allow_pending_sigwinch(TRUE);
|
||||||
|
@ -167,44 +147,41 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
* to get_translated_kbinput(). Continue until we get a
|
* to get_translated_kbinput(). Continue until we get a
|
||||||
* complete sequence. */
|
* complete sequence. */
|
||||||
kbinput = wgetch(win);
|
kbinput = wgetch(win);
|
||||||
retval = get_translated_kbinput(kbinput, &seq
|
retval = get_translated_kbinput(kbinput, &escape_seq
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
, FALSE
|
, FALSE
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
/* If we have a complete sequence now, we should interpret its
|
/* If we got a complete non-escape sequence, interpret the
|
||||||
* translated value instead of the value of the last character
|
* translated value instead of the value of the last character
|
||||||
* we got. */
|
* we got. Set func_key to TRUE if the translated value is
|
||||||
if (retval != ERR)
|
* outside byte range. */
|
||||||
|
if (retval != ERR) {
|
||||||
|
*func_key = (retval > 255);
|
||||||
kbinput = retval;
|
kbinput = retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we got a one-character sequence and it's outside the ASCII
|
/* If we got an incomplete escape sequence, put back the initial
|
||||||
* range, set func_key to TRUE. */
|
* non-escape and then read the entire sequence in as verbatim
|
||||||
if (seq == NO_SEQ) {
|
* input. */
|
||||||
if (kbinput > 255)
|
if (escape_seq) {
|
||||||
*func_key = TRUE;
|
int *sequence;
|
||||||
/* If we got a multi-character sequence, read it in, including
|
|
||||||
* the initial character, as verbatim input. */
|
|
||||||
} else {
|
|
||||||
int *sequence = NULL;
|
|
||||||
size_t seq_len;
|
size_t seq_len;
|
||||||
|
|
||||||
sequence = get_verbatim_kbinput(win, kbinput, &seq_len,
|
unget_kbinput(kbinput, FALSE);
|
||||||
FALSE);
|
sequence = get_verbatim_kbinput(win, &seq_len, FALSE);
|
||||||
|
|
||||||
/* Handle escape sequences. */
|
|
||||||
if (seq == ESCAPE_SEQ) {
|
|
||||||
/* If the escape sequence is one character long, set
|
/* If the escape sequence is one character long, set
|
||||||
* meta_key to TRUE, make the sequence character
|
* meta_key to TRUE, make the sequence character lowercase,
|
||||||
* lowercase, and save that as the result. */
|
* and save that as the result. */
|
||||||
if (seq_len == 1) {
|
if (seq_len == 1) {
|
||||||
*meta_key = TRUE;
|
*meta_key = TRUE;
|
||||||
retval = tolower(kbinput);
|
retval = tolower(kbinput);
|
||||||
/* If the escape sequence is more than one character
|
/* If the escape sequence is more than one character long,
|
||||||
* long, set func_key to TRUE, translate the escape
|
* set func_key to TRUE, translate the escape sequence into
|
||||||
* sequence into the corresponding key value, and save
|
* the corresponding key value, and save that as the
|
||||||
* that as the result. */
|
* result. */
|
||||||
} else if (seq_len > 1) {
|
} else if (seq_len > 1) {
|
||||||
bool ignore_seq;
|
bool ignore_seq;
|
||||||
|
|
||||||
|
@ -213,37 +190,12 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
&ignore_seq);
|
&ignore_seq);
|
||||||
|
|
||||||
if (retval == ERR && !ignore_seq) {
|
if (retval == ERR && !ignore_seq) {
|
||||||
/* This escape sequence is unrecognized. Send
|
/* This escape sequence is unrecognized. Send it
|
||||||
* it back. */
|
|
||||||
for (; seq_len > 1; seq_len--)
|
|
||||||
unget_kbinput(sequence[seq_len - 1], FALSE,
|
|
||||||
FALSE);
|
|
||||||
retval = sequence[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Handle UTF-8 sequences. */
|
|
||||||
} else if (seq == UTF8_SEQ) {
|
|
||||||
/* If we have a UTF-8 sequence, translate the UTF-8
|
|
||||||
* sequence into the corresponding wide character value,
|
|
||||||
* and save that as the result. */
|
|
||||||
int i = 0;
|
|
||||||
char *s = charalloc(seq_len + 1);
|
|
||||||
wchar_t wc;
|
|
||||||
|
|
||||||
for (; i < seq_len; i++)
|
|
||||||
s[i] = (char)sequence[i];
|
|
||||||
s[seq_len] = '\0';
|
|
||||||
|
|
||||||
if (mbtowc(&wc, s, MB_CUR_MAX) == -1) {
|
|
||||||
/* This UTF-8 sequence is unrecognized. Send it
|
|
||||||
* back. */
|
* back. */
|
||||||
for (; seq_len > 1; seq_len--)
|
for (; seq_len > 1; seq_len--)
|
||||||
unget_kbinput(sequence[seq_len - 1], FALSE,
|
unget_kbinput(sequence[seq_len - 1], FALSE);
|
||||||
FALSE);
|
|
||||||
retval = sequence[0];
|
retval = sequence[0];
|
||||||
} else
|
}
|
||||||
retval = wc;
|
|
||||||
free(s);
|
|
||||||
}
|
}
|
||||||
free(sequence);
|
free(sequence);
|
||||||
}
|
}
|
||||||
|
@ -260,11 +212,11 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translate acceptable ASCII, extended keypad values, and escape and
|
/* Translate acceptable ASCII, extended keypad values, and escape
|
||||||
* UTF-8 sequences into their corresponding key values. Set seq to
|
* sequences into their corresponding key values. Set escape_seq to
|
||||||
* ESCAPE_SEQ when we get an escape sequence, or UTF8_SEQ when we get a
|
* TRUE when we get an incomplete escape sequence. Assume nodelay(win)
|
||||||
* UTF-8 sequence. Assume nodelay(win) is FALSE. */
|
* is FALSE. */
|
||||||
int get_translated_kbinput(int kbinput, seq_type *seq
|
int get_translated_kbinput(int kbinput, bool *escape_seq
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
, bool reset
|
, bool reset
|
||||||
#endif
|
#endif
|
||||||
|
@ -282,7 +234,7 @@ int get_translated_kbinput(int kbinput, seq_type *seq
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*seq = NO_SEQ;
|
*escape_seq = FALSE;
|
||||||
|
|
||||||
switch (kbinput) {
|
switch (kbinput) {
|
||||||
case ERR:
|
case ERR:
|
||||||
|
@ -420,32 +372,21 @@ int get_translated_kbinput(int kbinput, seq_type *seq
|
||||||
case 1:
|
case 1:
|
||||||
/* One escape followed by a non-escape: escape
|
/* One escape followed by a non-escape: escape
|
||||||
* sequence mode. Reset the escape counter and set
|
* sequence mode. Reset the escape counter and set
|
||||||
* seq to ESCAPE_SEQ. */
|
* escape_seq to TRUE. */
|
||||||
escapes = 0;
|
escapes = 0;
|
||||||
*seq = ESCAPE_SEQ;
|
*escape_seq = TRUE;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
switch (kbinput) {
|
if (kbinput >= '0' && kbinput <= '9') {
|
||||||
case '0':
|
/* Two escapes followed by one or more decimal
|
||||||
case '1':
|
* digits: ASCII character sequence mode. If
|
||||||
case '2':
|
* the digit sequence's range is limited to 2XX
|
||||||
case '3':
|
* (the first digit is in the '0' to '2' range
|
||||||
case '4':
|
* and it's the first digit, or if it's in the
|
||||||
case '5':
|
* full digit range and it's not the first
|
||||||
case '6':
|
* digit), increment the ASCII digit counter and
|
||||||
case '7':
|
* interpret the digit. If the digit sequence's
|
||||||
case '8':
|
* range is not limited to 2XX, fall through. */
|
||||||
case '9':
|
|
||||||
/* Two escapes followed by one or more
|
|
||||||
* digits: ASCII character sequence mode.
|
|
||||||
* If the digit sequence's range is limited
|
|
||||||
* to 2XX (the first digit is in the '0' to
|
|
||||||
* '2' range and it's the first digit, or if
|
|
||||||
* it's in the full digit range and it's not
|
|
||||||
* the first digit), increment the ASCII
|
|
||||||
* digit counter and interpret the digit.
|
|
||||||
* If the digit sequence's range is not
|
|
||||||
* limited to 2XX, fall through. */
|
|
||||||
if (kbinput <= '2' || ascii_digits > 0) {
|
if (kbinput <= '2' || ascii_digits > 0) {
|
||||||
ascii_digits++;
|
ascii_digits++;
|
||||||
kbinput = get_ascii_kbinput(kbinput,
|
kbinput = get_ascii_kbinput(kbinput,
|
||||||
|
@ -457,49 +398,44 @@ int get_translated_kbinput(int kbinput, seq_type *seq
|
||||||
|
|
||||||
if (kbinput != ERR) {
|
if (kbinput != ERR) {
|
||||||
/* If we've read in a complete ASCII
|
/* If we've read in a complete ASCII
|
||||||
* digit sequence, reset the ASCII
|
* digit sequence, reset the ASCII digit
|
||||||
* digit counter and the escape
|
* counter and the escape counter and
|
||||||
* counter and save the corresponding
|
* save the corresponding ASCII
|
||||||
* ASCII character as the result. */
|
* character as the result. */
|
||||||
ascii_digits = 0;
|
ascii_digits = 0;
|
||||||
escapes = 0;
|
escapes = 0;
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
/* Reset the escape counter. */
|
/* Reset the escape counter. */
|
||||||
escapes = 0;
|
escapes = 0;
|
||||||
if (ascii_digits == 0)
|
if (ascii_digits == 0)
|
||||||
/* Two escapes followed by a non-decimal
|
/* Two escapes followed by a non-decimal
|
||||||
* digit or a decimal digit that would
|
* digit or a decimal digit that would
|
||||||
* create an ASCII digit sequence
|
* create an ASCII digit sequence greater
|
||||||
* greater than 2XX, and we're not in
|
* than 2XX, and we're not in the middle of
|
||||||
* the middle of an ASCII character
|
* an ASCII character sequence: control
|
||||||
* sequence: control character sequence
|
* character sequence mode. Interpret the
|
||||||
* mode. Interpret the control sequence
|
* control sequence and save the
|
||||||
* and save the corresponding control
|
* corresponding control character as the
|
||||||
* character as the result. */
|
* result. */
|
||||||
retval = get_control_kbinput(kbinput);
|
retval = get_control_kbinput(kbinput);
|
||||||
else {
|
else {
|
||||||
/* If we were in the middle of an ASCII
|
/* If we were in the middle of an ASCII
|
||||||
* character sequence, reset the ASCII
|
* character sequence, reset the ASCII digit
|
||||||
* digit counter and save the character
|
* counter and save the character we got as
|
||||||
* we got as the result. */
|
* the result. */
|
||||||
ascii_digits = 0;
|
ascii_digits = 0;
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A character other than ERR with its high bit set: UTF-8 sequence
|
|
||||||
* mode. Set seq to UTF8_SEQ. */
|
|
||||||
if (retval != ERR && 127 < retval && retval <= 255)
|
|
||||||
*seq = UTF8_SEQ;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "get_translated_kbinput(): kbinput = %d, seq = %d, escapes = %d, ascii_digits = %d, retval = %d\n", kbinput, (int)*seq, escapes, ascii_digits, retval);
|
fprintf(stderr, "get_translated_kbinput(): kbinput = %d, escape_seq = %d, escapes = %d, ascii_digits = %d, retval = %d\n", kbinput, (int)*escape_seq, escapes, ascii_digits, retval);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Return the result. */
|
/* Return the result. */
|
||||||
|
@ -527,70 +463,42 @@ int get_ascii_kbinput(int kbinput, int ascii_digits
|
||||||
switch (ascii_digits) {
|
switch (ascii_digits) {
|
||||||
case 1:
|
case 1:
|
||||||
/* Read in the first of the three ASCII digits. */
|
/* Read in the first of the three ASCII digits. */
|
||||||
switch (kbinput) {
|
|
||||||
/* Add the digit we got to the 100's position of the
|
/* Add the digit we got to the 100's position of the ASCII
|
||||||
* ASCII character sequence holder. */
|
* character sequence holder. */
|
||||||
case '0':
|
if ('0' <= kbinput && kbinput <= '2')
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
ascii_kbinput += (kbinput - '0') * 100;
|
ascii_kbinput += (kbinput - '0') * 100;
|
||||||
break;
|
else
|
||||||
default:
|
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* Read in the second of the three ASCII digits. */
|
/* Read in the second of the three ASCII digits. */
|
||||||
switch (kbinput) {
|
|
||||||
/* Add the digit we got to the 10's position of the
|
/* Add the digit we got to the 10's position of the ASCII
|
||||||
* ASCII character sequence holder. */
|
* character sequence holder. */
|
||||||
case '0':
|
if (('0' <= kbinput && kbinput <= '5') ||
|
||||||
case '1':
|
(ascii_kbinput < 200 && '6' <= kbinput &&
|
||||||
case '2':
|
kbinput <= '9'))
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
ascii_kbinput += (kbinput - '0') * 10;
|
ascii_kbinput += (kbinput - '0') * 10;
|
||||||
break;
|
else
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
if (ascii_kbinput < 200) {
|
|
||||||
ascii_kbinput += (kbinput - '0') * 10;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
/* Read in the third of the three ASCII digits. */
|
/* Read in the third of the three ASCII digits. */
|
||||||
switch (kbinput) {
|
|
||||||
/* Add the digit we got to the 1's position of the ASCII
|
/* Add the digit we got to the 1's position of the ASCII
|
||||||
* character sequence holder, and save the corresponding
|
* character sequence holder, and save the corresponding
|
||||||
* ASCII character as the result. */
|
* ASCII character as the result. */
|
||||||
case '0':
|
if (('0' <= kbinput && kbinput <= '5') ||
|
||||||
case '1':
|
(ascii_kbinput < 250 && '6' <= kbinput &&
|
||||||
case '2':
|
kbinput <= '9')) {
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
ascii_kbinput += (kbinput - '0');
|
ascii_kbinput += (kbinput - '0');
|
||||||
retval = ascii_kbinput;
|
retval = ascii_kbinput;
|
||||||
|
} else
|
||||||
|
retval = kbinput;
|
||||||
break;
|
break;
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
if (ascii_kbinput < 250) {
|
|
||||||
ascii_kbinput += (kbinput - '0');
|
|
||||||
retval = ascii_kbinput;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
retval = kbinput;
|
retval = kbinput;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,11 +1077,9 @@ int get_escape_seq_abcd(int kbinput)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read in a string of input characters (e.g. an escape sequence)
|
/* Read in a string of input characters (e.g. an escape sequence)
|
||||||
* verbatim. If v_first isn't ERR, make it the first character of the
|
* verbatim. Return the length of the string in v_len. Assume
|
||||||
* string. Return the length of the string in v_len. Assume
|
|
||||||
* nodelay(win) is FALSE. */
|
* nodelay(win) is FALSE. */
|
||||||
int *get_verbatim_kbinput(WINDOW *win, int v_first, size_t *v_len, bool
|
int *get_verbatim_kbinput(WINDOW *win, size_t *v_len, bool allow_ascii)
|
||||||
allow_ascii)
|
|
||||||
{
|
{
|
||||||
int kbinput, *v_kbinput;
|
int kbinput, *v_kbinput;
|
||||||
size_t i = 0, v_newlen = 0;
|
size_t i = 0, v_newlen = 0;
|
||||||
|
@ -1193,15 +1099,12 @@ int *get_verbatim_kbinput(WINDOW *win, int v_first, size_t *v_len, bool
|
||||||
keypad(win, FALSE);
|
keypad(win, FALSE);
|
||||||
|
|
||||||
/* If first is ERR, read the first character using blocking input,
|
/* If first is ERR, read the first character using blocking input,
|
||||||
* since using non-blocking input will eat up all unused CPU.
|
* since using non-blocking input will eat up all unused CPU. Then
|
||||||
* Otherwise, treat v_first as the first character. Then increment
|
* increment v_len and save the character in v_kbinput. */
|
||||||
* v_len and save the character in v_kbinput. */
|
|
||||||
if (v_first == ERR)
|
|
||||||
kbinput = wgetch(win);
|
kbinput = wgetch(win);
|
||||||
else
|
|
||||||
kbinput = v_first;
|
|
||||||
(*v_len)++;
|
(*v_len)++;
|
||||||
v_kbinput[0] = kbinput;
|
v_kbinput[0] = kbinput;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %lu\n", kbinput, (unsigned long)*v_len);
|
fprintf(stderr, "get_verbatim_kbinput(): kbinput = %d, v_len = %lu\n", kbinput, (unsigned long)*v_len);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1422,9 +1325,9 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||||
* has, at the very least, an equivalent control key, an
|
* has, at the very least, an equivalent control key, an
|
||||||
* equivalent primary meta key sequence, or both. */
|
* equivalent primary meta key sequence, or both. */
|
||||||
if (s->ctrlval != NANO_NO_KEY)
|
if (s->ctrlval != NANO_NO_KEY)
|
||||||
unget_kbinput(s->ctrlval, FALSE, FALSE);
|
unget_kbinput(s->ctrlval, FALSE);
|
||||||
else if (s->metaval != NANO_NO_KEY)
|
else if (s->metaval != NANO_NO_KEY)
|
||||||
unget_kbinput(s->metaval, TRUE, FALSE);
|
unget_kbinput(s->metaval, TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1432,14 +1335,14 @@ bool get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||||
}
|
}
|
||||||
#endif /* !DISABLE_MOUSE */
|
#endif /* !DISABLE_MOUSE */
|
||||||
|
|
||||||
const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
|
const shortcut *get_shortcut(const shortcut *s_list, int *kbinput, bool
|
||||||
*meta_key, bool *func_key)
|
*meta_key, bool *func_key)
|
||||||
{
|
{
|
||||||
const shortcut *s = s_list;
|
const shortcut *s = s_list;
|
||||||
size_t slen = length_of_list(s_list);
|
size_t slen = length_of_list(s_list);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %d, func_key = %d\n", kbinput, (int)*meta_key, (int)*func_key);
|
fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %d, func_key = %d\n", *kbinput, (int)*meta_key, (int)*func_key);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for shortcuts. */
|
/* Check for shortcuts. */
|
||||||
|
@ -1453,10 +1356,10 @@ const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
|
||||||
* 4. func_key is TRUE and the key is a function key in the
|
* 4. func_key is TRUE and the key is a function key in the
|
||||||
* shortcut list. */
|
* shortcut list. */
|
||||||
|
|
||||||
if (kbinput != NANO_NO_KEY && (kbinput == s->ctrlval ||
|
if (*kbinput != NANO_NO_KEY && (*kbinput == s->ctrlval ||
|
||||||
(*meta_key == TRUE && (kbinput == s->metaval ||
|
(*meta_key == TRUE && (*kbinput == s->metaval ||
|
||||||
kbinput == s->miscval)) || (*func_key == TRUE &&
|
*kbinput == s->miscval)) || (*func_key == TRUE &&
|
||||||
kbinput == s->funcval))) {
|
*kbinput == s->funcval))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1469,10 +1372,10 @@ const shortcut *get_shortcut(const shortcut *s_list, int kbinput, bool
|
||||||
if (slen > 0) {
|
if (slen > 0) {
|
||||||
if (s->ctrlval != NANO_NO_KEY) {
|
if (s->ctrlval != NANO_NO_KEY) {
|
||||||
*meta_key = FALSE;
|
*meta_key = FALSE;
|
||||||
kbinput = s->ctrlval;
|
*kbinput = s->ctrlval;
|
||||||
} else if (s->metaval != NANO_NO_KEY) {
|
} else if (s->metaval != NANO_NO_KEY) {
|
||||||
*meta_key = TRUE;
|
*meta_key = TRUE;
|
||||||
kbinput = s->metaval;
|
*kbinput = s->metaval;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -1538,7 +1441,7 @@ int get_edit_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for a shortcut in the main list. */
|
/* Check for a shortcut in the main list. */
|
||||||
s = get_shortcut(main_list, kbinput, meta_key, func_key);
|
s = get_shortcut(main_list, &kbinput, meta_key, func_key);
|
||||||
|
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
/* We got a shortcut. Run the shortcut's corresponding function
|
/* We got a shortcut. Run the shortcut's corresponding function
|
||||||
|
|
Loading…
Reference in New Issue