tweaks: elide three unneeded #defines

Backspace and Tab and Carriage Return have standard backslash escapes.
This commit is contained in:
Benno Schulenberg 2020-03-19 14:27:57 +01:00
parent 39ed865043
commit 4ce2e146ea
6 changed files with 9 additions and 12 deletions

View File

@ -83,7 +83,7 @@ bool is_blank_char(const char *c)
wchar_t wc;
if ((signed char)*c >= 0)
return (*c == ' ' || *c == TAB_CODE);
return (*c == ' ' || *c == '\t');
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return FALSE;

View File

@ -1130,13 +1130,13 @@ void shortcut_init(void)
/* Link key combos to functions in certain menus. */
add_to_sclist(MMOST|MBROWSER, "^M", 0, do_enter, 0);
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
add_to_sclist(MMOST, "^H", BS_CODE, do_backspace, 0);
add_to_sclist(MMOST, "^H", '\b', do_backspace, 0);
add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0);
add_to_sclist(MMOST, "Sh-Del", SHIFT_DELETE, do_backspace, 0);
add_to_sclist(MMOST, "^D", 0, do_delete, 0);
add_to_sclist(MMOST, "Del", KEY_DC, do_delete, 0);
add_to_sclist(MMOST, "^I", 0, do_tab, 0);
add_to_sclist(MMOST, "Tab", TAB_CODE, do_tab, 0);
add_to_sclist(MMOST, "Tab", '\t', do_tab, 0);
add_to_sclist((MMOST|MBROWSER) & ~MFINDINHELP, "^G", 0, do_help, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "^X", 0, do_exit, 0);
if (!ISSET(PRESERVE))

View File

@ -1469,13 +1469,13 @@ void suck_up_input_and_paste_it(void)
while (bracketed_paste) {
int input = get_kbinput(edit, BLIND);
if (input == CR_CODE) {
if (input == '\r') {
line->next = make_new_node(line);
line = line->next;
line->data = copy_of("");
index = 0;
} else if ((0x20 <= input && input <= 0xFF && input != DEL_CODE) ||
input == TAB_CODE) {
input == '\t') {
line->data = charealloc(line->data, index + 2);
line->data[index++] = (char)input;
line->data[index] = '\0';

View File

@ -565,9 +565,6 @@ enum
#endif
/* Basic control codes. */
#define BS_CODE 0x08
#define TAB_CODE 0x09
#define CR_CODE 0x0D
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F

View File

@ -460,7 +460,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (func == do_tab) {
#ifdef ENABLE_HISTORIES
if (history_list != NULL) {
if (last_kbinput != the_code_for(do_tab, TAB_CODE))
if (last_kbinput != the_code_for(do_tab, '\t'))
complete_len = strlen(answer);
if (complete_len > 0) {

View File

@ -930,7 +930,7 @@ int parse_kbinput(WINDOW *win)
case 1:
if (keycode >= 0x80)
retval = keycode;
else if (keycode == TAB_CODE)
else if (keycode == '\t')
retval = SHIFT_TAB;
else if ((keycode != 'O' && keycode != 'o' && keycode != '[') ||
key_buffer_len == 0 || *key_buffer == ESC_CODE) {
@ -1144,7 +1144,7 @@ int parse_kbinput(WINDOW *win)
}
/* Is Shift being held? */
if (modifiers & 0x01) {
if (retval == TAB_CODE)
if (retval == '\t')
return SHIFT_TAB;
if (!meta_key)
shift_held = TRUE;
@ -1194,7 +1194,7 @@ int parse_kbinput(WINDOW *win)
#ifndef NANO_TINY
/* When <Tab> is pressed while the mark is on, do an indent. */
if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN &&
if (retval == '\t' && openfile->mark && currmenu == MMAIN &&
!bracketed_paste && openfile->mark != openfile->current)
return INDENT_KEY;
#endif