scenario clicking-on-a-sandbox-moves-it-to-editor [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new [
recipe foo [
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 [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊0 edit copy delete .
.] ┊foo .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 3, 55
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊foo .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊ .
.] ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .
. ┊ .
]
assume-console [
type [0]
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊0foo .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊ .
.] ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .
. ┊ .
]
]
scenario clicking-on-a-sandbox-moves-it-to-editor-2 [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new [
recipe foo [
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 [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊0 edit copy delete .
.] ┊foo .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊4 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 3, 68
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊foo .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊ .
.] ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .
. ┊ .
]
assume-console [
type [0]
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊0foo .
.recipe foo [ ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. reply 4 ┊ .
.] ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊ .
. ┊ .
]
]
after <global-touch> [
{
edit?:boolean <- should-attempt-edit? click-row, click-column, env
break-unless edit?
edit?, env <- try-edit-sandbox click-row, env
break-unless edit?
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 should-attempt-edit? click-row:number, click-column:number, env:address:programming-environment-data -> result:boolean [
local-scope
load-ingredients
click-sandbox-area?:boolean <- click-on-sandbox-area? click-row, click-column, env
reply-unless click-sandbox-area?, 0/false
first-sandbox:address:editor-data <- get *env, current-sandbox:offset
assert first-sandbox, [!!]
sandbox-left-margin:number <- get *first-sandbox, left:offset
sandbox-right-margin:number <- get *first-sandbox, right:offset
edit-button-left:number, edit-button-right:number, _ <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
edit-button-vertical-area?:boolean <- within-range? click-column, edit-button-left, edit-button-right
reply-unless edit-button-vertical-area?, 0/false
current-sandbox:address:editor-data <- get *env, current-sandbox:offset
result <- empty-editor? current-sandbox
]
def try-edit-sandbox click-row:number, env:address:programming-environment-data -> clicked-on-edit-button?:boolean, env:address:programming-environment-data [
local-scope
load-ingredients
sandbox:address:sandbox-data <- find-sandbox env, click-row
return-unless sandbox, 0/false
clicked-on-edit-button? <- copy 1/true
text:address:array:character <- get *sandbox, data:offset
current-sandbox:address:editor-data <- get *env, current-sandbox:offset
current-sandbox <- insert-text current-sandbox, text
env <- delete-sandbox env, sandbox
*env <- put *env, render-from:offset, -1
*env <- put *env, sandbox-in-focus?:offset, 1/true
]
scenario sandbox-with-print-can-be-edited [
trace-until 100/app
assume-screen 100/width, 20/height
1:address:array:character <- new []
2:address:array:character <- new [print-integer screen, 4]
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
assume-console [
press F4
]
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊print-integer screen, 4 .
. ┊screen: .
. ┊ .4 . .
. ┊ . . .
. ┊ . . .
. ┊ . . .
. ┊ . . .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 3, 65
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊print-integer screen, 4 .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
. ┊ .
]
]
scenario editing-sandbox-after-scrolling-resets-scroll [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new []
2:address:array:character <- new []
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
render-all screen, 3:address:programming-environment-data, render
assume-console [
press ctrl-n
type [add 2, 2]
press F4
type [add 1, 1]
press F4
press page-down
press page-down
]
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 edit copy delete .
. ┊add 2, 2 .
. ┊4 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
assume-console [
left-click 2, 55
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊add 2, 2 .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊add 1, 1 .
. ┊2 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
]
scenario editing-sandbox-updates-sandbox-count [
trace-until 100/app
assume-screen 100/width, 10/height
1:address:array:character <- new []
2:address:array:character <- new []
3:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character, 2:address:array:character
render-all screen, 3:address:programming-environment-data, render
assume-console [
press ctrl-n
type [add 2, 2]
press F4
type [add 1, 1]
press F4
]
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
screen-should-contain [
. run (F4) .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊add 1, 1 .
. ┊2 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊1 edit copy delete .
. ┊add 2, 2 .
. ┊4 .
]
assume-console [
left-click 3, 60
press F4
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊ .
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊0 edit copy delete .
. ┊add 1, 1 .
. ┊2 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊1 edit copy delete .
. ┊add 2, 2 .
. ┊4 .
]
assume-console [
press page-down
press page-down
press page-down
]
run [
event-loop screen:address:screen, console:address:console, 3:address:programming-environment-data
]
screen-should-contain [
. run (F4) .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
.┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┊1 edit copy delete .
. ┊add 2, 2 .
. ┊4 .
. ┊━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
. ┊ .
]
]