Browse Source

Add escape key going to normal mode if not in normal mode

master
cancel 7 years ago
parent
commit
11df072b28
  1. 2
      README.md
  2. 11
      tui_main.c

2
README.md

@ -76,7 +76,7 @@ Run the interactive terminal UI, useful for debugging or observing behavior. Pas
- `/`: 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

11
tui_main.c

@ -1242,7 +1242,7 @@ typedef enum {
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 @@ void app_input_cmd(App_state* a, App_input_cmd ev) {
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 @@ int main(int argc, char** argv) {
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

Loading…
Cancel
Save