mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 06:39:43 +03:00
tweaks: update several comments after the previous changes
This commit is contained in:
parent
0ed62e84de
commit
71daa1ef6b
16
src/nano.c
16
src/nano.c
@ -1528,8 +1528,7 @@ void do_input(void)
|
|||||||
/* Check for a shortcut in the main list. */
|
/* Check for a shortcut in the main list. */
|
||||||
shortcut = get_shortcut(&input);
|
shortcut = get_shortcut(&input);
|
||||||
|
|
||||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
/* If not a command, discard anything that is not a normal character byte. */
|
||||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
|
||||||
if (shortcut == NULL) {
|
if (shortcut == NULL) {
|
||||||
if (input < 0x20 || input > 0xFF || meta_key)
|
if (input < 0x20 || input > 0xFF || meta_key)
|
||||||
unbound_key(input);
|
unbound_key(input);
|
||||||
@ -1548,18 +1547,14 @@ void do_input(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we got a shortcut or toggle, or if there aren't any other
|
/* If we have a command, or if there aren't any other key codes waiting,
|
||||||
* characters waiting after the one we read in, we need to output
|
* it's time to insert the gathered bytes into the current buffer. */
|
||||||
* all available characters in the input puddle. Note that this
|
|
||||||
* puddle will be empty if we're in view mode. */
|
|
||||||
if (shortcut || get_key_buffer_len() == 0) {
|
if (shortcut || get_key_buffer_len() == 0) {
|
||||||
if (puddle != NULL) {
|
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';
|
puddle[depth] = '\0';
|
||||||
inject(puddle, depth);
|
inject(puddle, depth);
|
||||||
|
|
||||||
/* Empty the input buffer. */
|
/* Empty the little input buffer. */
|
||||||
free(puddle);
|
free(puddle);
|
||||||
puddle = NULL;
|
puddle = NULL;
|
||||||
depth = 0;
|
depth = 0;
|
||||||
@ -1646,8 +1641,7 @@ void do_input(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The user typed output_len multibyte characters. Add them to the edit
|
/* The user typed output_len multibyte characters. Add them to the buffer. */
|
||||||
* buffer, filtering out ASCII control characters when filtering is TRUE. */
|
|
||||||
void inject(char *output, size_t output_len)
|
void inject(char *output, size_t output_len)
|
||||||
{
|
{
|
||||||
char onechar[MAXCHARLEN];
|
char onechar[MAXCHARLEN];
|
||||||
|
20
src/prompt.c
20
src/prompt.c
@ -87,13 +87,12 @@ int do_statusbar_input(bool *finished)
|
|||||||
/* Check for a shortcut in the current list. */
|
/* Check for a shortcut in the current list. */
|
||||||
shortcut = get_shortcut(&input);
|
shortcut = get_shortcut(&input);
|
||||||
|
|
||||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
/* If not a command, discard anything that is not a normal character byte.
|
||||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
* 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 (shortcut == NULL) {
|
||||||
if (input < 0x20 || input > 0xFF || meta_key)
|
if (input < 0x20 || input > 0xFF || meta_key)
|
||||||
beep();
|
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 ||
|
else if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
|
||||||
openfile->filename[0] == '\0') {
|
openfile->filename[0] == '\0') {
|
||||||
kbinput_len++;
|
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
|
/* 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
|
* it's time to insert all characters in the input buffer (if not empty)
|
||||||
* input buffer (if not empty) into the answer. */
|
* into the answer, and then clear the input buffer. */
|
||||||
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
|
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);
|
inject_into_answer(kbinput, kbinput_len);
|
||||||
|
|
||||||
/* Empty the input buffer. */
|
|
||||||
kbinput_len = 0;
|
kbinput_len = 0;
|
||||||
free(kbinput);
|
free(kbinput);
|
||||||
kbinput = NULL;
|
kbinput = NULL;
|
||||||
@ -176,8 +171,7 @@ int do_statusbar_input(bool *finished)
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The user typed input_len multibyte characters. Add them to the answer,
|
/* The user typed input_len multibyte characters. Add them to the answer. */
|
||||||
* filtering out ASCII control characters if filtering is TRUE. */
|
|
||||||
void inject_into_answer(int *the_input, size_t input_len)
|
void inject_into_answer(int *the_input, size_t input_len)
|
||||||
{
|
{
|
||||||
char *output = charalloc(input_len + 1);
|
char *output = charalloc(input_len + 1);
|
||||||
|
@ -3155,7 +3155,7 @@ void do_verbatim_input(void)
|
|||||||
keycodes[i] = (char)kbinput[i];
|
keycodes[i] = (char)kbinput[i];
|
||||||
keycodes[count] = '\0';
|
keycodes[count] = '\0';
|
||||||
|
|
||||||
/* Insert the keystroke verbatim, without filtering control characters. */
|
/* Insert the keystroke verbatim. */
|
||||||
inject(keycodes, count);
|
inject(keycodes, count);
|
||||||
|
|
||||||
free(keycodes);
|
free(keycodes);
|
||||||
|
Loading…
Reference in New Issue
Block a user