diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2017-06-23 14:09:11 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2017-06-23 15:39:14 -0700 |
commit | b1e558cfe42029df630e1c2d9399d4b52c187801 (patch) | |
tree | 35fba14030c48c8e3a5e1792ffef9a84095cfe85 /edit | |
parent | 0bf322d6f04c28d4b38eb07f5ee9bd588187a058 (diff) | |
download | mu-b1e558cfe42029df630e1c2d9399d4b52c187801.tar.gz |
3941
Even though the bug of commit 3938 is now fixed, I'm still trying to track down why the failure looked different on the fake screen than on the real one. Snapshot as I try to track down the difference. One key lesson is that the approach of commit 3860 -- updating the cursor before rather than after printing each character -- turns out to be untenable. A sequence of `print` followed by `cursor-position` needs to behave the same as the real screen. But it's still not clear how the real screen. When you get to the end of a line the cursor position wraps after print to the left margin (column 0) on the next row. When you get to the bottom right the cursor position wraps to the *bottom left* margin. How the heck does it know to scroll on the next print, then? Is there some hidden state in the terminal?
Diffstat (limited to 'edit')
-rw-r--r-- | edit/001-editor.mu | 2 | ||||
-rw-r--r-- | edit/002-typing.mu | 9 | ||||
-rw-r--r-- | edit/004-programming-environment.mu | 2 | ||||
-rw-r--r-- | edit/005-sandbox.mu | 29 |
4 files changed, 29 insertions, 13 deletions
diff --git a/edit/001-editor.mu b/edit/001-editor.mu index 807cf442..f7b7fb89 100644 --- a/edit/001-editor.mu +++ b/edit/001-editor.mu @@ -207,6 +207,7 @@ def render screen:&:screen, editor:&:editor -> last-row:num, last-column:num, sc def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num -> screen:&:screen [ local-scope load-ingredients + stash [clear-screen-from] row column [between] left [and] right # if it's the real screen, use the optimized primitive { break-if screen @@ -217,6 +218,7 @@ def clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num screen <- move-cursor screen, row, column clear-line-until screen, right clear-rest-of-screen screen, row, left, right + screen <- move-cursor screen, row, column ] def clear-rest-of-screen screen:&:screen, row:num, left:num, right:num -> screen:&:screen [ diff --git a/edit/002-typing.mu b/edit/002-typing.mu index 3b29c322..05ace7c5 100644 --- a/edit/002-typing.mu +++ b/edit/002-typing.mu @@ -1116,8 +1116,11 @@ after <handle-special-key> [ def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:screen [ local-scope load-ingredients + a:num, b:num <- cursor-position screen + stash [draw-horizontal] row [--] a b height:num <- screen-height screen past-bottom?:bool <- greater-or-equal row, height + stash [ past-bottom?] past-bottom? return-if past-bottom? style:char, style-found?:bool <- next-ingredient { @@ -1135,12 +1138,18 @@ def draw-horizontal screen:&:screen, row:num, x:num, right:num -> screen:&:scree break-if bg-color-found? bg-color <- copy 0/black } + stash [aa] x screen <- move-cursor screen, row, x { continue?:bool <- lesser-or-equal x, right # right is inclusive, to match editor semantics break-unless continue? + a b <- cursor-position screen + stash [bb] x [--] a b print screen, style, color, bg-color + a b <- cursor-position screen + stash [cc] x [--] a b x <- add x, 1 loop } + stash [draw-horizontal done] ] diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu index 897f2923..bcd3b524 100644 --- a/edit/004-programming-environment.mu +++ b/edit/004-programming-environment.mu @@ -447,6 +447,7 @@ def render-recipes screen:&:screen, env:&:environment, render-editor:render-reci clear-screen-from screen, row, left, left, right # assert-no-scroll screen, old-top-idx + stash [render recipes done] ] # replaced in a later layer @@ -467,6 +468,7 @@ def render-sandbox-side screen:&:screen, env:&:environment, render-editor:render clear-screen-from screen, row, left, left, right # assert-no-scroll screen, old-top-idx + stash [render sandbox side0 done] ] def update-cursor screen:&:screen, recipes:&:editor, current-sandbox:&:editor, sandbox-in-focus?:bool, env:&:environment -> screen:&:screen [ diff --git a/edit/005-sandbox.mu b/edit/005-sandbox.mu index 827f6632..2b17ecc2 100644 --- a/edit/005-sandbox.mu +++ b/edit/005-sandbox.mu @@ -14,6 +14,8 @@ def! main [ env:&:environment <- new-programming-environment 0/filesystem, 0/screen env <- restore-sandboxes env, 0/filesystem render-all 0/screen, env, render + wait-for-some-interaction + $exit event-loop 0/screen, 0/console, env, 0/filesystem ] @@ -268,20 +270,25 @@ def! render-sandbox-side screen:&:screen, env:&:environment, render-editor:rende clear-rest-of-screen screen, row, left, right # assert-no-scroll screen, old-top-idx + stash [render sandbox side done] ] def render-sandboxes screen:&:screen, sandbox:&:sandbox, left:num, right:num, row:num, render-from:num, idx:num -> row:num, screen:&:screen, sandbox:&:sandbox [ local-scope load-ingredients return-unless sandbox + a:num b:num <- cursor-position screen + stash [render-sandboxes] idx [:] row [--] a b screen-height:num <- screen-height screen + at-bottom?:bool <- greater-or-equal row, screen-height + return-if at-bottom? hidden?:bool <- lesser-than idx, render-from { break-if hidden? # render sandbox menu row <- add row, 1 - at-bottom?:bool <- greater-or-equal row, screen-height - return-if at-bottom? +#? at-bottom?:bool <- greater-or-equal row, screen-height +#? return-if at-bottom? screen <- move-cursor screen, row, left screen <- render-sandbox-menu screen, idx, left, right # save menu row so we can detect clicks to it later @@ -345,30 +352,26 @@ def render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num scenario skip-rendering-sandbox-menu-past-bottom-row [ trace-until 100/app # trace too long - assume-screen 100/width, 7/height + assume-screen 100/width, 6/height # recipe editor is empty assume-resources [ + [lesson/0] <- [|add 2, 2|] + [lesson/1] <- [|add 1, 1|] ] # create two sandboxes such that the top one just barely fills the screen env:&:environment <- new-programming-environment resources, screen, [] - render-all screen, env, render - assume-console [ - left-click 1, 75 - type [add 1, 1] - press F4 - type [add 2, 2] - press F4 - ] + env <- restore-sandboxes env, resources + $clear-trace run [ - event-loop screen, console, env, resources + render-all screen, env, render ] + $dump-trace [app] screen-should-contain [ . run (F4) . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊─────────────────────────────────────────────────. . ┊0 edit copy to recipe delete . . ┊add 2, 2 . - . ┊4 . . ┊─────────────────────────────────────────────────. ] ] |