about summary refs log tree commit diff stats
path: root/edit
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-11-05 14:17:31 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-11-05 14:17:31 -0800
commitb0403c18880395f9ce451f72ac4d33ef955f2ad1 (patch)
tree772e9c2dbe81774f01bd49de9ee17a6bf710a9b8 /edit
parent8389d168e4e6eada19462cf70249c45508fd1f4d (diff)
downloadmu-b0403c18880395f9ce451f72ac4d33ef955f2ad1.tar.gz
2374 - now edit works until layer 8
Diffstat (limited to 'edit')
-rw-r--r--edit/006-sandbox-edit.mu18
-rw-r--r--edit/007-sandbox-delete.mu6
-rw-r--r--edit/008-sandbox-test.mu10
-rw-r--r--edit/011-editor-undo.mu118
4 files changed, 73 insertions, 79 deletions
diff --git a/edit/006-sandbox-edit.mu b/edit/006-sandbox-edit.mu
index acf109fa..6c61916d 100644
--- a/edit/006-sandbox-edit.mu
+++ b/edit/006-sandbox-edit.mu
@@ -89,19 +89,17 @@ after <global-touch> [
   }
 ]
 
-recipe empty-editor? [
+recipe empty-editor? editor:address:editor-data -> result:boolean [
   local-scope
-  editor:address:editor-data <- next-ingredient
-  head:address:duplex-list <- get *editor, data:offset
-  first:address:duplex-list <- next-duplex head
-  result:boolean <- not first
-  reply result
+  load-ingredients
+  head:address:duplex-list:character <- get *editor, data:offset
+  first:address:duplex-list:character <- next-duplex head
+  result <- not first
 ]
 
-recipe extract-sandbox [
+recipe extract-sandbox env:address:programming-environment-data, click-row:number -> result:address:sandbox-data [
   local-scope
-  env:address:programming-environment-data <- next-ingredient
-  click-row:number <- next-ingredient
+  load-ingredients
   # assert click-row >= sandbox.starting-row-on-screen
   sandbox:address:address:sandbox-data <- get-address *env, sandbox:offset
   start:number <- get **sandbox, starting-row-on-screen:offset
@@ -118,7 +116,7 @@ recipe extract-sandbox [
     loop
   }
   # snip sandbox out of its list
-  result:address:sandbox-data <- copy *sandbox
+  result <- copy *sandbox
   *sandbox <- copy next-sandbox
   # position cursor in sandbox editor
   sandbox-in-focus?:address:boolean <- get-address *env, sandbox-in-focus?:offset
diff --git a/edit/007-sandbox-delete.mu b/edit/007-sandbox-delete.mu
index b78d9f76..54c4fc8b 100644
--- a/edit/007-sandbox-delete.mu
+++ b/edit/007-sandbox-delete.mu
@@ -77,11 +77,9 @@ after <global-touch> [
   }
 ]
 
-# was-deleted?:boolean <- delete-sandbox t:touch-event, env:address:programming-environment-data
-recipe delete-sandbox [
+recipe delete-sandbox t:touch-event, env:address:programming-environment-data -> was-delete?:boolean [
   local-scope
-  t:touch-event <- next-ingredient
-  env:address:programming-environment-data <- next-ingredient
+  load-ingredients
   click-column:number <- get t, column:offset
   current-sandbox:address:editor-data <- get *env, current-sandbox:offset
   right:number <- get *current-sandbox, right:offset
diff --git a/edit/008-sandbox-test.mu b/edit/008-sandbox-test.mu
index e7258204..fbc66aad 100644
--- a/edit/008-sandbox-test.mu
+++ b/edit/008-sandbox-test.mu
@@ -110,10 +110,9 @@ after <global-touch> [
   }
 ]
 
-recipe find-click-in-sandbox-output [
+recipe find-click-in-sandbox-output env:address:programming-environment-data, click-row:number -> sandbox:address:sandbox-data [
   local-scope
-  env:address:programming-environment-data <- next-ingredient
-  click-row:number <- next-ingredient
+  load-ingredients
   # assert click-row >= sandbox.starting-row-on-screen
   sandbox:address:sandbox-data <- get *env, sandbox:offset
   start:number <- get *sandbox, starting-row-on-screen:offset
@@ -137,9 +136,9 @@ recipe find-click-in-sandbox-output [
   reply sandbox
 ]
 
-recipe toggle-expected-response [
+recipe toggle-expected-response sandbox:address:sandbox-data -> sandbox:address:sandbox-data [
   local-scope
-  sandbox:address:sandbox-data <- next-ingredient
+  load-ingredients
   expected-response:address:address:array:character <- get-address *sandbox, expected-response:offset
   {
     # if expected-response is set, reset
@@ -150,7 +149,6 @@ recipe toggle-expected-response [
   # if not, current response is the expected response
   response:address:array:character <- get *sandbox, response:offset
   *expected-response <- copy response
-  reply sandbox/same-as-ingredient:0
 ]
 
 # when rendering a sandbox, color it in red/green if expected response exists
diff --git a/edit/011-editor-undo.mu b/edit/011-editor-undo.mu
index 17d97213..9f0d83de 100644
--- a/edit/011-editor-undo.mu
+++ b/edit/011-editor-undo.mu
@@ -11,13 +11,13 @@ exclusive-container operation [
 container insert-operation [
   before-row:number
   before-column:number
-  before-top-of-screen:address:duplex-list:character
+  before-top-of-screen:address:duplex-list:character:character
   after-row:number
   after-column:number
-  after-top-of-screen:address:duplex-list:character
+  after-top-of-screen:address:duplex-list:character:character
   # inserted text is from 'insert-from' until 'insert-until'; list doesn't have to terminate
-  insert-from:address:duplex-list:character
-  insert-until:address:duplex-list:character
+  insert-from:address:duplex-list:character:character
+  insert-until:address:duplex-list:character:character
   tag:number  # event causing this operation; might be used to coalesce runs of similar events
     # 0: no coalesce (enter+indent)
     # 1: regular alphanumeric characters
@@ -26,10 +26,10 @@ container insert-operation [
 container move-operation [
   before-row:number
   before-column:number
-  before-top-of-screen:address:duplex-list:character
+  before-top-of-screen:address:duplex-list:character:character
   after-row:number
   after-column:number
-  after-top-of-screen:address:duplex-list:character
+  after-top-of-screen:address:duplex-list:character:character
   tag:number  # event causing this operation; might be used to coalesce runs of similar events
     # 0: no coalesce (touch events, etc)
     # 1: left arrow
@@ -41,13 +41,13 @@ container move-operation [
 container delete-operation [
   before-row:number
   before-column:number
-  before-top-of-screen:address:duplex-list:character
+  before-top-of-screen:address:duplex-list:character:character
   after-row:number
   after-column:number
-  after-top-of-screen:address:duplex-list:character
-  deleted-text:address:duplex-list:character
-  delete-from:address:duplex-list:character
-  delete-until:address:duplex-list:character
+  after-top-of-screen:address:duplex-list:character:character
+  deleted-text:address:duplex-list:character:character
+  delete-from:address:duplex-list:character:character
+  delete-until:address:duplex-list:character:character
   tag:number  # event causing this operation; might be used to coalesce runs of similar events
     # 0: no coalesce (ctrl-k, ctrl-u)
     # 1: backspace
@@ -135,11 +135,11 @@ scenario editor-can-undo-typing [
 
 # save operation to undo
 after <insert-character-begin> [
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
-  cursor-before:address:duplex-list <- copy *before-cursor
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
+  cursor-before:address:duplex-list:character <- copy *before-cursor
 ]
 before <insert-character-end> [
-  top-after:address:duplex-list <- get *editor, top-of-screen:offset
+  top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
   undo:address:address:list <- get-address *editor, undo:offset
   {
     # if previous operation was an insert, coalesce this operation with it
@@ -149,19 +149,19 @@ before <insert-character-end> [
     break-unless typing
     previous-coalesce-tag:number <- get *typing, tag:offset
     break-unless previous-coalesce-tag
-    insert-until:address:address:duplex-list <- get-address *typing, insert-until:offset
+    insert-until:address:address:duplex-list:character <- get-address *typing, insert-until:offset
     *insert-until <- next-duplex *before-cursor
     after-row:address:number <- get-address *typing, after-row:offset
     *after-row <- copy *cursor-row
     after-column:address:number <- get-address *typing, after-column:offset
     *after-column <- copy *cursor-column
-    after-top:address:address:duplex-list:character <- get-address *typing, after-top-of-screen:offset
+    after-top:address:address:duplex-list:character:character <- get-address *typing, after-top-of-screen:offset
     *after-top <- get *editor, top-of-screen:offset
     break +done-adding-insert-operation:label
   }
   # if not, create a new operation
-  insert-from:address:duplex-list <- next-duplex cursor-before
-  insert-to:address:duplex-list <- next-duplex insert-from
+  insert-from:address:duplex-list:character <- next-duplex cursor-before
+  insert-to:address:duplex-list:character <- next-duplex insert-from
   op:address:operation <- new operation:type
   *op <- merge 0/insert-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 1/coalesce
   editor <- add-operation editor, op
@@ -172,14 +172,14 @@ before <insert-character-end> [
 after <insert-enter-begin> [
   cursor-row-before:number <- copy *cursor-row
   cursor-column-before:number <- copy *cursor-column
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
-  cursor-before:address:duplex-list <- copy *before-cursor
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
+  cursor-before:address:duplex-list:character <- copy *before-cursor
 ]
 before <insert-enter-end> [
-  top-after:address:duplex-list <- get *editor, top-of-screen:offset
+  top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
   # never coalesce
-  insert-from:address:duplex-list <- next-duplex cursor-before
-  insert-to:address:duplex-list <- next-duplex *before-cursor
+  insert-from:address:duplex-list:character <- next-duplex cursor-before
+  insert-to:address:duplex-list:character <- next-duplex *before-cursor
   op:address:operation <- new operation:type
   *op <- merge 0/insert-operation, cursor-row-before, cursor-column-before, top-before, *cursor-row/after, *cursor-column/after, top-after, insert-from, insert-to, 0/never-coalesce
   editor <- add-operation editor, op
@@ -204,14 +204,14 @@ after <handle-undo> [
   {
     typing:address:insert-operation <- maybe-convert *op, typing:variant
     break-unless typing
-    start:address:duplex-list <- get *typing, insert-from:offset
-    end:address:duplex-list <- get *typing, insert-until:offset
+    start:address:duplex-list:character <- get *typing, insert-from:offset
+    end:address:duplex-list:character <- get *typing, insert-until:offset
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
     *before-cursor <- prev-duplex start
     remove-duplex-between *before-cursor, end
     *cursor-row <- get *typing, before-row:offset
     *cursor-column <- get *typing, before-column:offset
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *top <- get *typing, before-top-of-screen:offset
   }
 ]
@@ -401,13 +401,13 @@ after <handle-redo> [
   {
     typing:address:insert-operation <- maybe-convert *op, typing:variant
     break-unless typing
-    insert-from:address:duplex-list <- get *typing, insert-from:offset  # ignore insert-to because it's already been spliced away
+    insert-from:address:duplex-list:character <- get *typing, insert-from:offset  # ignore insert-to because it's already been spliced away
     # assert insert-to matches next-duplex(*before-cursor)
     insert-duplex-range *before-cursor, insert-from
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
     *cursor-row <- get *typing, after-row:offset
     *cursor-column <- get *typing, after-column:offset
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *top <- get *typing, after-top-of-screen:offset
   }
 ]
@@ -703,12 +703,12 @@ ghi]
 after <move-cursor-begin> [
   before-cursor-row:number <- get *editor, cursor-row:offset
   before-cursor-column:number <- get *editor, cursor-column:offset
-  before-top-of-screen:address:duplex-list <- get *editor, top-of-screen:offset
+  before-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset
 ]
 before <move-cursor-end> [
   after-cursor-row:number <- get *editor, cursor-row:offset
   after-cursor-column:number <- get *editor, cursor-column:offset
-  after-top-of-screen:address:duplex-list <- get *editor, top-of-screen:offset
+  after-top-of-screen:address:duplex-list:character <- get *editor, top-of-screen:offset
   {
     break-unless undo-coalesce-tag
     # if previous operation was also a move, and also had the same coalesce
@@ -725,7 +725,7 @@ before <move-cursor-end> [
     *after-row <- copy after-cursor-row
     after-column:address:number <- get-address *move, after-column:offset
     *after-column <- copy after-cursor-column
-    after-top:address:address:duplex-list:character <- get-address *move, after-top-of-screen:offset
+    after-top:address:address:duplex-list:character:character <- get-address *move, after-top-of-screen:offset
     *after-top <- get *editor, top-of-screen:offset
     break +done-adding-move-operation:label
   }
@@ -740,7 +740,7 @@ after <handle-undo> [
     move:address:move-operation <- maybe-convert *op, move:variant
     break-unless move
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *cursor-row <- get *move, before-row:offset
     *cursor-column <- get *move, before-column:offset
     *top <- get *move, before-top-of-screen:offset
@@ -1516,7 +1516,7 @@ after <handle-redo> [
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
     *cursor-row <- get *move, after-row:offset
     *cursor-column <- get *move, after-column:offset
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *top <- get *move, after-top-of-screen:offset
   }
 ]
@@ -1590,12 +1590,12 @@ scenario editor-can-undo-and-redo-backspace [
 
 # save operation to undo
 after <backspace-character-begin> [
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
 ]
 before <backspace-character-end> [
   {
     break-unless backspaced-cell  # backspace failed; don't add an undo operation
-    top-after:address:duplex-list <- get *editor, top-of-screen:offset
+    top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
     undo:address:address:list <- get-address *editor, undo:offset
     {
       # if previous operation was an insert, coalesce this operation with it
@@ -1606,22 +1606,22 @@ before <backspace-character-end> [
       previous-coalesce-tag:number <- get *deletion, tag:offset
       coalesce?:boolean <- equal previous-coalesce-tag, 1/coalesce-backspace
       break-unless coalesce?
-      delete-from:address:address:duplex-list <- get-address *deletion, delete-from:offset
+      delete-from:address:address:duplex-list:character <- get-address *deletion, delete-from:offset
       *delete-from <- copy *before-cursor
-      backspaced-so-far:address:address:duplex-list <- get-address *deletion, deleted-text:offset
+      backspaced-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset
       insert-duplex-range backspaced-cell, *backspaced-so-far
       *backspaced-so-far <- copy backspaced-cell
       after-row:address:number <- get-address *deletion, after-row:offset
       *after-row <- copy *cursor-row
       after-column:address:number <- get-address *deletion, after-column:offset
       *after-column <- copy *cursor-column
-      after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset
+      after-top:address:address:duplex-list:character:character <- get-address *deletion, after-top-of-screen:offset
       *after-top <- get *editor, top-of-screen:offset
       break +done-adding-backspace-operation:label
     }
     # if not, create a new operation
     op:address:operation <- new operation:type
-    deleted-until:address:duplex-list <- next-duplex *before-cursor
+    deleted-until:address:duplex-list:character <- next-duplex *before-cursor
     *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, backspaced-cell/deleted, *before-cursor/delete-from, deleted-until, 1/coalesce-backspace
     editor <- add-operation editor, op
     +done-adding-backspace-operation
@@ -1632,17 +1632,17 @@ after <handle-undo> [
   {
     deletion:address:delete-operation <- maybe-convert *op, delete:variant
     break-unless deletion
-    start2:address:address:duplex-list <- get-address *editor, data:offset
-    anchor:address:duplex-list <- get *deletion, delete-from:offset
+    start2:address:address:duplex-list:character <- get-address *editor, data:offset
+    anchor:address:duplex-list:character <- get *deletion, delete-from:offset
     break-unless anchor
-    deleted:address:duplex-list <- get *deletion, deleted-text:offset
-    old-cursor:address:duplex-list <- last-duplex deleted
+    deleted:address:duplex-list:character <- get *deletion, deleted-text:offset
+    old-cursor:address:duplex-list:character <- last-duplex deleted
     insert-duplex-range anchor, deleted
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
     *before-cursor <- copy old-cursor
     *cursor-row <- get *deletion, before-row:offset
     *cursor-column <- get *deletion, before-column:offset
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *top <- get *deletion, before-top-of-screen:offset
   }
 ]
@@ -1651,13 +1651,13 @@ after <handle-redo> [
   {
     deletion:address:delete-operation <- maybe-convert *op, delete:variant
     break-unless deletion
-    start:address:duplex-list <- get *deletion, delete-from:offset
-    end:address:duplex-list <- get *deletion, delete-until:offset
+    start:address:duplex-list:character <- get *deletion, delete-from:offset
+    end:address:duplex-list:character <- get *deletion, delete-until:offset
     remove-duplex-between start, end
     # assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen
     *cursor-row <- get *deletion, after-row:offset
     *cursor-column <- get *deletion, after-column:offset
-    top:address:address:duplex-list <- get-address *editor, top-of-screen:offset
+    top:address:address:duplex-list:character <- get-address *editor, top-of-screen:offset
     *top <- get *deletion, after-top-of-screen:offset
   }
 ]
@@ -1812,12 +1812,12 @@ scenario editor-can-undo-and-redo-delete [
 ]
 
 after <delete-character-begin> [
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
 ]
 before <delete-character-end> [
   {
     break-unless deleted-cell  # delete failed; don't add an undo operation
-    top-after:address:duplex-list <- get *editor, top-of-screen:offset
+    top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
     undo:address:address:list <- get-address *editor, undo:offset
     {
       # if previous operation was an insert, coalesce this operation with it
@@ -1828,21 +1828,21 @@ before <delete-character-end> [
       previous-coalesce-tag:number <- get *deletion, tag:offset
       coalesce?:boolean <- equal previous-coalesce-tag, 2/coalesce-delete
       break-unless coalesce?
-      delete-until:address:address:duplex-list <- get-address *deletion, delete-until:offset
+      delete-until:address:address:duplex-list:character <- get-address *deletion, delete-until:offset
       *delete-until <- next-duplex *before-cursor
-      deleted-so-far:address:address:duplex-list <- get-address *deletion, deleted-text:offset
+      deleted-so-far:address:address:duplex-list:character <- get-address *deletion, deleted-text:offset
       *deleted-so-far <- append-duplex *deleted-so-far, deleted-cell
       after-row:address:number <- get-address *deletion, after-row:offset
       *after-row <- copy *cursor-row
       after-column:address:number <- get-address *deletion, after-column:offset
       *after-column <- copy *cursor-column
-      after-top:address:address:duplex-list:character <- get-address *deletion, after-top-of-screen:offset
+      after-top:address:address:duplex-list:character:character <- get-address *deletion, after-top-of-screen:offset
       *after-top <- get *editor, top-of-screen:offset
       break +done-adding-delete-operation:label
     }
     # if not, create a new operation
     op:address:operation <- new operation:type
-    deleted-until:address:duplex-list <- next-duplex *before-cursor
+    deleted-until:address:duplex-list:character <- next-duplex *before-cursor
     *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cell/deleted, *before-cursor/delete-from, deleted-until, 2/coalesce-delete
     editor <- add-operation editor, op
     +done-adding-delete-operation
@@ -1935,15 +1935,15 @@ def]
 ]
 
 after <delete-to-end-of-line-begin> [
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
 ]
 before <delete-to-end-of-line-end> [
   {
     break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:address:duplex-list <- get *editor, top-of-screen:offset
+    top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
     undo:address:address:list <- get-address *editor, undo:offset
     op:address:operation <- new operation:type
-    deleted-until:address:duplex-list <- next-duplex *before-cursor
+    deleted-until:address:duplex-list:character <- next-duplex *before-cursor
     *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce
     editor <- add-operation editor, op
     +done-adding-delete-operation
@@ -2036,15 +2036,15 @@ def]
 ]
 
 after <delete-to-start-of-line-begin> [
-  top-before:address:duplex-list <- get *editor, top-of-screen:offset
+  top-before:address:duplex-list:character <- get *editor, top-of-screen:offset
 ]
 before <delete-to-start-of-line-end> [
   {
     break-unless deleted-cells  # delete failed; don't add an undo operation
-    top-after:address:duplex-list <- get *editor, top-of-screen:offset
+    top-after:address:duplex-list:character <- get *editor, top-of-screen:offset
     undo:address:address:list <- get-address *editor, undo:offset
     op:address:operation <- new operation:type
-    deleted-until:address:duplex-list <- next-duplex *before-cursor
+    deleted-until:address:duplex-list:character <- next-duplex *before-cursor
     *op <- merge 2/delete-operation, save-row/before, save-column/before, top-before, *cursor-row/after, *cursor-column/after, top-after, deleted-cells/deleted, *before-cursor/delete-from, deleted-until, 0/never-coalesce
     editor <- add-operation editor, op
     +done-adding-delete-operation