about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-06-25 09:31:08 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-06-25 09:31:08 -0700
commit596490f46834f99c35bc42f6c5878ccee19b7c63 (patch)
tree46e3c8a4b730d7a4d0c0301c2b79724216f91da6
parent48bb86278826a08e2550f2c49e695167fb137957 (diff)
downloadmu-596490f46834f99c35bc42f6c5878ccee19b7c63.tar.gz
1656 - smooth refresh done
Had to take control of tb_present() after all. Termbox was wise.
-rw-r--r--070display.cc40
-rw-r--r--071print.mu26
-rw-r--r--edit.mu3
3 files changed, 59 insertions, 10 deletions
diff --git a/070display.cc b/070display.cc
index db205d63..477552a0 100644
--- a/070display.cc
+++ b/070display.cc
@@ -8,6 +8,7 @@
 
 :(before "End Globals")
 long long int Display_row = 0, Display_column = 0;
+bool Autodisplay = true;
 
 :(before "End Primitive Recipe Declarations")
 OPEN_CONSOLE,
@@ -57,7 +58,7 @@ case CLEAR_LINE_ON_DISPLAY: {
     tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK);
   }
   tb_set_cursor(Display_column, Display_row);
-  tb_present();
+  if (Autodisplay) tb_present();
   break;
 }
 
@@ -80,7 +81,7 @@ case PRINT_CHARACTER_TO_DISPLAY: {
       Display_column = 0;
       ++Display_row;
       tb_set_cursor(Display_column, Display_row);
-      tb_present();
+      if (Autodisplay) tb_present();
     }
     break;
   }
@@ -89,7 +90,7 @@ case PRINT_CHARACTER_TO_DISPLAY: {
       tb_change_cell(Display_column-1, Display_row, ' ', TB_WHITE, TB_BLACK);
       --Display_column;
       tb_set_cursor(Display_column, Display_row);
-      tb_present();
+      if (Autodisplay) tb_present();
     }
     break;
   }
@@ -106,7 +107,7 @@ case PRINT_CHARACTER_TO_DISPLAY: {
     ++Display_column;
     tb_set_cursor(Display_column, Display_row);
   }
-  tb_present();
+  if (Autodisplay) tb_present();
   break;
 }
 
@@ -133,7 +134,7 @@ case MOVE_CURSOR_ON_DISPLAY: {
   assert(scalar(ingredients.at(1)));
   Display_column = ingredients.at(1).at(0);
   tb_set_cursor(Display_column, Display_row);
-  tb_present();
+  if (Autodisplay) tb_present();
   break;
 }
 
@@ -148,7 +149,7 @@ case MOVE_CURSOR_DOWN_ON_DISPLAY: {
   if (Display_row < height-1) {
     Display_row++;
     tb_set_cursor(Display_column, Display_row);
-    tb_present();
+    if (Autodisplay) tb_present();
   }
   break;
 }
@@ -162,7 +163,7 @@ case MOVE_CURSOR_UP_ON_DISPLAY: {
   if (Display_row > 0) {
     Display_row--;
     tb_set_cursor(Display_column, Display_row);
-    tb_present();
+    if (Autodisplay) tb_present();
   }
   break;
 }
@@ -178,7 +179,7 @@ case MOVE_CURSOR_RIGHT_ON_DISPLAY: {
   if (Display_column < width-1) {
     Display_column++;
     tb_set_cursor(Display_column, Display_row);
-    tb_present();
+    if (Autodisplay) tb_present();
   }
   break;
 }
@@ -192,7 +193,7 @@ case MOVE_CURSOR_LEFT_ON_DISPLAY: {
   if (Display_column > 0) {
     Display_column--;
     tb_set_cursor(Display_column, Display_row);
-    tb_present();
+    if (Autodisplay) tb_present();
   }
   break;
 }
@@ -239,6 +240,27 @@ case SHOW_CURSOR_ON_DISPLAY: {
   break;
 }
 
+:(before "End Primitive Recipe Declarations")
+HIDE_DISPLAY,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["hide-display"] = HIDE_DISPLAY;
+:(before "End Primitive Recipe Implementations")
+case HIDE_DISPLAY: {
+  Autodisplay = false;
+  break;
+}
+
+:(before "End Primitive Recipe Declarations")
+SHOW_DISPLAY,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["show-display"] = SHOW_DISPLAY;
+:(before "End Primitive Recipe Implementations")
+case SHOW_DISPLAY: {
+  Autodisplay = true;
+  tb_present();
+  break;
+}
+
 //:: Keyboard/mouse management
 
 :(before "End Primitive Recipe Declarations")
diff --git a/071print.mu b/071print.mu
index a5cb191b..0f9db476 100644
--- a/071print.mu
+++ b/071print.mu
@@ -559,6 +559,32 @@ recipe show-cursor [
   reply x:address:screen
 ]
 
+recipe hide-screen [
+  default-space:address:array:location <- new location:type, 30:literal
+  x:address:screen <- next-ingredient
+  # if x exists (not real display), do nothing
+  {
+    break-unless x:address:screen
+    reply x:address:screen
+  }
+  # otherwise, real screen
+  hide-display
+  reply x:address:screen
+]
+
+recipe show-screen [
+  default-space:address:array:location <- new location:type, 30:literal
+  x:address:screen <- next-ingredient
+  # if x exists (not real display), do nothing
+  {
+    break-unless x:address:screen
+    reply x:address:screen
+  }
+  # otherwise, real screen
+  show-display
+  reply x:address:screen
+]
+
 recipe print-string [
   default-space:address:array:location <- new location:type, 30:literal
   x:address:screen <- next-ingredient
diff --git a/edit.mu b/edit.mu
index e8daedc2..d8baff98 100644
--- a/edit.mu
+++ b/edit.mu
@@ -157,7 +157,7 @@ recipe render [
   left:number <- get editor:address:editor-data/deref, left:offset
   screen-height:number <- screen-height screen:address
   right:number <- get editor:address:editor-data/deref, right:offset
-  hide-cursor screen:address
+  hide-screen screen:address
   # traversing editor
   curr:address:duplex-list <- get editor:address:editor-data/deref, top-of-screen:offset
   curr:address:duplex-list <- next-duplex curr:address:duplex-list
@@ -228,6 +228,7 @@ recipe render [
   cursor-row:number <- get editor:address:editor-data/deref, cursor-row:offset
   cursor-column:number <- get editor:address:editor-data/deref, cursor-column:offset
   move-cursor screen:address, cursor-row:number, cursor-column:number
+  show-screen screen:address
   reply editor:address:editor-data/same-as-ingredient:0
 ]