about summary refs log tree commit diff stats
path: root/edit/001-editor.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-04-16 15:02:42 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-04-16 15:05:31 -0700
commitace7ffb714ce5314c665f28945ee0f3f1664f9ca (patch)
tree191088837e3a6c6fa6a38aae59431efa88c86cb9 /edit/001-editor.mu
parentef73b04e744a69973208096a49d4ae52ddbb84d2 (diff)
downloadmu-ace7ffb714ce5314c665f28945ee0f3f1664f9ca.tar.gz
3824 - experiment: stop buffering in termbox
Now it's much more apparent why things are slow. You can see each repaint
happening. Already I fixed one performance bug -- in clear-rest-of-screen.

Since this subverts Mu's fake screen there may be bugs.

Another salubrious side effect: I've finally internalized that switching
to raw mode doesn't have to clear the screen. That was just an artifact
of how termbox abstracted operations. Now I can conceive of using termbox
to build a repl as well.

(I was inspired to poke into termbox internals by
http://viewsourcecode.org/snaptoken/kilo and
https://github.com/antirez/linenoise)
Diffstat (limited to 'edit/001-editor.mu')
-rw-r--r--edit/001-editor.mu8
1 files changed, 6 insertions, 2 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu
index 60042344..a6dde85b 100644
--- a/edit/001-editor.mu
+++ b/edit/001-editor.mu
@@ -6,10 +6,8 @@ def main text:text [
   local-scope
   load-ingredients
   open-console
-  hide-screen 0/screen
   e:&:editor <- new-editor text, 0/left, 5/right
   render 0/screen, e
-  show-screen 0/screen
   wait-for-event 0/console
   close-console
 ]
@@ -239,6 +237,12 @@ def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen
   local-scope
   load-ingredients
   row <- add row, 1
+  # if it's the real screen, use the optimized primitive
+  {
+    break-if screen
+    clear-display-from row, left, left, right
+    return
+  }
   screen <- move-cursor screen, row, left
   screen-height:num <- screen-height screen
   {