diff --git a/src/chars.c b/src/chars.c index 1bddb35ca2fa579599c3e93ca30f1a17636dd82d..cd19c4ae355e4bf4aa02a75541ed7488987d8994 100644 --- a/src/chars.c +++ b/src/chars.c @@ -219,7 +219,7 @@ char control_rep(const signed char c) /* An embedded newline is an encoded null. */ if (c == '\n') return '@'; - else if (c == NANO_CONTROL_8) + else if (c == DEL_CODE) return '?'; else if (c == -97) return '='; diff --git a/src/global.c b/src/global.c index 73a79fc9c814a518bff5d88ca8f4838c7bf40883..191b38e8d64b6334a3bdd7498b1e707aa43c5407 100644 --- a/src/global.c +++ b/src/global.c @@ -433,7 +433,7 @@ void assign_keyinfo(sc *s, const char *keystring) * but the exact integer values of ^I and ^M. Rebinding the * latter therefore also rebinds Tab and Enter. */ else if (!strcasecmp(keystring, "Tab")) - s->keycode = NANO_CONTROL_I; + s->keycode = TAB_CODE; else if (!strcasecmp(keystring, "Enter")) s->keycode = KEY_ENTER; else if (!strcasecmp(keystring, "PgUp")) diff --git a/src/nano.h b/src/nano.h index 1c4e4ee248ab0cbd0397ee76555967bffb184f77..7f5ec758fd39c2b666376beda91c2e37e8491f13 100644 --- a/src/nano.h +++ b/src/nano.h @@ -550,12 +550,10 @@ enum #define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\ MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER) -/* Control key sequences. Changing these would be very, very bad. */ -#define NANO_CONTROL_SPACE 0 -#define NANO_CONTROL_I 9 -#define NANO_CONTROL_3 27 -#define NANO_CONTROL_7 31 -#define NANO_CONTROL_8 127 +/* Basic control codes. */ +#define TAB_CODE 0x09 +#define ESC_CODE 0x1B +#define DEL_CODE 0x7F /* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */ #define CONTROL_LEFT 0x401 diff --git a/src/prompt.c b/src/prompt.c index 5eddaa0ab7fe4749bafb9b9ce0cf0e8818b1db85..3074408d5e7abc93dd5029f2d4a9a0b3a4f6ad3e 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -586,7 +586,7 @@ functionptrtype get_prompt_string(int *actual, bool allow_tabs, if (func == do_tab) { #ifndef DISABLE_HISTORIES if (history_list != NULL) { - if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I)) + if (last_kbinput != sc_seq_or(do_tab, TAB_CODE)) complete_len = strlen(answer); if (complete_len > 0) { diff --git a/src/winio.c b/src/winio.c index 1b691cb65ecccc641a26c1a76cc3ff5bb6140ad0..15920444e1eb597908fd2d192eb6af6db1d26ff0 100644 --- a/src/winio.c +++ b/src/winio.c @@ -73,8 +73,8 @@ bool the_window_resized(void) * - Ctrl-M is Enter under ASCII, ANSI, VT100, VT220, and VT320. * - Ctrl-Q is XON under ASCII, ANSI, VT100, VT220, and VT320. * - Ctrl-S is XOFF under ASCII, ANSI, VT100, VT220, and VT320. - * - Ctrl-8 (Ctrl-?, NANO_CONTROL_8) is Delete under ASCII, ANSI, - * VT100, and VT220, but is Backspace under VT320. + * - Ctrl-8 (Ctrl-?) is Delete under ASCII, ANSI, VT100, and VT220, + * but is Backspace under VT320. * * Note: VT220 and VT320 also generate Esc [ 3 ~ for Delete. By * default, xterm assumes it's running on a VT320 and generates Ctrl-8 @@ -255,7 +255,7 @@ void unget_kbinput(int kbinput, bool metakey) unget_input(&kbinput, 1); if (metakey) { - kbinput = NANO_CONTROL_3; + kbinput = ESC_CODE; unget_input(&kbinput, 1); } } @@ -361,7 +361,7 @@ int parse_kbinput(WINDOW *win) if (keycode == ERR) return ERR; - if (keycode == NANO_CONTROL_3) { + if (keycode == ESC_CODE) { /* Increment the escape counter. */ escapes++; /* If there are four consecutive escapes, discard three of them. */ @@ -380,7 +380,7 @@ int parse_kbinput(WINDOW *win) /* Reset the escape counter. */ escapes = 0; if ((keycode != 'O' && keycode != 'o' && keycode != '[') || - key_buffer_len == 0 || *key_buffer == 0x1B) { + key_buffer_len == 0 || *key_buffer == ESC_CODE) { /* One escape followed by a single non-escape: * meta key sequence mode. */ if (!solitary || (keycode >= 0x20 && keycode < 0x7F)) @@ -573,7 +573,7 @@ int parse_kbinput(WINDOW *win) /* Slang doesn't support KEY_SDC. */ case KEY_SDC: #endif - case NANO_CONTROL_8: + case DEL_CODE: if (ISSET(REBIND_DELETE)) return sc_seq_or(do_delete, keycode); else @@ -1266,16 +1266,16 @@ int get_control_kbinput(int kbinput) /* Ctrl-Space (Ctrl-2, Ctrl-@, Ctrl-`) */ if (kbinput == ' ' || kbinput == '2') - retval = NANO_CONTROL_SPACE; + retval = 0; /* Ctrl-/ (Ctrl-7, Ctrl-_) */ else if (kbinput == '/') - retval = NANO_CONTROL_7; + retval = 31; /* Ctrl-3 (Ctrl-[, Esc) to Ctrl-7 (Ctrl-/, Ctrl-_) */ else if ('3' <= kbinput && kbinput <= '7') retval = kbinput - 24; /* Ctrl-8 (Ctrl-?) */ else if (kbinput == '8' || kbinput == '?') - retval = NANO_CONTROL_8; + retval = DEL_CODE; /* Ctrl-@ (Ctrl-Space, Ctrl-2, Ctrl-`) to Ctrl-_ (Ctrl-/, Ctrl-7) */ else if ('@' <= kbinput && kbinput <= '_') retval = kbinput - '@';