Commit 6fb6689f authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

various input/output fixes: allow normal typing of high-bit control

characters, as Pico does; in do_verbatim_input(), unconditionally blank
the statusbar as soon as we're finished getting input; and in
parse_verbatim_kbinput(), don't include the ability to enter a Unicode
sequence via verbatim input mode if ENABLE_UTF8 isn't defined


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3584 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 36 additions and 11 deletions
+36 -11
...@@ -115,6 +115,8 @@ CVS code - ...@@ -115,6 +115,8 @@ CVS code -
to remove redundant code. New function add_unicode_digit(); to remove redundant code. New function add_unicode_digit();
changes to get_unicode_kbinput() and parse_verbatim_kbinput(). changes to get_unicode_kbinput() and parse_verbatim_kbinput().
(Benno Schulenberg, minor tweaks by DLR) (Benno Schulenberg, minor tweaks by DLR)
- Allow normal typing of high-bit control characters, as Pico
does. Changes to do_output() and do_statusbar_output(). (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
...@@ -292,6 +294,8 @@ CVS code - ...@@ -292,6 +294,8 @@ CVS code -
do_verbatim_input() do_verbatim_input()
- Add a translator comment explaining the "Verbatim Input" - Add a translator comment explaining the "Verbatim Input"
statusbar message. (Benno Schulenberg) statusbar message. (Benno Schulenberg)
- Unconditionally blank the statusbar as soon as we're finished
getting input. (DLR, suggested by Benno Schulenberg)
- winio.c: - winio.c:
parse_kbinput() parse_kbinput()
- If we get NANO_CONTROL_8, properly handle it in all cases. - If we get NANO_CONTROL_8, properly handle it in all cases.
...@@ -309,6 +313,9 @@ CVS code - ...@@ -309,6 +313,9 @@ CVS code -
- Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno - Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno
Schulenberg) Schulenberg)
- Simplify the if blocks wherever possible. (DLR) - Simplify the if blocks wherever possible. (DLR)
parse_verbatim_kbinput()
- Don't include the ability to enter a Unicode sequence via
verbatim input mode if ENABLE_UTF8 isn't defined. (DLR)
display_string() display_string()
- Properly display double-column characters if they're past the - Properly display double-column characters if they're past the
first virtual page and their first column is covered by the first virtual page and their first column is covered by the
......
...@@ -1473,7 +1473,7 @@ bool do_mouse(void) ...@@ -1473,7 +1473,7 @@ bool do_mouse(void)
#endif /* !DISABLE_MOUSE */ #endif /* !DISABLE_MOUSE */
/* The user typed output_len multibyte characters. Add them to the edit /* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all control characters if allow_cntrls is * buffer, filtering out all ASCII control characters if allow_cntrls is
* TRUE. */ * TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls) void do_output(char *output, size_t output_len, bool allow_cntrls)
{ {
...@@ -1491,7 +1491,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1491,7 +1491,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
while (i < output_len) { while (i < output_len) {
/* If allow_cntrls is FALSE, filter out nulls and newlines, /* If allow_cntrls is FALSE, filter out nulls and newlines,
* since they're control characters. */ * since they're ASCII control characters. */
if (allow_cntrls) { if (allow_cntrls) {
/* Null to newline, if needed. */ /* Null to newline, if needed. */
if (output[i] == '\0') if (output[i] == '\0')
...@@ -1509,8 +1509,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) ...@@ -1509,8 +1509,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
i += char_buf_len; i += char_buf_len;
/* If allow_cntrls is FALSE, filter out a control character. */ /* If allow_cntrls is FALSE, filter out an ASCII control
if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len)) * character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i -
char_buf_len)))
continue; continue;
/* If the NO_NEWLINES flag isn't set, when a character is /* If the NO_NEWLINES flag isn't set, when a character is
......
...@@ -301,7 +301,8 @@ bool do_statusbar_mouse(void) ...@@ -301,7 +301,8 @@ bool do_statusbar_mouse(void)
/* The user typed output_len multibyte characters. Add them to the /* The user typed output_len multibyte characters. Add them to the
* statusbar prompt, setting got_enter to TRUE if we get a newline, and * statusbar prompt, setting got_enter to TRUE if we get a newline, and
* filtering out all control characters if allow_cntrls is TRUE. */ * filtering out all ASCII control characters if allow_cntrls is
* TRUE. */
void do_statusbar_output(char *output, size_t output_len, bool void do_statusbar_output(char *output, size_t output_len, bool
*got_enter, bool allow_cntrls) *got_enter, bool allow_cntrls)
{ {
...@@ -316,7 +317,7 @@ void do_statusbar_output(char *output, size_t output_len, bool ...@@ -316,7 +317,7 @@ void do_statusbar_output(char *output, size_t output_len, bool
while (i < output_len) { while (i < output_len) {
/* If allow_cntrls is FALSE, filter out nulls and newlines, /* If allow_cntrls is FALSE, filter out nulls and newlines,
* since they're control characters. */ * since they're ASCII control characters. */
if (allow_cntrls) { if (allow_cntrls) {
/* Null to newline, if needed. */ /* Null to newline, if needed. */
if (output[i] == '\0') if (output[i] == '\0')
...@@ -338,8 +339,10 @@ void do_statusbar_output(char *output, size_t output_len, bool ...@@ -338,8 +339,10 @@ void do_statusbar_output(char *output, size_t output_len, bool
i += char_buf_len; i += char_buf_len;
/* If allow_cntrls is FALSE, filter out a control character. */ /* If allow_cntrls is FALSE, filter out an ASCII control
if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len)) * character. */
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i -
char_buf_len)))
continue; continue;
/* More dangerousness fun =) */ /* More dangerousness fun =) */
......
...@@ -728,8 +728,10 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool ...@@ -728,8 +728,10 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len, bool
int get_escape_seq_abcd(int kbinput); int get_escape_seq_abcd(int kbinput);
int parse_escape_seq_kbinput(int kbinput); int parse_escape_seq_kbinput(int kbinput);
int get_byte_kbinput(int kbinput); int get_byte_kbinput(int kbinput);
#ifdef ENABLE_UTF8
long get_unicode_kbinput(int kbinput); long get_unicode_kbinput(int kbinput);
long add_unicode_digit(int kbinput, long factor, long *uni); long add_unicode_digit(int kbinput, long factor, long *uni);
#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);
......
...@@ -2436,6 +2436,10 @@ void do_verbatim_input(void) ...@@ -2436,6 +2436,10 @@ void do_verbatim_input(void)
/* Read in all the verbatim characters. */ /* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len); kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* Blank the statusbar. */
blank_statusbar();
wnoutrefresh(bottomwin);
/* Display all the verbatim characters at once, not filtering out /* Display all the verbatim characters at once, not filtering out
* control characters. */ * control characters. */
output = charalloc(kbinput_len + 1); output = charalloc(kbinput_len + 1);
...@@ -2447,7 +2451,4 @@ void do_verbatim_input(void) ...@@ -2447,7 +2451,4 @@ void do_verbatim_input(void)
do_output(output, kbinput_len, TRUE); do_output(output, kbinput_len, TRUE);
free(output); free(output);
/* Blank the statusbar if we need to. */
check_statusblank();
} }
...@@ -1253,6 +1253,7 @@ int get_byte_kbinput(int kbinput) ...@@ -1253,6 +1253,7 @@ int get_byte_kbinput(int kbinput)
return retval; return retval;
} }
#ifdef ENABLE_UTF8
/* 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. */
...@@ -1353,6 +1354,7 @@ long add_unicode_digit(int kbinput, long factor, long *uni) ...@@ -1353,6 +1354,7 @@ long add_unicode_digit(int kbinput, long factor, long *uni)
return retval; return retval;
} }
#endif /* ENABLE_UTF8 */
/* Translate a control character sequence: turn an ASCII non-control /* Translate a control character sequence: turn an ASCII non-control
* character into its corresponding control character. */ * character into its corresponding control character. */
...@@ -1439,11 +1441,14 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) ...@@ -1439,11 +1441,14 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
{ {
int *kbinput, *retval; int *kbinput, *retval;
#ifdef ENABLE_UTF8
long uni; long uni;
#endif
/* Read in the first keystroke. */ /* Read in the first keystroke. */
while ((kbinput = get_input(win, 1)) == NULL); while ((kbinput = get_input(win, 1)) == NULL);
#ifdef ENABLE_UTF8
/* Check whether the first keystroke is a valid hexadecimal /* Check whether the first keystroke is a valid hexadecimal
* digit. */ * digit. */
uni = get_unicode_kbinput(*kbinput); uni = get_unicode_kbinput(*kbinput);
...@@ -1451,7 +1456,11 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) ...@@ -1451,7 +1456,11 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
/* If the first keystroke isn't a valid hexadecimal digit, put back /* If the first keystroke isn't a valid hexadecimal digit, put back
* the first keystroke. */ * the first keystroke. */
if (uni != ERR) if (uni != ERR)
#endif /* ENABLE_UTF8 */
unget_input(kbinput, 1); unget_input(kbinput, 1);
#ifdef ENABLE_UTF8
/* Otherwise, read in keystrokes until we have a complete Unicode /* Otherwise, read in keystrokes until we have a complete Unicode
* sequence, and put back the corresponding Unicode value. */ * sequence, and put back the corresponding Unicode value. */
else { else {
...@@ -1482,6 +1491,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) ...@@ -1482,6 +1491,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
free(seq); free(seq);
free(uni_mb); free(uni_mb);
} }
#endif /* ENABLE_UTF8 */
/* Get the complete sequence, and save the characters in it as the /* Get the complete sequence, and save the characters in it as the
* result. */ * result. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment