about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--037call_reply.cc5
-rw-r--r--070display.cc14
-rw-r--r--repl.mu2
-rw-r--r--termbox/termbox.c5
-rw-r--r--termbox/termbox.h2
5 files changed, 25 insertions, 3 deletions
diff --git a/037call_reply.cc b/037call_reply.cc
index a6ec8c0c..7e973ed3 100644
--- a/037call_reply.cc
+++ b/037call_reply.cc
@@ -20,6 +20,10 @@ Recipe_number["reply"] = REPLY;
 case REPLY: {
   const instruction& reply_inst = current_instruction();  // save pointer into recipe before pop
   --Callstack_depth;
+//?   if (tb_is_active()) { //? 1
+//?     tb_clear(); //? 1
+//?     cerr << Recipe[Current_routine->calls.front().running_recipe].name << ' ' << current_step_index() << '\n'; //? 1
+//?   } //? 1
   Current_routine->calls.pop_front();
   // just in case 'main' returns a value, drop it for now
   if (Current_routine->calls.empty()) goto stop_running_current_routine;
@@ -29,6 +33,7 @@ case REPLY: {
   // check that any reply ingredients with /same-as-ingredient connect up
   // the corresponding ingredient and product in the caller.
   for (long long int i = 0; i < SIZE(caller_instruction.products); ++i) {
+//?     cerr << Recipe[Current_routine->calls.front().running_recipe].name << '\n'; //? 1
     trace(Primitive_recipe_depth, "run") << "result " << i << " is " << to_string(ingredients.at(i));
     if (has_property(reply_inst.ingredients.at(i), "same-as-ingredient")) {
       vector<string> tmp = property(reply_inst.ingredients.at(i), "same-as-ingredient");
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;
 }
 
diff --git a/repl.mu b/repl.mu
index 0099d2cc..fb66f3ee 100644
--- a/repl.mu
+++ b/repl.mu
@@ -68,5 +68,5 @@ recipe read-instruction [
     loop
   }
   result2:address:array:character <- buffer-to-array result:address:buffer
-  reply result2:address:array:character
+  reply result2:address:array:character, k:address:keyboard, x:address:screen
 ]
diff --git a/termbox/termbox.c b/termbox/termbox.c
index 80aeb3a9..0e4d5a9f 100644
--- a/termbox/termbox.c
+++ b/termbox/termbox.c
@@ -153,6 +153,11 @@ void tb_shutdown(void)
   termw = termh = -1;
 }
 
+int tb_is_active(void)
+{
+  return termw != -1;
+}
+
 void tb_present(void)
 {
   int x,y,w,i;
diff --git a/termbox/termbox.h b/termbox/termbox.h
index 0bd55be9..ac31230a 100644
--- a/termbox/termbox.h
+++ b/termbox/termbox.h
@@ -44,6 +44,8 @@ int tb_init(void);
 /* Restore terminal mode. */
 void tb_shutdown(void);
 
+int tb_is_active(void);
+
 /* Size of the screen. Return negative values before tb_init() or after
  * tb_shutdown() */
 int tb_width(void);