about summary refs log tree commit diff stats
path: root/edit.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-16 22:39:25 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-16 22:39:25 -0700
commitbf31512cd5ee4e7b1f3ce95427c35fe6acb4d4fa (patch)
tree85e2bef9d55519cdd784e9a42df5f7277ceb8523 /edit.mu
parentdf2c1409830d7fc5598f54fea0d728380851aa1c (diff)
downloadmu-bf31512cd5ee4e7b1f3ce95427c35fe6acb4d4fa.tar.gz
2025 - back to speeding up render
First step: drop the existing optimization of not redrawing after every
character. Gives the editor a jumpy feel. I'm also hoisting the render
into handle-keyboard event as a first step to duplicating it everywhere.

One test temporarily failing: we're gonna sometimes forget to draw the
line below editors.
Diffstat (limited to 'edit.mu')
-rw-r--r--edit.mu62
1 files changed, 31 insertions, 31 deletions
diff --git a/edit.mu b/edit.mu
index 935b2c62..76de7ea6 100644
--- a/edit.mu
+++ b/edit.mu
@@ -600,9 +600,8 @@ recipe editor-event-loop [
     # keyboard events
     {
       break-if t
-      handle-keyboard-event screen, console, editor, e
+      handle-keyboard-event screen, editor, e
     }
-    render screen, editor
     loop
   }
 ]
