diff --git a/README.md b/README.md index 5743aed..972b220 100644 --- a/README.md +++ b/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 - Spacebar: play or pause - `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 - `/`: change into or out of key-trigger mode (for the `!` operator) - `[` and `]`: Adjust cosmetic grid rulers horizontally diff --git a/tui_main.c b/tui_main.c index 496b57b..2184726 100644 --- a/tui_main.c +++ b/tui_main.c @@ -1093,9 +1093,11 @@ int main(int argc, char** argv) { // ncurses state consistent, at the cost of less responsive terminal // interrupt. (This will rarely happen.) intrflush(stdscr, FALSE); - // Receive keyboard input immediately, and receive shift, control, etc. as - // separate events, instead of combined with individual characters. - // raw(); + // Receive keyboard input immediately without line buffering, and receive + // ctrl+z, ctrl+c etc. as input instead of having a signal generated. We need + // to do this even with wtimeout() if we don't want ctrl+z etc. to interrupt + // the program. + raw(); // Don't echo keyboard input noecho(); // Also receive arrow keys, etc. @@ -1212,6 +1214,7 @@ int main(int argc, char** argv) { case KEY_RIGHT: app_move_cursor_relative(&app_state, 0, 1); break; + case AND_CTRL('z'): case AND_CTRL('u'): app_input_cmd(&app_state, App_input_cmd_undo); break;