2015-09-12 20:49:50 +00:00
|
|
|
## deleting sandboxes
|
|
|
|
|
|
|
|
scenario deleting-sandboxes [
|
2016-09-29 02:48:56 +00:00
|
|
|
local-scope
|
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-12-12 00:18:18 +00:00
|
|
|
assume-resources [
|
|
|
|
]
|
|
|
|
env:&:environment <- new-programming-environment resources, screen, []
|
2017-06-09 18:29:15 +00:00
|
|
|
render-all screen, env, render
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2015-09-12 20:49:50 +00:00
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
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-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
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-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2015-09-12 20:49:50 +00:00
|
|
|
. .
|
|
|
|
]
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2015-09-12 20:49:50 +00:00
|
|
|
]
|
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
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-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2015-09-12 20:49:50 +00:00
|
|
|
. .
|
|
|
|
]
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2015-09-12 20:49:50 +00:00
|
|
|
]
|
|
|
|
screen-should-contain [
|
|
|
|
. run (F4) .
|
|
|
|
. .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2015-09-12 20:49:50 +00:00
|
|
|
. .
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
after <global-touch> [
|
2016-05-20 04:35:34 +00:00
|
|
|
# support 'delete' button
|
2015-09-12 20:49:50 +00:00
|
|
|
{
|
2016-09-17 20:25:40 +00:00
|
|
|
delete?:bool <- should-attempt-delete? click-row, click-column, env
|
2016-05-20 04:35:34 +00:00
|
|
|
break-unless delete?
|
|
|
|
delete?, env <- try-delete-sandbox click-row, env
|
|
|
|
break-unless delete?
|
2016-06-13 05:44:58 +00:00
|
|
|
screen <- render-sandbox-side screen, env, render
|
2016-01-23 03:11:59 +00:00
|
|
|
screen <- update-cursor screen, current-sandbox, env
|
2016-10-22 19:08:10 +00:00
|
|
|
loop +next-event
|
2015-09-12 20:49:50 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2016-05-20 04:35:34 +00:00
|
|
|
# some preconditions for attempting to delete a sandbox
|
2016-09-18 00:54:55 +00:00
|
|
|
def should-attempt-delete? click-row:num, click-column:num, env:&:environment -> result:bool [
|
2016-05-20 04:35:34 +00:00
|
|
|
local-scope
|
2017-12-04 07:25:40 +00:00
|
|
|
load-inputs
|
2016-05-20 04:35:34 +00:00
|
|
|
# are we below the sandbox editor?
|
2016-09-17 20:25:40 +00:00
|
|
|
click-sandbox-area?:bool <- click-on-sandbox-area? click-row, env
|
2018-06-17 07:05:38 +00:00
|
|
|
return-unless click-sandbox-area?, false
|
2016-05-20 04:35:34 +00:00
|
|
|
# narrower, is the click in the columns spanning the 'copy' button?
|
2016-09-18 00:54:55 +00:00
|
|
|
first-sandbox:&:editor <- get *env, current-sandbox:offset
|
2016-05-20 04:35:34 +00:00
|
|
|
assert first-sandbox, [!!]
|
2016-09-17 20:25:40 +00:00
|
|
|
sandbox-left-margin:num <- get *first-sandbox, left:offset
|
|
|
|
sandbox-right-margin:num <- get *first-sandbox, right:offset
|
|
|
|
_, _, _, _, delete-button-left:num <- sandbox-menu-columns sandbox-left-margin, sandbox-right-margin
|
2016-05-20 04:35:34 +00:00
|
|
|
result <- within-range? click-column, delete-button-left, sandbox-right-margin
|
|
|
|
]
|
|
|
|
|
2016-09-18 00:54:55 +00:00
|
|
|
def try-delete-sandbox click-row:num, env:&:environment -> clicked-on-delete-button?:bool, env:&:environment [
|
2016-05-20 04:35:34 +00:00
|
|
|
local-scope
|
2017-12-04 07:25:40 +00:00
|
|
|
load-inputs
|
2016-05-20 04:35:34 +00:00
|
|
|
# identify the sandbox to delete, if the click was actually on the 'delete' button
|
2016-09-18 00:54:55 +00:00
|
|
|
sandbox:&:sandbox <- find-sandbox env, click-row
|
2018-06-17 07:05:38 +00:00
|
|
|
return-unless sandbox, false
|
|
|
|
clicked-on-delete-button? <- copy true
|
2016-05-20 04:35:34 +00:00
|
|
|
env <- delete-sandbox env, sandbox
|
|
|
|
]
|
|
|
|
|
2016-09-18 00:54:55 +00:00
|
|
|
def delete-sandbox env:&:environment, sandbox:&:sandbox -> env:&:environment [
|
2015-09-12 20:49:50 +00:00
|
|
|
local-scope
|
2017-12-04 07:25:40 +00:00
|
|
|
load-inputs
|
2016-09-18 00:54:55 +00:00
|
|
|
curr-sandbox:&:sandbox <- get *env, sandbox:offset
|
2016-09-17 20:25:40 +00:00
|
|
|
first-sandbox?:bool <- 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?
|
2016-09-18 00:54:55 +00:00
|
|
|
next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
|
2016-05-20 04:35:34 +00:00
|
|
|
*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?
|
2016-09-18 00:54:55 +00:00
|
|
|
prev-sandbox:&:sandbox <- copy curr-sandbox
|
2016-05-20 04:35:34 +00:00
|
|
|
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.]
|
2016-09-17 20:25:40 +00:00
|
|
|
found?:bool <- equal curr-sandbox, sandbox
|
2016-05-20 04:35:34 +00:00
|
|
|
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
|
2016-09-18 00:54:55 +00:00
|
|
|
next-sandbox:&:sandbox <- get *curr-sandbox, next-sandbox:offset
|
2016-05-20 04:35:34 +00:00
|
|
|
*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
|
2016-09-17 20:25:40 +00:00
|
|
|
sandbox-count:num <- get *env, number-of-sandboxes:offset
|
2016-04-23 05:53:39 +00:00
|
|
|
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-09-17 20:25:40 +00:00
|
|
|
render-from:num <- get *env, render-from:offset
|
|
|
|
reset-scroll?:bool <- equal render-from, sandbox-count
|
2016-04-23 05:53:39 +00:00
|
|
|
break-unless reset-scroll?
|
|
|
|
*env <- put *env, render-from:offset, -1
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2016-01-23 21:32:00 +00:00
|
|
|
scenario deleting-sandbox-after-scroll [
|
2016-09-29 02:48:56 +00:00
|
|
|
local-scope
|
2016-01-23 21:32:00 +00:00
|
|
|
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-12-12 00:18:18 +00:00
|
|
|
assume-resources [
|
|
|
|
]
|
|
|
|
env:&:environment <- new-programming-environment resources, screen, []
|
2016-09-29 02:48:56 +00:00
|
|
|
render-all screen, env, render
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
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) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-top-sandbox-after-scroll [
|
2016-09-29 02:48:56 +00:00
|
|
|
local-scope
|
2016-01-23 21:32:00 +00:00
|
|
|
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-12-12 00:18:18 +00:00
|
|
|
assume-resources [
|
|
|
|
]
|
|
|
|
env:&:environment <- new-programming-environment resources, screen, []
|
2016-09-29 02:48:56 +00:00
|
|
|
render-all screen, env, render
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
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) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-final-sandbox-after-scroll [
|
2016-09-29 02:48:56 +00:00
|
|
|
local-scope
|
2016-01-23 21:32:00 +00:00
|
|
|
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-12-12 00:18:18 +00:00
|
|
|
assume-resources [
|
|
|
|
]
|
|
|
|
env:&:environment <- new-programming-environment resources, screen, []
|
2016-09-29 02:48:56 +00:00
|
|
|
render-all screen, env, render
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.1 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
. .
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
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) .
|
|
|
|
. .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
scenario deleting-updates-sandbox-count [
|
2016-09-29 02:48:56 +00:00
|
|
|
local-scope
|
2016-01-23 21:32:00 +00:00
|
|
|
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-12-12 00:18:18 +00:00
|
|
|
assume-resources [
|
|
|
|
]
|
|
|
|
env:&:environment <- new-programming-environment resources, screen, []
|
2016-09-29 02:48:56 +00:00
|
|
|
render-all screen, env, render
|
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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
2016-01-23 21:32:00 +00:00
|
|
|
screen-should-contain [
|
2016-05-20 04:35:34 +00:00
|
|
|
. run (F4) .
|
|
|
|
. .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 1, 1 .
|
|
|
|
.2 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.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-12-12 00:18:18 +00:00
|
|
|
event-loop screen, console, env, resources
|
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) .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
.0 edit copy delete .
|
|
|
|
.add 2, 2 .
|
|
|
|
.4 .
|
2016-10-09 07:20:43 +00:00
|
|
|
.──────────────────────────────────────────────────.
|
2016-05-20 04:35:34 +00:00
|
|
|
. .
|
2016-01-23 21:32:00 +00:00
|
|
|
]
|
|
|
|
]
|