From ace7ffb714ce5314c665f28945ee0f3f1664f9ca Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 16 Apr 2017 15:02:42 -0700 Subject: 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) --- sandbox/001-editor.mu | 2 -- sandbox/004-programming-environment.mu | 17 ----------------- sandbox/005-sandbox.mu | 4 ---- sandbox/006-sandbox-copy.mu | 2 -- sandbox/007-sandbox-delete.mu | 2 -- sandbox/008-sandbox-edit.mu | 2 -- sandbox/009-sandbox-test.mu | 3 --- sandbox/010-sandbox-trace.mu | 3 --- 8 files changed, 35 deletions(-) (limited to 'sandbox') diff --git a/sandbox/001-editor.mu b/sandbox/001-editor.mu index 60042344..717e147c 100644 --- a/sandbox/001-editor.mu +++ b/sandbox/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 ] diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 79fa79c6..7f0b4a05 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -89,7 +89,6 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources: } # if it's not global and not a touch event, send to appropriate editor { - hide-screen screen render?:bool <- handle-keyboard-event screen, current-sandbox, e:event # refresh screen only if no more events # if there are more events to process, wait for them to clear up, then make sure you render-all afterward. @@ -117,7 +116,6 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources: } +finish-event screen <- update-cursor screen, current-sandbox, env - show-screen screen } loop } @@ -223,7 +221,6 @@ def render-all screen:&:screen, env:&:environment, {render-editor: (recipe (addr local-scope load-ingredients trace 10, [app], [render all] - hide-screen screen # top menu trace 11, [app], [render top menu] width:num <- screen-width screen @@ -239,8 +236,6 @@ def render-all screen:&:screen, env:&:environment, {render-editor: (recipe (addr # current-sandbox:&:editor <- get *env, current-sandbox:offset screen <- update-cursor screen, current-sandbox, env - # - show-screen screen ] # replaced in a later layer @@ -267,15 +262,3 @@ def update-cursor screen:&:screen, current-sandbox:&:editor, env:&:environment - cursor-column:num <- get *current-sandbox, cursor-column:offset screen <- move-cursor screen, cursor-row, cursor-column ] - -# ctrl-l - redraw screen (just in case it printed junk somehow) - -after [ - { - redraw-screen?:bool <- equal c, 12/ctrl-l - break-unless redraw-screen? - screen <- render-all screen, env:&:environment, render - sync-screen screen - loop +next-event - } -] diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu index badd0d46..91826802 100644 --- a/sandbox/005-sandbox.mu +++ b/sandbox/005-sandbox.mu @@ -793,9 +793,7 @@ after [ render-from <- add render-from, 1 *env <- put *env, render-from:offset, render-from } - hide-screen screen screen <- render-sandbox-side screen, env, render - show-screen screen jump +finish-event } ] @@ -822,9 +820,7 @@ after [ break-if at-beginning? render-from <- subtract render-from, 1 *env <- put *env, render-from:offset, render-from - hide-screen screen screen <- render-sandbox-side screen, env, render - show-screen screen jump +finish-event } ] diff --git a/sandbox/006-sandbox-copy.mu b/sandbox/006-sandbox-copy.mu index 995f4c7c..4835f02e 100644 --- a/sandbox/006-sandbox-copy.mu +++ b/sandbox/006-sandbox-copy.mu @@ -140,10 +140,8 @@ after [ break-unless copy? copy?, env <- try-copy-sandbox click-row, env break-unless copy? - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env - show-screen screen loop +next-event } ] diff --git a/sandbox/007-sandbox-delete.mu b/sandbox/007-sandbox-delete.mu index ddfbf692..107c861c 100644 --- a/sandbox/007-sandbox-delete.mu +++ b/sandbox/007-sandbox-delete.mu @@ -69,10 +69,8 @@ after [ break-unless delete? delete?, env <- try-delete-sandbox click-row, env break-unless delete? - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env - show-screen screen loop +next-event } ] diff --git a/sandbox/008-sandbox-edit.mu b/sandbox/008-sandbox-edit.mu index cb19ebc4..ec4fd578 100644 --- a/sandbox/008-sandbox-edit.mu +++ b/sandbox/008-sandbox-edit.mu @@ -111,10 +111,8 @@ after [ break-unless edit? edit?, env <- try-edit-sandbox click-row, env break-unless edit? - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env - show-screen screen loop +next-event } ] diff --git a/sandbox/009-sandbox-test.mu b/sandbox/009-sandbox-test.mu index 2ee45a1e..1c24bcb8 100644 --- a/sandbox/009-sandbox-test.mu +++ b/sandbox/009-sandbox-test.mu @@ -132,11 +132,8 @@ after [ # toggle its expected-response, and save session sandbox <- toggle-expected-response sandbox save-sandboxes env, resources - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env - # no change in cursor - show-screen screen loop +next-event } ] diff --git a/sandbox/010-sandbox-trace.mu b/sandbox/010-sandbox-trace.mu index 72f6fe03..27f2915a 100644 --- a/sandbox/010-sandbox-trace.mu +++ b/sandbox/010-sandbox-trace.mu @@ -190,11 +190,8 @@ after [ x:bool <- get *sandbox, display-trace?:offset x <- not x *sandbox <- put *sandbox, display-trace?:offset, x - hide-screen screen screen <- render-sandbox-side screen, env, render screen <- update-cursor screen, current-sandbox, env - # no change in cursor - show-screen screen loop +next-event } ] -- cgit 1.4.1-2-gfad0