From: David Lawrence Ramsey Date: Sat, 27 May 2006 17:39:19 +0000 (+0000) Subject: various input/output fixes: allow normal typing of high-bit control X-Git-Tag: v1.3.12~96 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=6fb6689f0fbdc7ad55982b0554eb4050080793e2;p=nano.git 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 --- diff --git a/ChangeLog b/ChangeLog index 1807a780..5e531dad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,6 +115,8 @@ CVS code - to remove redundant code. New function add_unicode_digit(); changes to get_unicode_kbinput() and parse_verbatim_kbinput(). (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: do_browser() - Reference NANO_GOTODIR_(ALT|F)?KEY instead of @@ -292,6 +294,8 @@ CVS code - do_verbatim_input() - Add a translator comment explaining the "Verbatim Input" statusbar message. (Benno Schulenberg) + - Unconditionally blank the statusbar as soon as we're finished + getting input. (DLR, suggested by Benno Schulenberg) - winio.c: parse_kbinput() - If we get NANO_CONTROL_8, properly handle it in all cases. @@ -309,6 +313,9 @@ CVS code - - Add Ctrl-/ as an alias for Ctrl-_. (DLR, found by Benno Schulenberg) - 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() - Properly display double-column characters if they're past the first virtual page and their first column is covered by the diff --git a/src/nano.c b/src/nano.c index afca8c67..0a744948 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1473,7 +1473,7 @@ bool do_mouse(void) #endif /* !DISABLE_MOUSE */ /* 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. */ 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) { /* If allow_cntrls is FALSE, filter out nulls and newlines, - * since they're control characters. */ + * since they're ASCII control characters. */ if (allow_cntrls) { /* Null to newline, if needed. */ if (output[i] == '\0') @@ -1509,8 +1509,10 @@ void do_output(char *output, size_t output_len, bool allow_cntrls) i += char_buf_len; - /* If allow_cntrls is FALSE, filter out a control character. */ - if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len)) + /* If allow_cntrls is FALSE, filter out an ASCII control + * character. */ + if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - + char_buf_len))) continue; /* If the NO_NEWLINES flag isn't set, when a character is diff --git a/src/prompt.c b/src/prompt.c index 6d4b5a83..07d99031 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -301,7 +301,8 @@ bool do_statusbar_mouse(void) /* The user typed output_len multibyte characters. Add them to the * 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 *got_enter, bool allow_cntrls) { @@ -316,7 +317,7 @@ void do_statusbar_output(char *output, size_t output_len, bool while (i < output_len) { /* If allow_cntrls is FALSE, filter out nulls and newlines, - * since they're control characters. */ + * since they're ASCII control characters. */ if (allow_cntrls) { /* Null to newline, if needed. */ if (output[i] == '\0') @@ -338,8 +339,10 @@ void do_statusbar_output(char *output, size_t output_len, bool i += char_buf_len; - /* If allow_cntrls is FALSE, filter out a control character. */ - if (!allow_cntrls && is_cntrl_mbchar(output + i - char_buf_len)) + /* If allow_cntrls is FALSE, filter out an ASCII control + * character. */ + if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - + char_buf_len))) continue; /* More dangerousness fun =) */ diff --git a/src/proto.h b/src/proto.h index ef3481e4..6d356108 100644 --- a/src/proto.h +++ b/src/proto.h @@ -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 parse_escape_seq_kbinput(int kbinput); int get_byte_kbinput(int kbinput); +#ifdef ENABLE_UTF8 long get_unicode_kbinput(int kbinput); long add_unicode_digit(int kbinput, long factor, long *uni); +#endif int get_control_kbinput(int kbinput); void unparse_kbinput(char *output, size_t output_len); int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len); diff --git a/src/text.c b/src/text.c index c23ac7cf..5ebeb9b2 100644 --- a/src/text.c +++ b/src/text.c @@ -2436,6 +2436,10 @@ void do_verbatim_input(void) /* Read in all the verbatim characters. */ kbinput = get_verbatim_kbinput(edit, &kbinput_len); + /* Blank the statusbar. */ + blank_statusbar(); + wnoutrefresh(bottomwin); + /* Display all the verbatim characters at once, not filtering out * control characters. */ output = charalloc(kbinput_len + 1); @@ -2447,7 +2451,4 @@ void do_verbatim_input(void) do_output(output, kbinput_len, TRUE); free(output); - - /* Blank the statusbar if we need to. */ - check_statusblank(); } diff --git a/src/winio.c b/src/winio.c index 80538073..372f919c 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1253,6 +1253,7 @@ int get_byte_kbinput(int kbinput) return retval; } +#ifdef ENABLE_UTF8 /* Translate a Unicode sequence: turn a six-digit hexadecimal number * (from 000000 to 10FFFF, case-insensitive) into its corresponding * multibyte value. */ @@ -1353,6 +1354,7 @@ long add_unicode_digit(int kbinput, long factor, long *uni) return retval; } +#endif /* ENABLE_UTF8 */ /* Translate a control character sequence: turn an ASCII non-control * character into its corresponding control character. */ @@ -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 *kbinput, *retval; +#ifdef ENABLE_UTF8 long uni; +#endif /* Read in the first keystroke. */ while ((kbinput = get_input(win, 1)) == NULL); +#ifdef ENABLE_UTF8 /* Check whether the first keystroke is a valid hexadecimal * digit. */ uni = get_unicode_kbinput(*kbinput); @@ -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 * the first keystroke. */ if (uni != ERR) +#endif /* ENABLE_UTF8 */ + unget_input(kbinput, 1); + +#ifdef ENABLE_UTF8 /* Otherwise, read in keystrokes until we have a complete Unicode * sequence, and put back the corresponding Unicode value. */ else { @@ -1482,6 +1491,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) free(seq); free(uni_mb); } +#endif /* ENABLE_UTF8 */ /* Get the complete sequence, and save the characters in it as the * result. */