about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--070display.cc23
-rw-r--r--edit.mu32
2 files changed, 48 insertions, 7 deletions
diff --git a/070display.cc b/070display.cc
index ce6d657f..b32af983 100644
--- a/070display.cc
+++ b/070display.cc
@@ -369,3 +369,26 @@ case INTERACTIONS_LEFT: {
   products.at(0).push_back(tb_event_ready());
   break;
 }
+
+//: a hack to make edit.mu more responsive
+
+:(before "End Primitive Recipe Declarations")
+CLEAR_DISPLAY_FROM,
+:(before "End Primitive Recipe Numbers")
+Recipe_ordinal["clear-display-from"] = CLEAR_DISPLAY_FROM;
+:(before "End Primitive Recipe Implementations")
+case CLEAR_DISPLAY_FROM: {
+  // todo: error checking
+  int row = ingredients.at(0).at(0);
+  int column = ingredients.at(1).at(0);
+  int left = ingredients.at(2).at(0);
+  int right = ingredients.at(3).at(0);
+  int height=tb_height();
+  for (; row < height; ++row, column=left) {  // start column from left in every inner loop except first
+    for (; column <= right; ++column) {
+      tb_change_cell(column, row, ' ', TB_WHITE, TB_BLACK);
+    }
+  }
+  if (Autodisplay) tb_present();
+  break;
+}
diff --git a/edit.mu b/edit.mu
index 83abeec1..4e4f3cb6 100644
--- a/edit.mu
+++ b/edit.mu
@@ -244,8 +244,7 @@ recipe render [
     *before-cursor <- copy prev
   }
   # clear rest of screen
-  clear-line-delimited screen, column, right
-  clear-rest-of-screen screen, row, left, right
+  clear-screen-from screen, row, column, left, right
   reply row, screen/same-as-ingredient:0
 ]
 
@@ -322,9 +321,8 @@ recipe render-string [
 recipe clear-line-delimited [
   local-scope
   screen:address <- next-ingredient
-  left:number <- next-ingredient
+  column:number <- next-ingredient
   right:number <- next-ingredient
-  column:number <- copy left
   {
     done?:boolean <- greater-than column, right
     break-if done?
@@ -334,6 +332,26 @@ recipe clear-line-delimited [
   }
 ]
 
+recipe clear-screen-from [
+  local-scope
+  screen:address <- next-ingredient
+  row:number <- next-ingredient
+  column:number <- next-ingredient
+  left:number <- next-ingredient
+  right:number <- next-ingredient
+  # if it's the real screen, use the optimized primitive
+  {
+    break-if screen
+    clear-display-from row, column, left, right
+    reply screen/same-as-ingredient:0
+  }
+  # if not, go the slower route
+  move-cursor screen, row, column
+  clear-line-delimited screen, column, right
+  clear-rest-of-screen screen, row, left, right
+  reply screen/same-as-ingredient:0
+]
+
 recipe clear-rest-of-screen [
   local-scope
   screen:address <- next-ingredient
@@ -598,8 +616,7 @@ recipe editor-event-loop [
     left:number <- get *editor, left:offset
     right:number <- get *editor, right:offset
     row <- add row, 1
-    move-cursor screen, row, left
-    clear-line-delimited screen, left, right
+    clear-screen-from screen, row, left, left, right
     loop
   }
 ]
@@ -4201,7 +4218,8 @@ recipe render-recipes [
   }
   # draw dotted line after recipes
   draw-horizontal screen, row, left, right, 9480/horizontal-dotted
-  clear-rest-of-screen screen, row, left, right
+  row <- add row, 1
+  clear-screen-from screen, row, left, left, right
   reply screen/same-as-ingredient:0
 ]