mirror of git://git.sv.gnu.org/nano.git
remove duplicate escape sequence-interpreting code
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3566 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
d6eb17515d
commit
1320d29267
|
@ -285,6 +285,9 @@ CVS code -
|
||||||
(DLR)
|
(DLR)
|
||||||
- If we get Escape followed by an escape sequence, interpret the
|
- If we get Escape followed by an escape sequence, interpret the
|
||||||
escape sequence for consistency. (DLR)
|
escape sequence for consistency. (DLR)
|
||||||
|
parse_escape_seq_kbinput()
|
||||||
|
- New function used to interpret escape sequences, formerly part
|
||||||
|
of parse_kbinput(). (DLR)
|
||||||
get_control_kbinput()
|
get_control_kbinput()
|
||||||
- Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno
|
- Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno
|
||||||
Schulenberg)
|
Schulenberg)
|
||||||
|
|
|
@ -726,6 +726,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||||
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 parse_escape_seq_kbinput(int kbinput);
|
||||||
int get_byte_kbinput(int kbinput);
|
int get_byte_kbinput(int kbinput);
|
||||||
long get_unicode_kbinput(int kbinput);
|
long get_unicode_kbinput(int kbinput);
|
||||||
int get_control_kbinput(int kbinput);
|
int get_control_kbinput(int kbinput);
|
||||||
|
|
81
src/winio.c
81
src/winio.c
|
@ -520,29 +520,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
if (get_key_buffer_len() == 0) {
|
if (get_key_buffer_len() == 0) {
|
||||||
*meta_key = TRUE;
|
*meta_key = TRUE;
|
||||||
retval = tolower(*kbinput);
|
retval = tolower(*kbinput);
|
||||||
} else {
|
} else
|
||||||
int *seq;
|
retval = parse_escape_seq_kbinput(*kbinput);
|
||||||
size_t seq_len;
|
|
||||||
bool ignore_seq;
|
|
||||||
|
|
||||||
/* Put back the non-escape character, get the
|
|
||||||
* complete escape sequence, translate the
|
|
||||||
* sequence into its corresponding key value,
|
|
||||||
* and save that as the result. */
|
|
||||||
unget_input(kbinput, 1);
|
|
||||||
seq_len = get_key_buffer_len();
|
|
||||||
seq = get_input(NULL, seq_len);
|
|
||||||
retval = get_escape_seq_kbinput(seq, seq_len,
|
|
||||||
&ignore_seq);
|
|
||||||
|
|
||||||
/* If the escape sequence is unrecognized and
|
|
||||||
* not ignored, throw it out, and indicate this
|
|
||||||
* on the statusbar. */
|
|
||||||
if (retval == ERR && !ignore_seq)
|
|
||||||
statusbar(_("Unknown Command"));
|
|
||||||
|
|
||||||
free(seq);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
/* Two escapes followed by one or more decimal
|
/* Two escapes followed by one or more decimal
|
||||||
|
@ -619,29 +598,8 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||||
byte_digits = 0;
|
byte_digits = 0;
|
||||||
retval = *kbinput;
|
retval = *kbinput;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
int *seq;
|
retval = parse_escape_seq_kbinput(*kbinput);
|
||||||
size_t seq_len;
|
|
||||||
bool ignore_seq;
|
|
||||||
|
|
||||||
/* Put back the non-escape character, get the
|
|
||||||
* complete escape sequence, translate the
|
|
||||||
* sequence into its corresponding key value,
|
|
||||||
* and save that as the result. */
|
|
||||||
unget_input(kbinput, 1);
|
|
||||||
seq_len = get_key_buffer_len();
|
|
||||||
seq = get_input(NULL, seq_len);
|
|
||||||
retval = get_escape_seq_kbinput(seq, seq_len,
|
|
||||||
&ignore_seq);
|
|
||||||
|
|
||||||
/* If the escape sequence is unrecognized and
|
|
||||||
* not ignored, throw it out, and indicate this
|
|
||||||
* on the statusbar. */
|
|
||||||
if (retval == ERR && !ignore_seq)
|
|
||||||
statusbar(_("Unknown Command"));
|
|
||||||
|
|
||||||
free(seq);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,6 +1152,37 @@ int get_escape_seq_abcd(int kbinput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Interpret the escape sequence in the keystroke buffer, the first
|
||||||
|
* character of which is kbinput. Assume that the keystroke buffer
|
||||||
|
* isn't empty, and that the initial escape has already been read in. */
|
||||||
|
int parse_escape_seq_kbinput(int kbinput)
|
||||||
|
{
|
||||||
|
int retval, *seq;
|
||||||
|
size_t seq_len;
|
||||||
|
bool ignore_seq;
|
||||||
|
|
||||||
|
/* Put back the non-escape character, get the complete escape
|
||||||
|
* sequence, translate the sequence into its corresponding key
|
||||||
|
* value, and save that as the result. */
|
||||||
|
unget_input(&kbinput, 1);
|
||||||
|
seq_len = get_key_buffer_len();
|
||||||
|
seq = get_input(NULL, seq_len);
|
||||||
|
retval = get_escape_seq_kbinput(seq, seq_len, &ignore_seq);
|
||||||
|
|
||||||
|
/* If the escape sequence is unrecognized and not ignored, throw it
|
||||||
|
* out, and indicate this on the statusbar. */
|
||||||
|
if (retval == ERR && !ignore_seq)
|
||||||
|
statusbar(_("Unknown Command"));
|
||||||
|
|
||||||
|
free(seq);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "parse_escape_seq_kbinput(): kbinput = %d, seq_len = %lu, ignore_seq = %d, retval = %d\n", *kbinput, (unsigned long)seq_len, (int)ignore_seq, retval);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* 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)
|
||||||
|
|
Loading…
Reference in New Issue