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