From c53839cefa86d231bd5fcc80d916056ac6841e29 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 15 Jul 2024 08:43:38 +0200 Subject: [PATCH] tweaks: rename a symbol, away from an obscure abbreviation Also, reshuffle its definition, and change its value to match other special codes. --- src/browser.c | 8 ++++---- src/definitions.h | 8 +++++--- src/help.c | 2 +- src/nano.c | 2 +- src/prompt.c | 8 ++++---- src/text.c | 2 +- src/winio.c | 8 ++++---- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/browser.c b/src/browser.c index f12573a4..2ade2aec 100644 --- a/src/browser.c +++ b/src/browser.c @@ -498,11 +498,11 @@ char *browse(char *path) #ifndef NANO_TINY /* Simulate a terminal resize to force a directory reread, * or because the terminal dimensions might have changed. */ - kbinput = KEY_WINCH; + kbinput = THE_WINDOW_RESIZED; } else if (function == do_toggle && get_shortcut(kbinput)->toggle == NO_HELP) { TOGGLE(NO_HELP); window_init(); - kbinput = KEY_WINCH; + kbinput = THE_WINDOW_RESIZED; #endif } else if (function == do_search_backward) { search_filename(BACKWARD); @@ -642,7 +642,7 @@ char *browse(char *path) implant(first_sc_for(MBROWSER, function)->expansion); #endif #ifndef NANO_TINY - } else if (kbinput == KEY_WINCH) { + } else if (kbinput == THE_WINDOW_RESIZED) { ; /* Gets handled below. */ #endif } else if (function == do_exit) { @@ -652,7 +652,7 @@ char *browse(char *path) #ifndef NANO_TINY /* If the terminal resized (or might have), refresh the file list. */ - if (kbinput == KEY_WINCH) { + if (kbinput == THE_WINDOW_RESIZED) { /* Remember the selected file, to be able to reselect it. */ present_name = copy_of(filelist[selected]); goto read_directory_contents; diff --git a/src/definitions.h b/src/definitions.h index 68fc126d..08170769 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -227,9 +227,14 @@ #define PLANTED_A_COMMAND 0x4EC #define NO_SUCH_FUNCTION 0x4EF +#ifndef NANO_TINY /* A special keycode for Ctrl + the central key on the numeric keypad. */ #define KEY_CENTER 0x4F0 +/* A special keycode for when we get a SIGWINCH (a window resize). */ +#define THE_WINDOW_RESIZED 0x4F7 +#endif + /* A special keycode to signal the beginning and end of a bracketed paste. */ #define BRACKETED_PASTE_MARKER 0x4FB @@ -240,9 +245,6 @@ #define KEY_FRESH 0x4FE #ifndef NANO_TINY -/* A special keycode for when we get a SIGWINCH (a window resize). */ -#define KEY_WINCH -2 - /* Some extra flags for the undo function. */ #define WAS_BACKSPACE_AT_EOF (1<<1) #define WAS_WHOLE_LINE (1<<2) diff --git a/src/help.c b/src/help.c index b5771a7d..b881769b 100644 --- a/src/help.c +++ b/src/help.c @@ -513,7 +513,7 @@ void show_help(void) get_mouseinput(&dummy_row, &dummy_col, TRUE); #endif #ifndef NANO_TINY - } else if (kbinput == KEY_WINCH) { + } else if (kbinput == THE_WINDOW_RESIZED) { ; /* Nothing to do. */ #endif } else if (function == do_exit) { diff --git a/src/nano.c b/src/nano.c index 0ae71d8e..599f005e 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1592,7 +1592,7 @@ void process_a_keystroke(void) lastmessage = VACUUM; #ifndef NANO_TINY - if (input == KEY_WINCH) + if (input == THE_WINDOW_RESIZED) return; #endif #ifdef ENABLE_MOUSE diff --git a/src/prompt.c b/src/prompt.c index d427d1ea..06ed0a9d 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -442,9 +442,9 @@ functionptrtype acquire_an_answer(int *actual, bool *listed, #ifndef NANO_TINY /* If the window size changed, go reformat the prompt string. */ - if (input == KEY_WINCH) { + if (input == THE_WINDOW_RESIZED) { refresh_func(); /* Only needed when in file browser. */ - *actual = KEY_WINCH; + *actual = THE_WINDOW_RESIZED; #ifdef ENABLE_HISTORIES free(stored_string); #endif @@ -598,7 +598,7 @@ int do_prompt(int menu, const char *provided, linestruct **history_list, free(prompt); #ifndef NANO_TINY - if (retval == KEY_WINCH) + if (retval == THE_WINDOW_RESIZED) goto redo_theprompt; #endif @@ -697,7 +697,7 @@ int ask_user(bool withall, const char *question) kbinput = get_kbinput(footwin, !withall); #ifndef NANO_TINY - if (kbinput == KEY_WINCH) + if (kbinput == THE_WINDOW_RESIZED) continue; /* Accept first character of an external paste and ignore the rest. */ diff --git a/src/text.c b/src/text.c index e6e01f35..19e85567 100644 --- a/src/text.c +++ b/src/text.c @@ -2877,7 +2877,7 @@ void do_linter(void) kbinput = get_kbinput(footwin, VISIBLE); #ifndef NANO_TINY - if (kbinput == KEY_WINCH) + if (kbinput == THE_WINDOW_RESIZED) continue; #endif function = func_from_key(kbinput); diff --git a/src/winio.c b/src/winio.c index 09ebbd69..843d34df 100644 --- a/src/winio.c +++ b/src/winio.c @@ -218,7 +218,7 @@ void read_keys_from(WINDOW *frame) #ifndef NANO_TINY if (the_window_resized) { regenerate_screen(); - input = KEY_WINCH; + input = THE_WINDOW_RESIZED; } if (timed) { @@ -272,7 +272,7 @@ void read_keys_from(WINDOW *frame) } /* If we got a SIGWINCH, get out as the frame argument is no longer valid. */ - if (input == KEY_WINCH) + if (input == THE_WINDOW_RESIZED) return; /* Remember where the recording of this keystroke (or burst of them) started. */ @@ -1445,7 +1445,7 @@ int *parse_verbatim_kbinput(WINDOW *frame, size_t *count) #ifndef NANO_TINY /* When the window was resized, abort and return nothing. */ - if (keycode == KEY_WINCH) { + if (keycode == THE_WINDOW_RESIZED) { *count = 999; return NULL; } @@ -1469,7 +1469,7 @@ int *parse_verbatim_kbinput(WINDOW *frame, size_t *count) } #ifndef NANO_TINY - if (keycode == KEY_WINCH) { + if (keycode == THE_WINDOW_RESIZED) { *count = 999; free(yield); return NULL;