shithub: orca

Download patch

ref: df81654324b585f0a0f4167ac2f9dae2106cdc46
parent: 7555f772947dfad2031fbac96dc566a1a6aaa891
author: cancel <cancel@cancel.fm>
date: Sun Dec 9 16:28:07 EST 2018

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

--- a/README.md
+++ b/README.md
@@ -67,7 +67,7 @@
 - `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
--- a/tui_main.c
+++ b/tui_main.c
@@ -1093,9 +1093,11 @@
   // 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 @@
     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;