ref: 11df072b288ee3a2f3d8f813db05af7205862e57
parent: 37e3a682cae4c36a56b9f5b982d3248dd817226c
author: cancel <cancel@cancel.fm>
date: Tue Dec 11 15:07:17 EST 2018
Add escape key going to normal mode if not in normal mode
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@
- `/`: change into or out of key-trigger mode (for the `!` operator)
- `'` (single quote): change into or out of rectangle selection size adjustment mode
- `shift+arrow keys`: adjust rectangle selection size (only in some terminals)
-- `escape`: deselect (set cursor rectangle selection to 1x1)
+- `escape`: return to normal mode, or deselect (set cursor rectangle selection to 1x1)
- `[` and `]`: adjust cosmetic grid rulers horizontally
- `{` and `}`: adjust cosmetic grid rulers vertically
- `(` and `)`: resize grid horizontally
--- a/tui_main.c
+++ b/tui_main.c
@@ -1242,7 +1242,7 @@
App_input_cmd_toggle_play_pause,
App_input_cmd_copy,
App_input_cmd_paste,
- App_input_cmd_deselect,
+ App_input_cmd_escape,
} App_input_cmd;
void app_input_cmd(App_state* a, App_input_cmd ev) {
@@ -1347,8 +1347,11 @@
a->needs_remarking = true;
a->is_draw_dirty = true;
} break;
- case App_input_cmd_deselect: {
- if (a->tui_cursor.h != 1 || a->tui_cursor.w != 1) {
+ case App_input_cmd_escape: {
+ if (a->input_mode != Tui_input_mode_normal) {
+ a->input_mode = Tui_input_mode_normal;
+ a->is_draw_dirty = true;
+ } else if (a->tui_cursor.h != 1 || a->tui_cursor.w != 1) {
a->tui_cursor.h = 1;
a->tui_cursor.w = 1;
a->is_draw_dirty = true;
@@ -1708,7 +1711,7 @@
stm_laptime(&last_time);
break;
case 27: // Escape
- app_input_cmd(&app_state, App_input_cmd_deselect);
+ app_input_cmd(&app_state, App_input_cmd_escape);
break;
// Selection size modification. These may not work in all terminals. (Only