From 8ce71ea092832f07ad1254827d099b33f217d95c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 30 Jul 2015 22:12:06 -0700 Subject: 1905 --- edit.mu | 76 ++++++++++++++++++++++++++++++++--------------------------------- 1 file 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 [ -- cgit 1.4.1-2-gfad0