diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-30 22:12:06 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-30 22:12:06 -0700 |
commit | 8ce71ea092832f07ad1254827d099b33f217d95c (patch) | |
tree | 3fa6b0dd728ca1f9505f78f2c4850e2d0646d8c8 | |
parent | 09bd1e3257ab121b958be538f0c80e690d069ad4 (diff) | |
download | mu-8ce71ea092832f07ad1254827d099b33f217d95c.tar.gz |
1905
-rw-r--r-- | edit.mu | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/edit.mu b/edit.mu index 1e6ae56c..bb97984d 100644 --- a/edit.mu +++ b/edit.mu @@ -3145,6 +3145,44 @@ scenario run-instruction-and-print-warnings-only-once [ ] ] +recipe editor-contents [ + local-scope + editor:address:editor-data <- next-ingredient + buf:address:buffer <- new-buffer 80 + curr:address:duplex-list <- get *editor, data:offset + # skip § sentinel + assert curr, [editor without data is illegal; must have at least a sentinel] + curr <- next-duplex curr + reply-unless curr, 0 + { + break-unless curr + c:character <- get *curr, value:offset + buffer-append buf, c + curr <- next-duplex curr + loop + } + result:address:array:character <- buffer-to-array buf + reply result +] + +scenario editor-provides-edited-contents [ + assume-screen 10/width, 5/height + 1:address:array:character <- new [abc] + 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right + assume-console [ + left-click 1, 2 + type [def] + ] + run [ + editor-event-loop screen:address, console:address, 2:address:editor-data + 3:address:array:character <- editor-contents 2:address:editor-data + 4:array:character <- copy *3:address:array:character + ] + memory-should-contain [ + 4:string <- [abdefc] + ] +] + ## editing sandboxes after they've been created scenario clicking-on-a-sandbox-moves-it-to-editor [ @@ -3398,44 +3436,6 @@ scenario run-instruction-manages-screen-per-sandbox [ ] ] -recipe editor-contents [ - local-scope - editor:address:editor-data <- next-ingredient - buf:address:buffer <- new-buffer 80 - curr:address:duplex-list <- get *editor, data:offset - # skip § sentinel - assert curr, [editor without data is illegal; must have at least a sentinel] - curr <- next-duplex curr - reply-unless curr, 0 - { - break-unless curr - c:character <- get *curr, value:offset - buffer-append buf, c - curr <- next-duplex curr - loop - } - result:address:array:character <- buffer-to-array buf - reply result -] - -scenario editor-provides-edited-contents [ - assume-screen 10/width, 5/height - 1:address:array:character <- new [abc] - 2:address:editor-data <- new-editor 1:address:array:character, screen:address, 0/left, 10/right - assume-console [ - left-click 1, 2 - type [def] - ] - run [ - editor-event-loop screen:address, console:address, 2:address:editor-data - 3:address:array:character <- editor-contents 2:address:editor-data - 4:array:character <- copy *3:address:array:character - ] - memory-should-contain [ - 4:string <- [abdefc] - ] -] - ## handling malformed programs scenario run-shows-warnings-in-get [ |