2015-09-12 20:49:50 +00:00
|
|
|
## deleting sandboxes
|
|
|
|
|
|
|
|
scenario deleting-sandboxes [
|
2015-10-07 06:38:28 +00:00
|
|
|
trace-until 100/app # trace too long
|
2015-09-12 20:49:50 +00:00
|
|
|
assume-screen 50/width, 15/height
|
2016-04-24 18:54:30 +00:00
|
|
|
1:address:array:character <- new []
|
|
|
|
2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character
|
2015-09-12 20:49:50 +00:00
|
|
|
# run a few commands
|
|
|
|
assume-console [
|
|
|
|
type [divide-with-remainder 11, 3]
|
|
|
|
press F4
|
|
|
|
type [add 2, 2]
|
|
|
|
press F4
|
|
|
|
]
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2015-09-12 20:49:50 +00:00
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
2015-09-12 20:49:50 +00:00
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
2016-05-20 04:35:34 +00:00
|
|
|
.1 edit copy delete .
|
2015-09-12 20:49:50 +00:00
|
|
|
.divide-with-remainder 11, 3 .
|
|
|
|
.3 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
|
|
|
]
|
2016-05-20 04:35:34 +00:00
|
|
|
# delete second sandbox by clicking on left edge of 'delete' button
|
2015-09-12 20:49:50 +00:00
|
|
|
assume-console [
|
2016-05-20 04:35:34 +00:00
|
|
|
left-click 7, 34
|
2015-09-12 20:49:50 +00:00
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2015-09-12 20:49:50 +00:00
|
|
|
]
|
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
2015-09-12 20:49:50 +00:00
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
|
|
|
]
|
2016-05-20 04:35:34 +00:00
|
|
|
# delete first sandbox by clicking at right edge of 'delete' button
|
2015-09-12 20:49:50 +00:00
|
|
|
assume-console [
|
|
|
|
left-click 3, 49
|
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2015-09-12 20:49:50 +00:00
|
|
|
]
|
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
after <global-touch> [
|
2016-05-20 04:35:34 +00:00
|
|
|
# support 'delete' button
|
2015-09-12 20:49:50 +00:00
|
|
|
{
|
2016-05-20 04:35:34 +00:00
|
|
|
delete?:boolean <- should-attempt-delete? click-row, click-column, env
|
|
|
|
break-unless delete?
|
|
|
|
delete?, env <- try-delete-sandbox click-row, env
|
|
|
|
break-unless delete?
|
2015-09-12 20:49:50 +00:00
|
|
|
hide-screen screen
|
|
|
|
screen <- render-sandbox-side screen, env
|
2016-01-23 03:11:59 +00:00
|
|
|
screen <- update-cursor screen, current-sandbox, env
|
2015-09-12 20:49:50 +00:00
|
|
|
show-screen screen
|
|
|
|
loop +next-event:label
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2016-05-20 04:35:34 +00:00
|
|
|
# some preconditions for attempting to delete a sandbox
|
|
|
|
def should-attempt-delete? click-row:number, click-column:number, env:address:programming-environment-data -> result:boolean [
|
|
|
|
local-scope
|
|
|
|
load-ingredients
|
|
|
|
# are we below the sandbox editor?
|
|
|
|
click-sandbox-area?:boolean <- click-on-sandbox-area? click-row, env
|
|
|
|
reply-unless click-sandbox-area?, 0/false
|
|
|
|
# narrower, is the click in the columns spanning the 'copy' button?
|
|
|
|
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
|
|
|
|
_, _, _, _, delete-button-left:number <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
|
|
|
|
result <- within-range? click-column, delete-button-left, sandbox-right-margin
|
|
|
|
]
|
|
|
|
|
|
|
|
def try-delete-sandbox click-row:number, env:address:programming-environment-data -> clicked-on-delete-button?:boolean, env:address:programming-environment-data [
|
|
|
|
local-scope
|
|
|
|
load-ingredients
|
|
|
|
# identify the sandbox to delete, if the click was actually on the 'delete' button
|
|
|
|
sandbox:address:sandbox-data <- find-sandbox env, click-row
|
|
|
|
return-unless sandbox, 0/false
|
|
|
|
clicked-on-delete-button? <- copy 1/true
|
|
|
|
env <- delete-sandbox env, sandbox
|
|
|
|
]
|
|
|
|
|
|
|
|
def delete-sandbox env:address:programming-environment-data, sandbox:address:sandbox-data -> env:address:programming-environment-data [
|
2015-09-12 20:49:50 +00:00
|
|
|
local-scope
|
2015-11-13 06:31:49 +00:00
|
|
|
load-ingredients
|
2016-05-20 04:35:34 +00:00
|
|
|
curr-sandbox:address:sandbox-data <- get *env, sandbox:offset
|
|
|
|
first-sandbox?:boolean <- equal curr-sandbox, sandbox
|
2016-04-23 05:53:39 +00:00
|
|
|
{
|
2016-05-20 04:35:34 +00:00
|
|
|
# first sandbox? pop
|
|
|
|
break-unless first-sandbox?
|
|
|
|
next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset
|
|
|
|
*env <- put *env, sandbox:offset, next-sandbox
|
2016-04-23 05:53:39 +00:00
|
|
|
}
|
2015-09-12 20:49:50 +00:00
|
|
|
{
|
2016-05-20 04:35:34 +00:00
|
|
|
# not first sandbox?
|
|
|
|
break-if first-sandbox?
|
|
|
|
prev-sandbox:address:sandbox-data <- copy curr-sandbox
|
|
|
|
curr-sandbox <- get *curr-sandbox, next-sandbox:offset
|
2015-09-12 20:49:50 +00:00
|
|
|
{
|
2016-05-20 04:35:34 +00:00
|
|
|
assert curr-sandbox, [sandbox not found! something is wrong.]
|
|
|
|
found?:boolean <- equal curr-sandbox, sandbox
|
|
|
|
break-if found?
|
|
|
|
prev-sandbox <- copy curr-sandbox
|
|
|
|
curr-sandbox <- get *curr-sandbox, next-sandbox:offset
|
|
|
|
loop
|
2015-09-12 20:49:50 +00:00
|
|
|
}
|
2016-05-20 04:35:34 +00:00
|
|
|
# snip sandbox out of its list
|
|
|
|
next-sandbox:address:sandbox-data <- get *curr-sandbox, next-sandbox:offset
|
|
|
|
*prev-sandbox <- put *prev-sandbox, next-sandbox:offset, next-sandbox
|
2015-09-12 20:49:50 +00:00
|
|
|
}
|
2016-04-23 05:53:39 +00:00
|
|
|
# update sandbox count
|
|
|
|
sandbox-count:number <- get *env, number-of-sandboxes:offset
|
|
|
|
sandbox-count <- subtract sandbox-count, 1
|
|
|
|
*env <- put *env, number-of-sandboxes:offset, sandbox-count
|
2016-05-20 04:35:34 +00:00
|
|
|
# reset scroll if deleted sandbox was last
|
2016-04-23 05:53:39 +00:00
|
|
|
{
|
2016-05-20 04:35:34 +00:00
|
|
|
break-if next-sandbox
|
2016-04-23 05:53:39 +00:00
|
|
|
render-from:number <- get *env, render-from:offset
|
|
|
|
reset-scroll?:boolean <- equal render-from, sandbox-count
|
|
|
|
break-unless reset-scroll?
|
|
|
|
*env <- put *env, render-from:offset, -1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2016-01-23 21:32:00 +00:00
|
|
|
scenario deleting-sandbox-after-scroll [
|
|
|
|
trace-until 100/app # trace too long
|
2016-05-20 04:35:34 +00:00
|
|
|
assume-screen 50/width, 10/height
|
2016-01-23 21:32:00 +00:00
|
|
|
# initialize environment
|
2016-04-24 18:54:30 +00:00
|
|
|
1:address:array:character <- new []
|
|
|
|
2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character
|
|
|
|
render-all screen, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
# create 2 sandboxes and scroll to second
|
|
|
|
assume-console [
|
|
|
|
press ctrl-n
|
|
|
|
type [add 2, 2]
|
|
|
|
press F4
|
|
|
|
type [add 1, 1]
|
|
|
|
press F4
|
2016-05-12 01:00:11 +00:00
|
|
|
press page-down
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# delete the second sandbox
|
|
|
|
assume-console [
|
2016-05-20 04:35:34 +00:00
|
|
|
left-click 6, 34
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# second sandbox shows in editor; scroll resets to display first sandbox
|
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-top-sandbox-after-scroll [
|
|
|
|
trace-until 100/app # trace too long
|
2016-05-20 04:35:34 +00:00
|
|
|
assume-screen 50/width, 10/height
|
2016-01-23 21:32:00 +00:00
|
|
|
# initialize environment
|
2016-04-24 18:54:30 +00:00
|
|
|
1:address:array:character <- new []
|
|
|
|
2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character
|
|
|
|
render-all screen, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
# create 2 sandboxes and scroll to second
|
|
|
|
assume-console [
|
|
|
|
press ctrl-n
|
|
|
|
type [add 2, 2]
|
|
|
|
press F4
|
|
|
|
type [add 1, 1]
|
|
|
|
press F4
|
2016-05-12 01:00:11 +00:00
|
|
|
press page-down
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# delete the second sandbox
|
|
|
|
assume-console [
|
2016-05-20 04:35:34 +00:00
|
|
|
left-click 2, 34
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# second sandbox shows in editor; scroll resets to display first sandbox
|
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-final-sandbox-after-scroll [
|
|
|
|
trace-until 100/app # trace too long
|
2016-05-20 04:35:34 +00:00
|
|
|
assume-screen 50/width, 10/height
|
2016-01-23 21:32:00 +00:00
|
|
|
# initialize environment
|
2016-04-24 18:54:30 +00:00
|
|
|
1:address:array:character <- new []
|
|
|
|
2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character
|
|
|
|
render-all screen, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
# create 2 sandboxes and scroll to second
|
|
|
|
assume-console [
|
|
|
|
press ctrl-n
|
|
|
|
type [add 2, 2]
|
|
|
|
press F4
|
|
|
|
type [add 1, 1]
|
|
|
|
press F4
|
2016-05-12 01:00:11 +00:00
|
|
|
press page-down
|
|
|
|
press page-down
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# delete the second sandbox
|
|
|
|
assume-console [
|
2016-05-20 04:35:34 +00:00
|
|
|
left-click 2, 34
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# implicitly scroll up to first sandbox
|
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
. .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-updates-sandbox-count [
|
|
|
|
trace-until 100/app # trace too long
|
2016-05-20 04:35:34 +00:00
|
|
|
assume-screen 50/width, 10/height
|
2016-01-23 21:32:00 +00:00
|
|
|
# initialize environment
|
2016-04-24 18:54:30 +00:00
|
|
|
1:address:array:character <- new []
|
|
|
|
2:address:programming-environment-data <- new-programming-environment screen:address:screen, 1:address:array:character
|
|
|
|
render-all screen, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
# create 2 sandboxes
|
|
|
|
assume-console [
|
|
|
|
press ctrl-n
|
|
|
|
type [add 2, 2]
|
|
|
|
press F4
|
|
|
|
type [add 1, 1]
|
|
|
|
press F4
|
|
|
|
]
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
. .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# delete the second sandbox, then try to scroll down twice
|
|
|
|
assume-console [
|
2016-05-20 04:35:34 +00:00
|
|
|
left-click 3, 34
|
2016-05-12 01:00:11 +00:00
|
|
|
press page-down
|
|
|
|
press page-down
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
run [
|
2016-04-24 18:54:30 +00:00
|
|
|
event-loop screen:address:screen, console:address:console, 2:address:programming-environment-data
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
# shouldn't go past last sandbox
|
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
.0 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
|
|
|
.━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━.
|
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|