From 71daa1ef6be14387928b626217eeb9c4eb164fe6 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 12 Feb 2020 12:05:52 +0100 Subject: [PATCH] tweaks: update several comments after the previous changes --- src/nano.c | 16 +++++----------- src/prompt.c | 20 +++++++------------- src/text.c | 2 +- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/nano.c b/src/nano.c index 2e819e44..599e6cc0 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1528,8 +1528,7 @@ void do_input(void) /* Check for a shortcut in the main list. */ shortcut = get_shortcut(&input); - /* If we got a non-high-bit control key, a meta key sequence, or a - * function key, and it's not a shortcut or toggle, throw it out. */ + /* If not a command, discard anything that is not a normal character byte. */ if (shortcut == NULL) { if (input < 0x20 || input > 0xFF || meta_key) unbound_key(input); @@ -1548,18 +1547,14 @@ void do_input(void) #endif } - /* If we got a shortcut or toggle, or if there aren't any other - * characters waiting after the one we read in, we need to output - * all available characters in the input puddle. Note that this - * puddle will be empty if we're in view mode. */ + /* If we have a command, or if there aren't any other key codes waiting, + * it's time to insert the gathered bytes into the current buffer. */ if (shortcut || get_key_buffer_len() == 0) { if (puddle != NULL) { - /* Insert all bytes in the input buffer into the edit buffer - * at once, filtering out any ASCII control codes. */ puddle[depth] = '\0'; inject(puddle, depth); - /* Empty the input buffer. */ + /* Empty the little input buffer. */ free(puddle); puddle = NULL; depth = 0; @@ -1646,8 +1641,7 @@ void do_input(void) #endif } -/* The user typed output_len multibyte characters. Add them to the edit - * buffer, filtering out ASCII control characters when filtering is TRUE. */ +/* The user typed output_len multibyte characters. Add them to the buffer. */ void inject(char *output, size_t output_len) { char onechar[MAXCHARLEN]; diff --git a/src/prompt.c b/src/prompt.c index aba8fc38..c51a87d2 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -87,13 +87,12 @@ int do_statusbar_input(bool *finished) /* Check for a shortcut in the current list. */ shortcut = get_shortcut(&input); - /* If we got a non-high-bit control key, a meta key sequence, or a - * function key, and it's not a shortcut or toggle, throw it out. */ + /* If not a command, discard anything that is not a normal character byte. + * Apart from that, only accept input when not in restricted mode, or when + * not at the "Write File" prompt, or when there is no filename yet. */ if (shortcut == NULL) { if (input < 0x20 || input > 0xFF || meta_key) beep(); - /* Only accept input when not in restricted mode, or when not at - * the "Write File" prompt, or when there is no filename yet. */ else if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE || openfile->filename[0] == '\0') { kbinput_len++; @@ -102,15 +101,11 @@ int do_statusbar_input(bool *finished) } } - /* If we got a shortcut, or if there aren't any other keystrokes waiting - * after the one we read in, we need to insert all the characters in the - * input buffer (if not empty) into the answer. */ + /* If we got a shortcut, or if there aren't any other keystrokes waiting, + * it's time to insert all characters in the input buffer (if not empty) + * into the answer, and then clear the input buffer. */ if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) { - /* Inject all characters in the input buffer at once, filtering out - * control characters. */ inject_into_answer(kbinput, kbinput_len); - - /* Empty the input buffer. */ kbinput_len = 0; free(kbinput); kbinput = NULL; @@ -176,8 +171,7 @@ int do_statusbar_input(bool *finished) return input; } -/* The user typed input_len multibyte characters. Add them to the answer, - * filtering out ASCII control characters if filtering is TRUE. */ +/* The user typed input_len multibyte characters. Add them to the answer. */ void inject_into_answer(int *the_input, size_t input_len) { char *output = charalloc(input_len + 1); diff --git a/src/text.c b/src/text.c index 54e95ade..204e87bb 100644 --- a/src/text.c +++ b/src/text.c @@ -3155,7 +3155,7 @@ void do_verbatim_input(void) keycodes[i] = (char)kbinput[i]; keycodes[count] = '\0'; - /* Insert the keystroke verbatim, without filtering control characters. */ + /* Insert the keystroke verbatim. */ inject(keycodes, count); free(keycodes);