diff options
-rw-r--r-- | edit.mu | 176 |
1 files changed, 167 insertions, 9 deletions
diff --git a/edit.mu b/edit.mu index 7d007e6e..08081bc6 100644 --- a/edit.mu +++ b/edit.mu @@ -591,10 +591,19 @@ recipe event-loop [ loop +next-event:label } } - # 'touch' event - send to both editors + # 'touch' event { t:address:touch-event <- maybe-convert e:event, touch:variant break-unless t:address:touch-event + # on a sandbox delete icon? process delete + { + was-delete?:boolean <- delete-sandbox t:address:touch-event/deref, env:address:programming-environment-data + break-unless was-delete?:boolean + screen:address <- render-sandbox-side screen:address, env:address:programming-environment-data, 1:literal/clear + update-cursor screen:address, recipes:address:editor-data, current-sandbox:address:editor-data, sandbox-in-focus?:address:boolean/deref + loop +next-event:label + } + # if not, send to both editors _ <- move-cursor-in-editor screen:address, recipes:address:editor-data, t:address:touch-event/deref sandbox-in-focus?:address:boolean/deref <- move-cursor-in-editor screen:address, current-sandbox:address:editor-data, t:address:touch-event/deref jump +continue:label @@ -1123,6 +1132,7 @@ recipe render-sandbox-side [ local-scope screen:address <- next-ingredient env:address:programming-environment-data <- next-ingredient + clear:boolean <- next-ingredient current-sandbox:address:editor-data <- get env:address:programming-environment-data/deref, current-sandbox:offset left:number <- get current-sandbox:address:editor-data/deref, left:offset right:number <- get current-sandbox:address:editor-data/deref, right:offset @@ -1135,6 +1145,16 @@ recipe render-sandbox-side [ row:number <- add row:number, 1:literal move-cursor screen:address, row:number, left:number clear-line-delimited screen:address, left:number, right:number + reply-unless clear:boolean, screen:address/same-as-ingredient:0 + screen-height:number <- screen-height screen:address + { + at-bottom-of-screen?:boolean <- greater-or-equal row:number, screen-height:number + break-if at-bottom-of-screen?:boolean + move-cursor screen:address, row:number, left:number + clear-line-delimited screen:address, left:number, right:number + row:number <- add row:number, 1:literal + loop + } reply screen:address/same-as-ingredient:0 ] @@ -1149,6 +1169,16 @@ recipe render-sandboxes [ screen-height:number <- screen-height screen:address at-bottom?:boolean <- greater-or-equal row:number screen-height:number reply-if at-bottom?:boolean, row:number/same-as-ingredient:4, screen:address/same-as-ingredient:0 +#? $print [rendering sandbox ], sandbox:address:sandbox-data, [ +#? ] #? 1 + # render sandbox menu + row:number <- add row:number, 1:literal + move-cursor screen:address, row:number, left:number + clear-line-delimited screen:address, left:number, right:number + print-character screen:address, 120:literal/x, 245:literal/grey + # save menu row so we can detect clicks to it later + starting-row:address:number <- get-address sandbox:address:sandbox-data/deref, starting-row-on-screen:offset + starting-row:address:number/deref <- copy row:number # render sandbox contents sandbox-data:address:array:character <- get sandbox:address:sandbox-data/deref, data:offset row:number, screen:address <- render-string screen:address, sandbox-data:address:array:character, left:number, right:number, 7:literal/white, row:number @@ -2590,13 +2620,14 @@ container sandbox-data [ data:address:array:character response:address:array:character warnings:address:array:character - screen:address:screen + starting-row-on-screen:number # to track clicks on delete + screen:address:screen # prints in the sandbox go here next-sandbox:address:sandbox-data ] scenario run-and-show-results [ $close-trace # trace too long for github - assume-screen 100:literal/width, 12:literal/height + assume-screen 100:literal/width, 15:literal/height # recipe editor is empty 1:address:array:character <- new [] # sandbox editor contains an instruction without storing outputs @@ -2614,6 +2645,7 @@ scenario run-and-show-results [ . run (F10) . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊divide-with-remainder 11:literal, 3:literal . . ┊3 . . ┊2 . @@ -2624,6 +2656,7 @@ scenario run-and-show-results [ . . . . . . + . . . divide-with-remainder 11:literal, 3:literal . . . . . @@ -2634,6 +2667,7 @@ scenario run-and-show-results [ . . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊ . . ┊3 . . ┊2 . @@ -2654,9 +2688,11 @@ scenario run-and-show-results [ . run (F10) . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊add 2:literal, 2:literal . . ┊4 . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊divide-with-remainder 11:literal, 3:literal . . ┊3 . . ┊2 . @@ -2707,6 +2743,55 @@ recipe run-sandboxes [ } ] +# was-deleted?:boolean <- delete-sandbox t:touch-event, env:address:programming-environment-data +recipe delete-sandbox [ + local-scope + t:touch-event <- next-ingredient + env:address:programming-environment-data <- next-ingredient + click-column:number <- get t:touch-event, column:offset + current-sandbox:address:editor-data <- get env:address:programming-environment-data/deref, current-sandbox:offset + right:number <- get current-sandbox:address:editor-data/deref, right:offset +#? $print [comparing column ], click-column:number, [ vs ], right:number, [ +#? ] #? 1 + at-right?:boolean <- equal click-column:number, right:number + reply-unless at-right?:boolean, 0:literal/false +#? $print [trying to delete +#? ] #? 1 + click-row:number <- get t:touch-event, row:offset + prev:address:address:sandbox-data <- get-address env:address:programming-environment-data/deref, sandbox:offset +#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, [ +#? ] #? 1 + curr:address:sandbox-data <- get env:address:programming-environment-data/deref, sandbox:offset + { +#? $print [next sandbox +#? ] #? 1 + break-unless curr:address:sandbox-data + # more sandboxes to check + { +#? $print [checking +#? ] #? 1 + target-row:number <- get curr:address:sandbox-data/deref, starting-row-on-screen:offset +#? $print [comparing row ], target-row:number, [ vs ], click-row:number, [ +#? ] #? 1 + delete-curr?:boolean <- equal target-row:number, click-row:number + break-unless delete-curr?:boolean +#? $print [found! +#? ] #? 1 + # delete this sandbox, rerender and stop + prev:address:address:sandbox-data/deref <- get curr:address:sandbox-data/deref, next-sandbox:offset +#? $print [setting prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, [ +#? ] #? 1 + reply 1:literal/true + } + prev:address:address:sandbox-data <- get-address curr:address:sandbox-data/deref, next-sandbox:offset +#? $print [prev: ], prev:address:address:sandbox-data, [ -> ], prev:address:address:sandbox-data/deref, [ +#? ] #? 1 + curr:address:sandbox-data <- get curr:address:sandbox-data/deref, next-sandbox:offset + loop + } + reply 0:literal/false +] + scenario run-updates-results [ $close-trace # trace too long for github assume-screen 100:literal/width, 12:literal/height @@ -2730,9 +2815,10 @@ z:number <- add 2:literal, 2:literal . run (F10) . . ┊ . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - .z:number <- add 2:literal, 2:literal ┊foo . - .] ┊4 . - .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .z:number <- add 2:literal, 2:literal ┊ x. + .] ┊foo . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ . ] # make a change (incrementing one of the args to 'add'), then rerun @@ -2751,9 +2837,10 @@ z:number <- add 2:literal, 2:literal . run (F10) . . ┊ . .recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. - .z:number <- add 2:literal, 3:literal ┊foo . - .] ┊5 . - .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + .z:number <- add 2:literal, 3:literal ┊ x. + .] ┊foo . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊5 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. . ┊ . ] ] @@ -2778,6 +2865,7 @@ scenario run-instruction-and-print-warnings [ . run (F10) . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊get 1234:number, foo:offset . . ┊unknown element foo in container number . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -2787,6 +2875,7 @@ scenario run-instruction-and-print-warnings [ . . . . . . + . . . get 1234:number, foo:offset . . . . . @@ -2797,6 +2886,7 @@ scenario run-instruction-and-print-warnings [ . . . . . . + . . . unknown element foo in container number . . . ] @@ -2804,6 +2894,7 @@ scenario run-instruction-and-print-warnings [ . . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊ . . ┊ . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -2832,6 +2923,7 @@ scenario run-instruction-and-print-warnings-only-once [ . run (F10) . . ┊ . .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. . ┊get 1234:number, foo:offset . . ┊unknown element foo in container number . . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. @@ -2839,6 +2931,72 @@ scenario run-instruction-and-print-warnings-only-once [ ] ] +scenario deleting-sandboxes [ + $close-trace # trace too long for github + assume-screen 100:literal/width, 15:literal/height + 1:address:array:character <- new [] + 2:address:array:character <- new [] + 3:address:programming-environment-data <- new-programming-environment screen:address, 1:address:array:character, 2:address:array:character + # run a few commands + assume-console [ + left-click 1, 80 + type [divide-with-remainder 11:literal, 3:literal] + press 65526 # F10 + type [add 2:literal, 2:literal] + press 65526 # F10 + ] + run [ + event-loop screen:address, console:address, 3:address:programming-environment-data + ] + screen-should-contain [ + . run (F10) . + . ┊ . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. + . ┊add 2:literal, 2:literal . + . ┊4 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. + . ┊divide-with-remainder 11:literal, 3:literal . + . ┊3 . + . ┊2 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + ] + # delete second sandbox + assume-console [ + left-click 7, 99 + ] + run [ + event-loop screen:address, console:address, 3:address:programming-environment-data + ] + screen-should-contain [ + . run (F10) . + . ┊ . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ x. + . ┊add 2:literal, 2:literal . + . ┊4 . + . ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + . ┊ . + ] + # delete first sandbox + assume-console [ + left-click 3, 99 + ] + run [ + event-loop screen:address, console:address, 3:address:programming-environment-data + ] + screen-should-contain [ + . run (F10) . + . ┊ . + .┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━. + . ┊ . + . ┊ . + ] +] + scenario run-instruction-manages-screen-per-sandbox [ $close-trace # trace too long for github #? 1 assume-screen 100:literal/width, 20:literal/height |