nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 4ec96f9f2e7d661e0da160e2b54e7a7bacf94e78
parent bdc856812fea5db0e608ac090c5c6650b8bc778a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 10 Aug 2020 07:53:41 +0200

tweaks: reshuffle a few lines, to condense the code, and improve comment

Diffstat:
Msrc/prompt.c | 2+-
Msrc/text.c | 2+-
Msrc/winio.c | 18+++++++-----------
3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/prompt.c b/src/prompt.c @@ -195,8 +195,8 @@ void inject_into_answer(char *burst, size_t count) /* Get a verbatim keystroke and insert it into the answer. */ void do_statusbar_verbatim_input(void) { + size_t count = 1; char *bytes; - size_t count; bytes = get_verbatim_kbinput(bottomwin, &count); diff --git a/src/text.c b/src/text.c @@ -3004,8 +3004,8 @@ void do_wordlinechar_count(void) /* Get verbatim input. */ void do_verbatim_input(void) { + size_t count = 1; char *bytes; - size_t count; /* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */ statusbar(_("Verbatim Input")); diff --git a/src/winio.c b/src/winio.c @@ -293,9 +293,9 @@ void implant(const char *string) } #endif -/* Try to read one code from the keystroke buffer. - * If the buffer is empty and win isn't NULL, try to read in more codes, - * and if the buffer is still empty then, return NULL. */ +/* Try to read one code from the keystroke buffer. If the buffer is empty and + * win isn't NULL, try to get more codes from the keyboard. Return the first + * code, or ERR if the keystroke buffer is still empty. */ int get_input(WINDOW *win) { int input; @@ -955,8 +955,7 @@ int parse_kbinput(WINDOW *win) ('a' <= *key_buffer && *key_buffer <= 'd'))) { /* An iTerm2/Eterm/rxvt double-escape sequence: Esc Esc [ X * for Option+arrow, or Esc Esc [ x for Shift+Alt+arrow. */ - keycode= get_input(NULL); - switch (keycode) { + switch (get_input(NULL)) { case 'A': return KEY_HOME; case 'B': return KEY_END; case 'C': return CONTROL_RIGHT; @@ -1381,13 +1380,11 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) /* Reserve ample space for the possible result. */ yield = (int *)nmalloc(6 * sizeof(int)); - *count = 1; #ifdef ENABLE_UTF8 - if (using_utf8()) { - /* If the first code is a valid Unicode starter digit (0 or 1), - * commence Unicode input. Otherwise, put the code back. */ - if (keycode == '0' || keycode == '1') { + /* If the first code is a valid Unicode starter digit (0 or 1), + * commence Unicode input. Otherwise, put the code back. */ + if (using_utf8() && (keycode == '0' || keycode == '1')) { long unicode = assemble_unicode(keycode); char *multibyte; @@ -1408,7 +1405,6 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count) free(multibyte); return yield; - } } #endif /* ENABLE_UTF8 */