scenario sandbox-click-on-code-toggles-app-trace [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new [
recipe foo [
stash [abc]
]]
2:address:array:character <- new [foo]
assume-console [
press F4
]
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊ .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. stash [abc] ┊0 edit copy delete .
.] ┊foo .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 4, 51
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
4:character/cursor-icon <- copy 9251/␣
print screen:address:screen, 4:character/cursor-icon
]
screen-should-contain [
. run (F4) .
.␣ ┊ .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. stash [abc] ┊0 edit copy delete .
.] ┊foo .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc .
. ┊8 instructions run .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
screen-should-contain-in-color 245/grey, [
. .
. ┊ .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊abc .
. ┊8 instructions run .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 4, 55
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
print screen:address:screen, 4:character/cursor-icon
]
screen-should-contain [
. run (F4) .
.␣ ┊ .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. stash [abc] ┊0 edit copy delete .
.] ┊foo .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
]
scenario sandbox-shows-app-trace-and-result [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new [
recipe foo [
stash [abc]
reply 4
]]
2:address:array:character <- new [foo]
assume-console [
press F4
]
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊ .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. stash [abc] ┊0 edit copy delete .
. reply 4 ┊foo .
.] ┊4 .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 4, 51
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊ .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. stash [abc] ┊0 edit copy delete .
. reply 4 ┊foo .
.] ┊abc .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊8 instructions run .
. ┊4 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
]
scenario clicking-on-app-trace-does-nothing [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new []
2:address:array:character <- new [stash 123456789]
assume-console [
press F4
left-click 4, 51
]
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊stash 123456789 .
. ┊123456789 .
. ┊6 instructions run .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 5, 57
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊stash 123456789 .
. ┊123456789 .
. ┊6 instructions run .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
]
container sandbox-data [
trace:address:array:character
display-trace?:boolean
]
def! update-sandbox sandbox:address:sandbox-data, env:address:programming-environment-data, idx:number -> sandbox:address:sandbox-data, env:address:programming-environment-data [
local-scope
load-ingredients
data:address:array:character <- get *sandbox, data:offset
response:address:array:character, _, fake-screen:address:screen, trace:address:array:character <- run-interactive data
*sandbox <- put *sandbox, response:offset, response
*sandbox <- put *sandbox, screen:offset, fake-screen
*sandbox <- put *sandbox, trace:offset, trace
]
after <global-touch> [
{
sandbox-left-margin:number <- get *current-sandbox, left:offset
click-column:number <- get t, column:offset
on-sandbox-side?:boolean <- greater-or-equal click-column, sandbox-left-margin
break-unless on-sandbox-side?
first-sandbox:address:sandbox-data <- get *env, sandbox:offset
break-unless first-sandbox
first-sandbox-begins:number <- get *first-sandbox, starting-row-on-screen:offset
click-row:number <- get t, row:offset
below-sandbox-editor?:boolean <- greater-or-equal click-row, first-sandbox-begins
break-unless below-sandbox-editor?
sandbox:address:sandbox-data <- find-click-in-sandbox-code env, click-row
break-unless sandbox
x:boolean <- 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, recipes, current-sandbox, sandbox-in-focus?, env
show-screen screen
loop +next-event:label
}
]
def find-click-in-sandbox-code env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [
local-scope
load-ingredients
sandbox <- get *env, sandbox:offset
start:number <- get *sandbox, starting-row-on-screen:offset
clicked-on-sandboxes?:boolean <- greater-or-equal click-row, start
assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
{
next-sandbox:address:sandbox-data <- get *sandbox, next-sandbox:offset
break-unless next-sandbox
next-start:number <- get *next-sandbox, starting-row-on-screen:offset
found?:boolean <- lesser-than click-row, next-start
break-if found?
sandbox <- copy next-sandbox
loop
}
code-ending-row:number <- get *sandbox, code-ending-row-on-screen:offset
click-above-response?:boolean <- lesser-than click-row, code-ending-row
start:number <- get *sandbox, starting-row-on-screen:offset
click-below-menu?:boolean <- greater-than click-row, start
click-on-sandbox-code?:boolean <- and click-above-response?, click-below-menu?
{
break-if click-on-sandbox-code?
return 0/no-click-in-sandbox-output
}
return sandbox
]
after <render-sandbox-results> [
{
display-trace?:boolean <- get *sandbox, display-trace?:offset
break-unless display-trace?
sandbox-trace:address:array:character <- get *sandbox, trace:offset
break-unless sandbox-trace
row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row
}
<render-sandbox-trace-done>
]