commit 4ce2e146eab8f8779d5ae56a8977da71f76e5c45
parent 39ed8650438bf1f955d80136f65556f3654be3a4
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 19 Mar 2020 14:27:57 +0100
tweaks: elide three unneeded #defines
Backspace and Tab and Carriage Return have standard backslash escapes.
Diffstat:
6 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/chars.c b/src/chars.c
@@ -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;
diff --git a/src/global.c b/src/global.c
@@ -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))
diff --git a/src/nano.c b/src/nano.c
@@ -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';
diff --git a/src/nano.h b/src/nano.h
@@ -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
diff --git a/src/prompt.c b/src/prompt.c
@@ -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) {
diff --git a/src/winio.c b/src/winio.c
@@ -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