about summary refs log tree commit diff stats
path: root/edit/012-editor-undo.mu
diff options
context:
space:
mode:
Diffstat (limited to 'edit/012-editor-undo.mu')
-rw-r--r--edit/012-editor-undo.mu574
1 files changed, 292 insertions, 282 deletions
diff --git a/edit/012-editor-undo.mu b/edit/012-editor-undo.mu
index 428d51ca..48179c63 100644
--- a/edit/012-editor-undo.mu
+++ b/edit/012-editor-undo.mu
@@ -99,21 +99,21 @@ after <handle-special-character> [
 # undo typing
 
 scenario editor-can-undo-typing [
+  local-scope
   # create an editor and type a character
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [0]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # character should be gone
   screen-should-contain [
@@ -127,7 +127,7 @@ scenario editor-can-undo-typing [
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -229,21 +229,21 @@ after <handle-undo> [
 ]
 
 scenario editor-can-undo-typing-multiple [
+  local-scope
   # create an editor and type multiple characters
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [012]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # all characters must be gone
   screen-should-contain [
@@ -255,16 +255,16 @@ scenario editor-can-undo-typing-multiple [
 ]
 
 scenario editor-can-undo-typing-multiple-2 [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [a]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # type some characters
   assume-console [
     type [012]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .012a      .
@@ -276,7 +276,7 @@ scenario editor-can-undo-typing-multiple-2 [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # back to original text
   screen-should-contain [
@@ -290,7 +290,7 @@ scenario editor-can-undo-typing-multiple-2 [
     type [3]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -301,17 +301,17 @@ scenario editor-can-undo-typing-multiple-2 [
 ]
 
 scenario editor-can-undo-typing-enter [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [  abc]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [  abc], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # new line
   assume-console [
     left-click 1, 8
     press enter
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .  abc     .
@@ -320,8 +320,8 @@ scenario editor-can-undo-typing-enter [
     .          .
   ]
   # line is indented
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 2
@@ -331,10 +331,10 @@ scenario editor-can-undo-typing-enter [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 5
@@ -351,7 +351,7 @@ scenario editor-can-undo-typing-enter [
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -364,16 +364,16 @@ scenario editor-can-undo-typing-enter [
 # redo typing
 
 scenario editor-redo-typing [
+  local-scope
   # create an editor, type something, undo
   assume-screen 10/width, 5/height
-  1:text <- new [a]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [a], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [012]
     press ctrl-z
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .a         .
@@ -385,7 +385,7 @@ scenario editor-redo-typing [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # all characters must be back
   screen-should-contain [
@@ -399,7 +399,7 @@ scenario editor-redo-typing [
     type [3]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -428,16 +428,16 @@ after <handle-redo> [
 ]
 
 scenario editor-redo-typing-empty [
+  local-scope
   # create an editor, type something, undo
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [012]
     press ctrl-z
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .          .
@@ -449,7 +449,7 @@ scenario editor-redo-typing-empty [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # all characters must be back
   screen-should-contain [
@@ -463,7 +463,7 @@ scenario editor-redo-typing-empty [
     type [3]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -474,23 +474,24 @@ scenario editor-redo-typing-empty [
 ]
 
 scenario editor-work-clears-redo-stack [
+  local-scope
   # create an editor with some text, do some work, undo
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [1]
     press ctrl-z
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # do some more work
   assume-console [
     type [0]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .0abc      .
@@ -503,7 +504,7 @@ ghi]
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # nothing should happen
   screen-should-contain [
@@ -516,11 +517,11 @@ ghi]
 ]
 
 scenario editor-can-redo-typing-and-enter-and-tab [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and tabs, hit enter, some more text and tabs
   assume-console [
     press tab
@@ -531,7 +532,7 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press tab
     type [efg]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .  ab  cd  .
@@ -539,8 +540,8 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 7
@@ -550,11 +551,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # typing in second line deleted, but not indent
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 2
@@ -571,11 +572,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # indent and newline deleted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 8
@@ -591,11 +592,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # empty screen
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 0
@@ -611,11 +612,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 8
@@ -631,11 +632,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # newline and indent inserted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 2
@@ -652,11 +653,11 @@ scenario editor-can-redo-typing-and-enter-and-tab [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # indent and newline deleted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 7
@@ -673,28 +674,29 @@ scenario editor-can-redo-typing-and-enter-and-tab [
 # undo cursor movement and scroll
 
 scenario editor-can-undo-touch [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor
   assume-console [
     left-click 3, 1
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # click undone
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 0
@@ -704,7 +706,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -763,21 +765,22 @@ after <handle-undo> [
 ]
 
 scenario editor-can-undo-scroll [
+  local-scope
   # screen has 1 line for menu + 3 lines
   assume-screen 5/width, 4/height
   # editor contains a wrapped line
-  1:text <- new [a
+  contents:text <- new [a
 b
 cdefgh]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 5/right
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 5/right
   # position cursor at end of screen and try to move right
   assume-console [
     left-click 3, 3
     press right-arrow
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  editor-event-loop screen:&:screen, console:&:console, e
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   # screen scrolls
   screen-should-contain [
     .     .
@@ -794,11 +797,11 @@ cdefgh]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moved back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 3
     4 <- 3
@@ -815,7 +818,7 @@ cdefgh]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .     .
@@ -826,29 +829,30 @@ cdefgh]
 ]
 
 scenario editor-can-undo-left-arrow [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor
   assume-console [
     left-click 3, 1
     press left-arrow
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 3
     4 <- 1
@@ -858,7 +862,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -870,21 +874,22 @@ ghi]
 ]
 
 scenario editor-can-undo-up-arrow [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor
   assume-console [
     left-click 3, 1
     press up-arrow
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  editor-event-loop screen:&:screen, console:&:console, e
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -894,11 +899,11 @@ ghi]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 3
     4 <- 1
@@ -908,7 +913,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -920,29 +925,30 @@ ghi]
 ]
 
 scenario editor-can-undo-down-arrow [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor
   assume-console [
     left-click 2, 1
     press down-arrow
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -952,7 +958,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -964,29 +970,28 @@ ghi]
 ]
 
 scenario editor-can-undo-ctrl-f [
+  local-scope
   # create an editor with multiple pages of text
   assume-screen 10/width, 5/height
-  1:text <- new [a
+  contents:text <- new [a
 b
 c
 d
 e
 f]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # scroll the page
   assume-console [
     press ctrl-f
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # screen should again show page 1
   screen-should-contain [
@@ -999,29 +1004,28 @@ f]
 ]
 
 scenario editor-can-undo-page-down [
+  local-scope
   # create an editor with multiple pages of text
   assume-screen 10/width, 5/height
-  1:text <- new [a
+  contents:text <- new [a
 b
 c
 d
 e
 f]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # scroll the page
   assume-console [
     press page-down
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # screen should again show page 1
   screen-should-contain [
@@ -1034,30 +1038,29 @@ f]
 ]
 
 scenario editor-can-undo-ctrl-b [
+  local-scope
   # create an editor with multiple pages of text
   assume-screen 10/width, 5/height
-  1:text <- new [a
+  contents:text <- new [a
 b
 c
 d
 e
 f]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # scroll the page down and up
   assume-console [
     press page-down
     press ctrl-b
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # screen should again show page 2
   screen-should-contain [
@@ -1070,30 +1073,29 @@ f]
 ]
 
 scenario editor-can-undo-page-up [
+  local-scope
   # create an editor with multiple pages of text
   assume-screen 10/width, 5/height
-  1:text <- new [a
+  contents:text <- new [a
 b
 c
 d
 e
 f]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # scroll the page down and up
   assume-console [
     press page-down
     press page-up
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # screen should again show page 2
   screen-should-contain [
@@ -1106,29 +1108,30 @@ f]
 ]
 
 scenario editor-can-undo-ctrl-a [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor, then to start of line
   assume-console [
     left-click 2, 1
     press ctrl-a
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -1138,7 +1141,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1150,29 +1153,30 @@ ghi]
 ]
 
 scenario editor-can-undo-home [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor, then to start of line
   assume-console [
     left-click 2, 1
     press home
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -1182,7 +1186,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1194,29 +1198,30 @@ ghi]
 ]
 
 scenario editor-can-undo-ctrl-e [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor, then to start of line
   assume-console [
     left-click 2, 1
     press ctrl-e
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -1226,7 +1231,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1238,29 +1243,30 @@ ghi]
 ]
 
 scenario editor-can-undo-end [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor, then to start of line
   assume-console [
     left-click 2, 1
     press end
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # undo
   assume-console [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves back
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -1270,7 +1276,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1282,13 +1288,14 @@ ghi]
 ]
 
 scenario editor-can-undo-multiple-arrows-in-the-same-direction [
+  local-scope
   # create an editor with some text
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # move the cursor
   assume-console [
     left-click 2, 1
@@ -1296,9 +1303,9 @@ ghi]
     press right-arrow
     press up-arrow
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  editor-event-loop screen:&:screen, console:&:console, e
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 3
@@ -1308,11 +1315,11 @@ ghi]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # up-arrow is undone
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 3
@@ -1322,11 +1329,11 @@ ghi]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # both right-arrows are undone
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 2
     4 <- 1
@@ -1336,28 +1343,29 @@ ghi]
 # redo cursor movement and scroll
 
 scenario editor-redo-touch [
+  local-scope
   # create an editor with some text, click on a character, undo
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def
 ghi]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     left-click 3, 1
     press ctrl-z
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   # redo
   assume-console [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # cursor moves to left-click
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 3
     4 <- 1
@@ -1367,7 +1375,7 @@ ghi]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1393,19 +1401,19 @@ after <handle-redo> [
 ]
 
 scenario editor-separates-undo-insert-from-undo-cursor-move [
+  local-scope
   # create an editor, type some text, move the cursor, type some more text
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   assume-console [
     type [abc]
     left-click 1, 1
     type [d]
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  editor-event-loop screen:&:screen, console:&:console, e
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   screen-should-contain [
     .          .
     .adbc      .
@@ -1421,9 +1429,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # last letter typed is deleted
   screen-should-contain [
@@ -1441,9 +1449,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # no change to screen; cursor moves
   screen-should-contain [
@@ -1461,9 +1469,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # screen empty
   screen-should-contain [
@@ -1481,9 +1489,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # first insert
   screen-should-contain [
@@ -1501,9 +1509,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # cursor moves
   screen-should-contain [
@@ -1522,9 +1530,9 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
-    3:num <- get *2:&:editor, cursor-row:offset
-    4:num <- get *2:&:editor, cursor-column:offset
+    editor-event-loop screen:&:screen, console:&:console, e
+    3:num/raw <- get *e, cursor-row:offset
+    4:num/raw <- get *e, cursor-column:offset
   ]
   # second insert
   screen-should-contain [
@@ -1542,26 +1550,26 @@ scenario editor-separates-undo-insert-from-undo-cursor-move [
 # undo backspace
 
 scenario editor-can-undo-and-redo-backspace [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and hit backspace
   assume-console [
     type [abc]
     press backspace
     press backspace
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .a         .
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1571,10 +1579,10 @@ scenario editor-can-undo-and-redo-backspace [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 3
@@ -1590,10 +1598,10 @@ scenario editor-can-undo-and-redo-backspace [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1687,11 +1695,11 @@ after <handle-redo> [
 # undo delete
 
 scenario editor-can-undo-and-redo-delete [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and hit delete and backspace a few times
   assume-console [
     type [abcdef]
@@ -1701,15 +1709,15 @@ scenario editor-can-undo-and-redo-delete [
     press delete
     press delete
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .af        .
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1719,10 +1727,10 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1738,10 +1746,10 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 2
@@ -1757,10 +1765,10 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 2
@@ -1776,11 +1784,11 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 2
@@ -1796,11 +1804,11 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1816,11 +1824,11 @@ scenario editor-can-undo-and-redo-delete [
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1876,18 +1884,19 @@ before <delete-character-end> [
 # undo ctrl-k
 
 scenario editor-can-undo-and-redo-ctrl-k [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and hit delete and backspace a few times
   assume-console [
     left-click 1, 1
     press ctrl-k
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .a         .
@@ -1895,8 +1904,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1906,7 +1915,7 @@ def]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1915,8 +1924,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1926,7 +1935,7 @@ def]
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
   screen-should-contain [
@@ -1936,8 +1945,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 1
@@ -1947,7 +1956,7 @@ def]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -1978,18 +1987,19 @@ before <delete-to-end-of-line-end> [
 # undo ctrl-u
 
 scenario editor-can-undo-and-redo-ctrl-u [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new [abc
+  contents:text <- new [abc
 def]
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor contents, screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and hit delete and backspace a few times
   assume-console [
     left-click 1, 2
     press ctrl-u
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .c         .
@@ -1997,8 +2007,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 0
@@ -2008,7 +2018,7 @@ def]
     press ctrl-z
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -2017,8 +2027,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 2
@@ -2028,7 +2038,7 @@ def]
     press ctrl-y
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   # first line inserted
   screen-should-contain [
@@ -2038,8 +2048,8 @@ def]
     .┈┈┈┈┈┈┈┈┈┈.
     .          .
   ]
-  3:num <- get *2:&:editor, cursor-row:offset
-  4:num <- get *2:&:editor, cursor-column:offset
+  3:num/raw <- get *e, cursor-row:offset
+  4:num/raw <- get *e, cursor-column:offset
   memory-should-contain [
     3 <- 1
     4 <- 0
@@ -2049,7 +2059,7 @@ def]
     type [1]
   ]
   run [
-    editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+    editor-event-loop screen:&:screen, console:&:console, e
   ]
   screen-should-contain [
     .          .
@@ -2079,18 +2089,18 @@ before <delete-to-start-of-line-end> [
 ]
 
 scenario editor-can-undo-and-redo-ctrl-u-2 [
+  local-scope
   # create an editor
   assume-screen 10/width, 5/height
-  1:text <- new []
-  2:&:editor <- new-editor 1:text, screen:&:screen, 0/left, 10/right
-  editor-render screen, 2:&:editor
+  e:&:editor <- new-editor [], screen:&:screen, 0/left, 10/right
+  editor-render screen, e
   # insert some text and hit delete and backspace a few times
   assume-console [
     type [abc]
     press ctrl-u
     press ctrl-z
   ]
-  editor-event-loop screen:&:screen, console:&:console, 2:&:editor
+  editor-event-loop screen:&:screen, console:&:console, e
   screen-should-contain [
     .          .
     .abc       .