Browse Source

Add ctrl+z as undo (if allowed by terminal, hopefully)

master
cancel 6 years ago
parent
commit
df81654324
  1. 2
      README.md
  2. 9
      tui_main.c

2
README.md

@ -67,7 +67,7 @@ Run the interactive terminal UI, useful for debugging or observing behavior. Pas
- `A`-`Z`, `a`-`z`, `0`-`9`, and other printable characters: write character to grid at cursor - `A`-`Z`, `a`-`z`, `0`-`9`, and other printable characters: write character to grid at cursor
- Spacebar: play or pause - Spacebar: play or pause
- `ctrl+f`: step the simulation one tick forward - `ctrl+f`: step the simulation one tick forward
- `ctrl+u`: undo - `ctrl+z` or `ctrl+u`: undo
- return or enter: change into or out of overwrite/append mode - return or enter: change into or out of overwrite/append mode
- `/`: change into or out of key-trigger mode (for the `!` operator) - `/`: change into or out of key-trigger mode (for the `!` operator)
- `[` and `]`: Adjust cosmetic grid rulers horizontally - `[` and `]`: Adjust cosmetic grid rulers horizontally

9
tui_main.c

@ -1093,9 +1093,11 @@ int main(int argc, char** argv) {
// ncurses state consistent, at the cost of less responsive terminal // ncurses state consistent, at the cost of less responsive terminal
// interrupt. (This will rarely happen.) // interrupt. (This will rarely happen.)
intrflush(stdscr, FALSE); intrflush(stdscr, FALSE);
// Receive keyboard input immediately, and receive shift, control, etc. as // Receive keyboard input immediately without line buffering, and receive
// separate events, instead of combined with individual characters. // ctrl+z, ctrl+c etc. as input instead of having a signal generated. We need
// raw(); // to do this even with wtimeout() if we don't want ctrl+z etc. to interrupt
// the program.
raw();
// Don't echo keyboard input // Don't echo keyboard input
noecho(); noecho();
// Also receive arrow keys, etc. // Also receive arrow keys, etc.
@ -1212,6 +1214,7 @@ int main(int argc, char** argv) {
case KEY_RIGHT: case KEY_RIGHT:
app_move_cursor_relative(&app_state, 0, 1); app_move_cursor_relative(&app_state, 0, 1);
break; break;
case AND_CTRL('z'):
case AND_CTRL('u'): case AND_CTRL('u'):
app_input_cmd(&app_state, App_input_cmd_undo); app_input_cmd(&app_state, App_input_cmd_undo);
break; break;

Loading…
Cancel
Save