about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cannot_write_tests_for6
-rw-r--r--edit/004-programming-environment.mu17
-rw-r--r--sandbox/004-programming-environment.mu15
3 files changed, 32 insertions, 6 deletions
diff --git a/cannot_write_tests_for b/cannot_write_tests_for
index 0c0685c9..1bd9ce3c 100644
--- a/cannot_write_tests_for
+++ b/cannot_write_tests_for
@@ -4,6 +4,12 @@
 3. more touch event types
 4. sandbox isolation
 5. errors in reading/writing files (missing directory, others?)
+6. has-more-events?
 
 termbox issues are implementation-specific and not worth testing:
   latency in interpreting low-level escape characters
+
+calls to update-cursor are currently duplicated:
+  render-all calls update-cursor to simplify testing
+  event-loop needs to call update-cursor explicitly to backstop branches doing their own minimal rendering
+  solution: update-cursor after minimal rendering
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index 5a1e84c7..ba626cb4 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -42,6 +42,10 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources:
   recipes:&:editor <- get *env, recipes:offset
   current-sandbox:&:editor <- get *env, current-sandbox:offset
   sandbox-in-focus?:bool <- get *env, sandbox-in-focus?:offset
+  # if we fall behind we'll stop updating the screen, but then we have to
+  # render the entire screen when we catch up.
+  # todo: test this
+  render-all-on-no-more-events?:bool <- copy 0/false
   {
     # looping over each (keyboard or touch) event as it occurs
     +next-event
@@ -96,14 +100,19 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources:
       {
         break-if sandbox-in-focus?
         render?:bool <- handle-keyboard-event screen, recipes, e:event
-        break-unless render?
-        screen <- render-all screen, env, render
       }
       {
         break-unless sandbox-in-focus?
         render?:bool <- handle-keyboard-event screen, current-sandbox, e:event
-        break-unless render?
-        screen <- render-sandbox-side screen, env, render
+      }
+      # try to batch up rendering if there are more events queued up
+      # to compensate for this additional code complexity, we always render both sides when we do render
+      render-all-on-no-more-events? <- or render-all-on-no-more-events?, render?
+      more-events?:bool <- has-more-events? console
+      {
+        break-if more-events?
+        break-unless render-all-on-no-more-events?
+        screen <- render-all screen, env, render
       }
       screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env
     }
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index a29324b0..2dca181d 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -28,6 +28,10 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources:
   local-scope
   load-ingredients
   current-sandbox:&:editor <- get *env, current-sandbox:offset
+  # if we fall behind we'll stop updating the screen, but then we have to
+  # render the entire screen when we catch up.
+  # todo: test this
+  render-all-on-no-more-events?:bool <- copy 0/false
   {
     # looping over each (keyboard or touch) event as it occurs
     +next-event
@@ -73,11 +77,18 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources:
       screen <- render-all screen, env, render-without-moving-cursor
       loop +next-event
     }
-    # if it's not global and not a touch event, send to appropriate editor
+    # not global and not a touch event
     {
       render?:bool <- handle-keyboard-event screen, current-sandbox, e:event
       break-unless render?
-      screen <- render-all screen, env, render
+      # try to batch up rendering if there are more events queued up
+      render-all-on-no-more-events? <- or render-all-on-no-more-events?, render?
+      more-events?:bool <- has-more-events? console
+      {
+        break-if more-events?
+        break-unless render-all-on-no-more-events?
+        screen <- render-all screen, env, render
+      }
     }
     loop
   }