diff options
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | src/kilo.c | 10 | ||||
-rw-r--r-- | src/lua.c | 11 | ||||
-rw-r--r-- | src/teliva.h | 12 |
4 files changed, 24 insertions, 19 deletions
diff --git a/README.md b/README.md index 20a4af2..a52ff8a 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,15 @@ a say in its future direction. call to `assume_default_colors()` in function `main()` at the bottom of `src/lua.c`. If you do this, you'll likely also need to tweak other colors for legibility. Look for calls to `FG()`, `BG()` and `COLOR_PAIR()`. - ``` + +* Backspace is known to not work in some configurations. As a workaround, + typing `ctrl-h` tends to work in those situations. + +* Keys outside the main keyboard area are mostly not supported. This includes + the delete key when it's set away from the main keyboard area. (Macs call + the backspace key “delete”; it should behave like backspace. As + a consequence the menu sometimes mentions keys that don't work, just to + encourage people to try options.) ## What's with the name? diff --git a/src/kilo.c b/src/kilo.c index 6df16e5..4035f60 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -674,6 +674,8 @@ static void editorMenu(void) { draw_menu_item("^b", "big picture"); draw_menu_item("^f", "find"); draw_menu_item("^/", "(un)comment line"); + draw_menu_item("^h", "back up cursor"); + draw_menu_item("^l", "end of line"); attrset(A_NORMAL); } @@ -830,7 +832,7 @@ static void editorFind() { mvprintw(LINES-2, 0, "Find: %s", query); int c = getch(); - if (c == TELIVA_BACKSPACE) { + if (c == KEY_BACKSPACE || c == DELETE || c == CTRL_H) { if (qlen != 0) query[--qlen] = '\0'; last_match = -1; } else if (c == ESC || c == ENTER) { @@ -1033,7 +1035,7 @@ static void editorGo(lua_State* L) { mvprintw(LINES-2, 0, "Go to: %s", query); int c = getch(); - if (c == TELIVA_BACKSPACE) { + if (c == KEY_BACKSPACE || c == DELETE || c == CTRL_H) { if (qlen != 0) query[--qlen] = '\0'; } else if (c == ESC || c == ENTER) { editorSetStatusMessage(""); @@ -1095,7 +1097,9 @@ static void editorProcessKeypress(lua_State* L) { case CTRL_F: editorFind(); break; - case TELIVA_BACKSPACE: + case KEY_BACKSPACE: + case DELETE: + case CTRL_H: editorDelChar(); break; case KEY_NPAGE: diff --git a/src/lua.c b/src/lua.c index 66eddbf..dceac8f 100644 --- a/src/lua.c +++ b/src/lua.c @@ -451,8 +451,8 @@ static void recent_changes_menu (int cursor, int history_array_size) { draw_string_on_menu("older"); /* draw_menu_item("↑/backspace", "newer"); */ attroff(A_REVERSE); - mvaddstr(LINES-1, menu_column, " ↑/" TELIVA_BACKSPACE_KEY_NAME " "); - menu_column += (strlen(TELIVA_BACKSPACE_KEY_NAME) + 4); + mvaddstr(LINES-1, menu_column, " ↑/backspace/delete/^h "); + menu_column += 23; attron(A_REVERSE); draw_string_on_menu("newer"); draw_menu_item("^e", "edit/add note"); @@ -616,7 +616,9 @@ void recent_changes_view (lua_State *L) { if (cursor > 1) --cursor; break; case KEY_UP: - case TELIVA_BACKSPACE: + case KEY_BACKSPACE: + case DELETE: + case CTRL_H: if (cursor < history_array_size) ++cursor; break; case CTRL_E: @@ -649,6 +651,7 @@ static void big_picture_menu (void) { menu_column = 2; draw_menu_item("Esc", "go back"); draw_menu_item("Enter", "submit"); + draw_menu_item("^h", "back up cursor"); draw_menu_item("^u", "clear"); draw_menu_item("^r", "recent changes"); attrset(A_NORMAL); @@ -811,7 +814,7 @@ restart: mvaddch(LINES-2, x, ' '); mvprintw(LINES-2, 0, "Edit: %s", query); int c = getch(); - if (c == TELIVA_BACKSPACE) { + if (c == KEY_BACKSPACE || c == DELETE || c == CTRL_H) { if (qlen != 0) query[--qlen] = '\0'; } else if (c == ESC) { return; diff --git a/src/teliva.h b/src/teliva.h index 65c1020..fdee063 100644 --- a/src/teliva.h +++ b/src/teliva.h @@ -11,11 +11,6 @@ enum KEY_ACTION { CTRL_F = 6, CTRL_G = 7, CTRL_H = 8, -#if __APPLE__ - TELIVA_BACKSPACE = 127, /* delete */ -#else - TELIVA_BACKSPACE = KEY_BACKSPACE, -#endif TAB = 9, ENTER = 10, CTRL_K = 11, @@ -27,12 +22,7 @@ enum KEY_ACTION { CTRL_X = 24, ESC = 27, CTRL_SLASH = 31, + DELETE = 127, }; -#if __APPLE__ - #define TELIVA_BACKSPACE_KEY_NAME "delete/backspace" -#else - #define TELIVA_BACKSPACE_KEY_NAME "backspace" -#endif - #endif |