about summary refs log tree commit diff stats
path: root/070display.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-05-27 15:57:38 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-05-27 15:57:38 -0700
commit0e120d8153a28f825a74d0c976c9d2f208e9e267 (patch)
treed034dc0ed6da5e07c629755b224a369b2ae25669 /070display.cc
parent7199af30e8fdcdc0848a2e2b90014b98f97998b3 (diff)
downloadmu-0e120d8153a28f825a74d0c976c9d2f208e9e267.tar.gz
1486 - repl: hitting enter now working
Diffstat (limited to '070display.cc')
-rw-r--r--070display.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/070display.cc b/070display.cc
index 1bfdb822..a9df09c5 100644
--- a/070display.cc
+++ b/070display.cc
@@ -71,6 +71,9 @@ case PRINT_CHARACTER_TO_DISPLAY: {
   long long int width = (w >= 0) ? w : 0;
   assert(scalar(ingredients.at(0)));
   long long int c = ingredients.at(0).at(0);
+//?   tb_shutdown(); //? 1
+//?   cerr << "AAA " << c << ' ' << (int)'\n' << ' ' << (int)'\r' << '\n'; //? 1
+//?   exit(1); //? 1
   if (c == '\n' || c == '\r') {
     if (Display_row < height-1) {
       Display_column = 0;
@@ -93,8 +96,11 @@ case PRINT_CHARACTER_TO_DISPLAY: {
   if (SIZE(ingredients) > 1) {
     assert(scalar(ingredients.at(1)));
     color = ingredients.at(1).at(0);
+//?     tb_shutdown(); //? 1
+//?     cerr << "AAA " << color << '\n'; //? 1
+//?     exit(1); //? 1
   }
-  tb_change_cell(Display_column, Display_row, c, color, TB_DEFAULT);
+  tb_change_cell(Display_column, Display_row, c, 7, TB_DEFAULT);
   if (Display_column < width-1) {
     ++Display_column;
     tb_set_cursor(Display_column, Display_row);
@@ -202,8 +208,12 @@ case WAIT_FOR_KEY_FROM_KEYBOARD: {
   do {
     tb_poll_event(&event);
   } while (event.type != TB_EVENT_KEY);
+  long long int result = event.key ? event.key : event.ch;
+  if (result == TB_KEY_CTRL_C) tb_shutdown(), exit(1);
+  if (result == TB_KEY_BACKSPACE2) result = TB_KEY_BACKSPACE;
+  if (result == TB_KEY_CARRIAGE_RETURN) result = TB_KEY_NEWLINE;
   products.resize(1);
-  products.at(0).push_back(event.ch);
+  products.at(0).push_back(result);
   break;
 }