scenario sandbox-click-on-code-toggles-app-trace [
local-scope
trace-until 100/app
assume-screen 100/width, 10/height
recipes:text <- new [
recipe foo [
stash [abc]
]]
env:&:environment <- new-programming-environment screen, recipes, [foo]
assume-console [
press F4
]
event-loop screen, console, env
screen-should-contain [
. run (F4) .
. ╎ .
.recipe foo [ ╎─────────────────────────────────────────────────.
. stash [abc] ╎0 edit copy delete .
.] ╎foo .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.
. ╎ .
]
assume-console [
left-click 4, 51
]
run [
event-loop screen, console, env
cursor:char <- copy 9251/␣
print screen, cursor
]
screen-should-contain [
. run (F4) .
.␣ ╎ .
.recipe foo [ ╎─────────────────────────────────────────────────.
. stash [abc] ╎0 edit copy delete .
.] ╎foo .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎abc .
]
screen-should-contain-in-color 245/grey, [
. .
. ╎ .
. ╎─────────────────────────────────────────────────.
. ╎ .
. ╎ .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎abc .
]
assume-console [
left-click 4, 55
]
run [
event-loop screen, console, env
print screen, cursor
]
screen-should-contain [
. run (F4) .
.␣ ╎ .
.recipe foo [ ╎─────────────────────────────────────────────────.
. stash [abc] ╎0 edit copy delete .
.] ╎foo .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.
. ╎ .
]
]
scenario sandbox-shows-app-trace-and-result [
local-scope
trace-until 100/app
assume-screen 100/width, 10/height
recipes:text <- new [
recipe foo [
stash [abc]
reply 4
]]
env:&:environment <- new-programming-environment screen, recipes, [foo]
assume-console [
press F4
]
event-loop screen, console, env
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, console, env
]
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 [
local-scope
trace-until 100/app
assume-screen 100/width, 10/height
env:&:environment <- new-programming-environment screen, [], [stash 123456789]
assume-console [
press F4
left-click 4, 51
]
event-loop screen, console, env
screen-should-contain [
. run (F4) .
. ╎ .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.
. ╎0 edit copy delete .
. ╎stash 123456789 .
. ╎123456789 .
]
assume-console [
left-click 5, 57
]
run [
event-loop screen, console, env
]
screen-should-contain [
. run (F4) .
. ╎ .
.╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╎─────────────────────────────────────────────────.
. ╎0 edit copy delete .
. ╎stash 123456789 .
. ╎123456789 .
]
]
container sandbox [
trace:text
display-trace?:bool
]
def! update-sandbox sandbox:&:sandbox, env:&:environment, idx:num -> sandbox:&:sandbox, env:&:environment [
local-scope
load-ingredients
data:text <- get *sandbox, data:offset
response:text, _, fake-screen:&:screen, trace:text <- run-sandboxed 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:num <- get *current-sandbox, left:offset
click-column:num <- get t, column:offset
on-sandbox-side?:bool <- greater-or-equal click-column, sandbox-left-margin
break-unless on-sandbox-side?
first-sandbox:&:sandbox <- get *env, sandbox:offset
break-unless first-sandbox
first-sandbox-begins:num <- get *first-sandbox, starting-row-on-screen:offset
click-row:num <- get t, row:offset
below-sandbox-editor?:bool <- greater-or-equal click-row, first-sandbox-begins
break-unless below-sandbox-editor?
sandbox:&:sandbox <- find-click-in-sandbox-code env, click-row
break-unless sandbox
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, recipes, current-sandbox, sandbox-in-focus?, env
show-screen screen
loop +next-event
}
]
def find-click-in-sandbox-code env:&:environment, click-row:num -> sandbox:&:sandbox [
local-scope
load-ingredients
sandbox <- get *env, sandbox:offset
start:num <- get *sandbox, starting-row-on-screen:offset
clicked-on-sandboxes?:bool <- greater-or-equal click-row, start
assert clicked-on-sandboxes?, [extract-sandbox called on click to sandbox editor]
{
next-sandbox:&:sandbox <- get *sandbox, next-sandbox:offset
break-unless next-sandbox
next-start:num <- get *next-sandbox, starting-row-on-screen:offset
found?:bool <- lesser-than click-row, next-start
break-if found?
sandbox <- copy next-sandbox
loop
}
code-ending-row:num <- get *sandbox, code-ending-row-on-screen:offset
click-above-response?:bool <- lesser-than click-row, code-ending-row
start:num <- get *sandbox, starting-row-on-screen:offset
click-below-menu?:bool <- greater-than click-row, start
click-on-sandbox-code?:bool <- 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?:bool <- get *sandbox, display-trace?:offset
break-unless display-trace?
sandbox-trace:text <- get *sandbox, trace:offset
break-unless sandbox-trace
row, screen <- render-text screen, sandbox-trace, left, right, 245/grey, row
}
<render-sandbox-trace-done>
]