commit 90a90365a8a042c22b4475d8046c88732676851c
parent 9cd30d4917bfe3d5a99a08b36e2b08e90d0b4f45
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 1 Aug 2016 12:56:05 +0200
tweaks: rename three constants, for clarity, and hardcode two others
Diffstat:
5 files changed, 16 insertions(+), 18 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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 - '@';