@@ -610,7 +609,6 @@ recipe editor-event-loop [
 recipe handle-keyboard-event [
   local-scope
   screen:address <- next-ingredient
-  console:address <- next-ingredient
   editor:address:editor-data <- next-ingredient
   e:event <- next-ingredient
   reply-unless editor
@@ -626,10 +624,10 @@ recipe handle-keyboard-event [
     regular-character?:boolean <- greater-or-equal *c, 32/space
     newline?:boolean <- equal *c, 10/newline
     regular-character? <- or regular-character?, newline?
-    reply-unless regular-character?
+    jump-unless regular-character?, +update-screen:label
     # otherwise type it in
     insert-at-cursor editor, *c, screen
-    reply
+    jump +update-screen:label
   }
   # special key to modify the text or move the cursor
   k:address:number <- maybe-convert e:event, keycode:variant
@@ -641,6 +639,9 @@ recipe handle-keyboard-event [
   right:number <- get *editor, right:offset
   # handlers for each special key will go here
   +handle-special-key
+  #
+  +update-screen
+  render screen, editor
 ]
 
 # process click, return if it was on current editor
@@ -1334,7 +1335,7 @@ after +handle-special-key [
     break-unless paste-start?
     indent:address:boolean <- get-address *editor, indent:offset
     *indent <- copy 0/false
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -1344,7 +1345,7 @@ after +handle-special-key [
     break-unless paste-end?
     indent:address:boolean <- get-address *editor, indent:offset
     *indent <- copy 1/true
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -1381,7 +1382,7 @@ after +handle-special-character [
     break-unless tab?
     insert-at-cursor editor, 32/space, screen
     insert-at-cursor editor, 32/space, screen
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -1418,7 +1419,7 @@ after +handle-special-character [
     backspace?:boolean <- equal *c, 8/backspace
     break-unless backspace?
     delete-before-cursor editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -1567,7 +1568,7 @@ after +handle-special-key [
     break-unless delete?
     curr:address:duplex-list <- get **before-cursor, next:offset
     _ <- remove-duplex curr
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -1608,10 +1609,10 @@ after +handle-special-key [
       *cursor-row <- add *cursor-row, 1
       *cursor-column <- copy left
       below-screen?:boolean <- greater-or-equal *cursor-row, screen-height  # must be equal
-      reply-unless below-screen?
+      jump-unless below-screen?, +update-screen:label
       +scroll-down
       *cursor-row <- subtract *cursor-row, 1  # bring back into screen range
-      reply
+      jump +update-screen:label
     }
     # if the line wraps, move cursor to start of next row
     {
@@ -1628,10 +1629,10 @@ after +handle-special-key [
       *cursor-row <- add *cursor-row, 1
       *cursor-column <- copy left
       below-screen?:boolean <- greater-or-equal *cursor-row, screen-height  # must be equal
-      reply-unless below-screen?
+      jump-unless below-screen?, +update-screen:label
       +scroll-down
       *cursor-row <- subtract *cursor-row, 1  # bring back into screen range
-      reply
+      jump +update-screen:label
     }
     # otherwise move cursor one character right
     *cursor-column <- add *cursor-column, 1
@@ -1819,6 +1820,7 @@ after +handle-special-key [
     prev:address:duplex-list <- prev-duplex *before-cursor
     break-unless prev
     editor <- move-cursor-coordinates-left editor
+    jump +update-screen:label
   }
 ]
 
@@ -1984,6 +1986,7 @@ after +handle-special-key [
       +scroll-up
     }
     # that's it; render will adjust cursor-column as necessary
+    jump +update-screen:label
   }
 ]
 
@@ -2047,6 +2050,7 @@ after +handle-special-key [
       +scroll-down
     }
     # that's it; render will adjust cursor-column as necessary
+    jump +update-screen:label
   }
 ]
 
@@ -2101,7 +2105,7 @@ after +handle-special-character [
     ctrl-a?:boolean <- equal *c, 1/ctrl-a
     break-unless ctrl-a?
     move-to-start-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -2110,7 +2114,7 @@ after +handle-special-key [
     home?:boolean <- equal *k, 65521/home
     break-unless home?
     move-to-start-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -2255,7 +2259,7 @@ after +handle-special-character [
     ctrl-e?:boolean <- equal *c, 5/ctrl-e
     break-unless ctrl-e?
     move-to-end-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -2264,7 +2268,7 @@ after +handle-special-key [
     end?:boolean <- equal *k, 65520/end
     break-unless end?
     move-to-end-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -2387,7 +2391,7 @@ after +handle-special-character [
     ctrl-u?:boolean <- equal *c, 21/ctrl-u
     break-unless ctrl-u?
     delete-to-start-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -2527,7 +2531,7 @@ after +handle-special-character [
     ctrl-k?:boolean <- equal *c, 11/ctrl-k
     break-unless ctrl-k?
     delete-to-end-of-line editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -3406,7 +3410,7 @@ after +handle-special-character [
     ctrl-f?:boolean <- equal *c, 6/ctrl-f
     break-unless ctrl-f?
     page-down editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -3415,7 +3419,7 @@ after +handle-special-key [
     page-down?:boolean <- equal *k, 65518/page-down
     break-unless page-down?
     page-down editor
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -3584,7 +3588,7 @@ after +handle-special-character [
     ctrl-b?:boolean <- equal *c, 2/ctrl-f
     break-unless ctrl-b?
     editor <- page-up editor, screen-height
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -3593,7 +3597,7 @@ after +handle-special-key [
     page-up?:boolean <- equal *k, 65519/page-up
     break-unless page-up?
     editor <- page-up editor, screen-height
-    reply
+    jump +update-screen:label
   }
 ]
 
@@ -4003,17 +4007,12 @@ recipe event-loop [
     {
       {
         break-if *sandbox-in-focus?
-        handle-keyboard-event screen, console, recipes, e:event
+        handle-keyboard-event screen, recipes, e:event
       }
       {
         break-unless *sandbox-in-focus?
-        handle-keyboard-event screen, console, current-sandbox, e:event
+        handle-keyboard-event screen, current-sandbox, e:event
       }
-      # optimization: refresh screen only if no more events
-      # todo: test this
-      more-events?:boolean <- has-more-events? console
-      break-if more-events?
-      render-minimal screen, env
     }
     loop
   }
@@ -4084,6 +4083,7 @@ scenario edit-multiple-editors [
   1:address:array:character <- new [abc]
   2:address:array:character <- new [def]
   3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character
+  render-all screen, 3:address:programming-environment-data
   # type one letter in each of them
   assume-console [
     left-click 1, 1