diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-05-06 14:54:26 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-05-06 14:54:26 -0700 |
commit | dc0e767cf5130461a6aa58774d1016ec3934396b (patch) | |
tree | cd4522ac4fb08a2679f663b813dd2e62f7332fb4 | |
parent | 71d4ce1800b5df555aa7786b30f4d5d7fcd30352 (diff) | |
download | mu-dc0e767cf5130461a6aa58774d1016ec3934396b.tar.gz |
3844
Once I start optimizing most events to not repaint everything there's no need to be smart about queued-up events.
-rw-r--r-- | 084console.mu | 3 | ||||
-rw-r--r-- | cannot_write_tests_for | 7 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 63 | ||||
-rw-r--r-- | sandbox/004-programming-environment.mu | 47 |
4 files changed, 13 insertions, 107 deletions
diff --git a/084console.mu b/084console.mu index d566bc27..9f55ca91 100644 --- a/084console.mu +++ b/084console.mu @@ -96,10 +96,9 @@ def wait-for-event console:&:console -> console:&:console [ } ] -# use this helper to skip rendering if there's lots of other events queued up def has-more-events? console:&:console -> result:bool [ local-scope load-ingredients - return-if console, 0/false # fake consoles should be plenty fast; never skip + return-if console, 0/false # fake events are processed as soon as they arrive result <- interactions-left? ] diff --git a/cannot_write_tests_for b/cannot_write_tests_for index 5e10fa49..0c0685c9 100644 --- a/cannot_write_tests_for +++ b/cannot_write_tests_for @@ -1,10 +1,9 @@ 0. main's ingredients 1. assertion failures or errors inside scenarios 2. screen background color -3. has-more-events? -4. more touch event types -5. sandbox isolation -6. errors in reading/writing files (missing directory, others?) +3. more touch event types +4. sandbox isolation +5. errors in reading/writing files (missing directory, others?) termbox issues are implementation-specific and not worth testing: latency in interpreting low-level escape characters diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 78264212..435495f4 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -42,10 +42,6 @@ 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 @@ -100,65 +96,16 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources: { break-if sandbox-in-focus? render?:bool <- handle-keyboard-event screen, recipes, 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. - more-events?:bool <- has-more-events? console - { - break-unless more-events? - render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - loop +next-event - } - { - break-if more-events? - { - break-unless render-all-on-no-more-events? - # no more events, and we have to force render - screen <- render-all screen, env, render - render-all-on-no-more-events? <- copy 0/false - loop +next-event - } - # no more events, no force render - { - break-unless render? - screen <- render-recipes screen, env, render - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - loop +next-event - } - } - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + break-unless render? + screen <- render-all screen, env, render } { break-unless sandbox-in-focus? 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. - more-events?:bool <- has-more-events? console - { - break-unless more-events? - render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - loop +next-event - } - { - break-if more-events? - { - break-unless render-all-on-no-more-events? - # no more events, and we have to force render - screen <- render-all screen, env, render - render-all-on-no-more-events? <- copy 0/false - loop +next-event - } - # no more events, no force render - { - break-unless render? - screen <- render-sandbox-side screen, env, render - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - loop +next-event - } - screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env - } + break-unless render? + screen <- render-sandbox-side screen, env, render } + screen <- update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env } loop } diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu index 796bee36..1ebb696d 100644 --- a/sandbox/004-programming-environment.mu +++ b/sandbox/004-programming-environment.mu @@ -28,10 +28,6 @@ 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,50 +69,15 @@ def event-loop screen:&:screen, console:&:console, env:&:environment, resources: { r:resize-event, is-resize?:bool <- maybe-convert e:event, resize:variant break-unless is-resize? - # if more events, we're still resizing; wait until we stop - more-events?:bool <- has-more-events? console - { - break-unless more-events? - render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event - } - { - break-if more-events? - env, screen <- resize screen, env - screen <- render-all screen, env, render-without-moving-cursor - render-all-on-no-more-events? <- copy 0/false # full render done - } + env, screen <- resize screen, env + 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 { 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. - more-events?:bool <- has-more-events? console - { - break-unless more-events? - render-all-on-no-more-events? <- copy 1/true # no rendering now, full rendering on some future event - screen <- update-cursor screen, current-sandbox, env - loop +next-event - } - { - break-if more-events? - { - break-unless render-all-on-no-more-events? - # no more events, and we have to force render - screen <- render-all screen, env, render - render-all-on-no-more-events? <- copy 0/false - loop +next-event - } - # no more events, no force render - { - break-unless render? - screen <- render-sandbox-side screen, env, render - screen <- update-cursor screen, current-sandbox, env - loop +next-event - } - screen <- update-cursor screen, current-sandbox, env - } + break-unless render? + screen <- render-all screen, env, render } loop } |