diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:45:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 19:56:28 -0700 |
commit | f918675c8b11adb80a83000a3a984e4ff3bdcf1b (patch) | |
tree | 2472316e3bf536e0bad76751c5f3504d029b8215 /html/edit | |
parent | af7349d50c40e0604c9bb1e9a50aa1c3c0d407d8 (diff) | |
download | mu-f918675c8b11adb80a83000a3a984e4ff3bdcf1b.tar.gz |
3569
Update syntax highlighting to not color numeric locations like literals.
Diffstat (limited to 'html/edit')
-rw-r--r-- | html/edit/001-editor.mu.html | 232 | ||||
-rw-r--r-- | html/edit/002-typing.mu.html | 596 | ||||
-rw-r--r-- | html/edit/003-shortcuts.mu.html | 1418 | ||||
-rw-r--r-- | html/edit/004-programming-environment.mu.html | 414 | ||||
-rw-r--r-- | html/edit/005-sandbox.mu.html | 474 | ||||
-rw-r--r-- | html/edit/006-sandbox-copy.mu.html | 90 | ||||
-rw-r--r-- | html/edit/007-sandbox-delete.mu.html | 84 | ||||
-rw-r--r-- | html/edit/008-sandbox-edit.mu.html | 64 | ||||
-rw-r--r-- | html/edit/009-sandbox-test.mu.html | 80 | ||||
-rw-r--r-- | html/edit/010-sandbox-trace.mu.html | 90 | ||||
-rw-r--r-- | html/edit/011-errors.mu.html | 132 | ||||
-rw-r--r-- | html/edit/012-editor-undo.mu.html | 888 |
12 files changed, 2281 insertions, 2281 deletions
diff --git a/html/edit/001-editor.mu.html b/html/edit/001-editor.mu.html index a0044e7a..01b0bf0a 100644 --- a/html/edit/001-editor.mu.html +++ b/html/edit/001-editor.mu.html @@ -87,22 +87,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># no clipping of bounds</span> - right<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> - result<span class="Special"> <- </span>new <span class="Constant">editor:type</span> + right <span class="Special"><-</span> subtract right,<span class="Constant"> 1</span> + result <span class="Special"><-</span> new <span class="Constant">editor:type</span> <span class="Comment"># initialize screen-related fields</span> - *result<span class="Special"> <- </span>put *result, <span class="Constant">left:offset</span>, left - *result<span class="Special"> <- </span>put *result, <span class="Constant">right:offset</span>, right + *result <span class="Special"><-</span> put *result, <span class="Constant">left:offset</span>, left + *result <span class="Special"><-</span> put *result, <span class="Constant">right:offset</span>, right <span class="Comment"># initialize cursor coordinates</span> - *result<span class="Special"> <- </span>put *result, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1/top</span> - *result<span class="Special"> <- </span>put *result, <span class="Constant">cursor-column:offset</span>, left + *result <span class="Special"><-</span> put *result, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1/top</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">cursor-column:offset</span>, left <span class="Comment"># initialize empty contents</span> - init:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - *result<span class="Special"> <- </span>put *result, <span class="Constant">data:offset</span>, init - *result<span class="Special"> <- </span>put *result, <span class="Constant">top-of-screen:offset</span>, init - *result<span class="Special"> <- </span>put *result, <span class="Constant">before-cursor:offset</span>, init - result<span class="Special"> <- </span>insert-text result, s + init:&:duplex-list:char <span class="Special"><-</span> push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">data:offset</span>, init + *result <span class="Special"><-</span> put *result, <span class="Constant">top-of-screen:offset</span>, init + *result <span class="Special"><-</span> put *result, <span class="Constant">before-cursor:offset</span>, init + result <span class="Special"><-</span> insert-text result, s <span class="Comment"># initial render to screen, just for some old tests</span> - _, _, screen, result<span class="Special"> <- </span>render screen, result + _, _, screen, result <span class="Special"><-</span> render screen, result <span class="Constant"> <editor-initialization></span> ] @@ -110,42 +110,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># early exit if text is empty</span> - <span class="muControl">return-unless</span> text, editor/same-as-ingredient:<span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *text - <span class="muControl">return-unless</span> len, editor/same-as-ingredient:<span class="Constant">0</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="muControl">return-unless</span> text, editor/same-as-ingredient:0 + len:num <span class="Special"><-</span> length *text + <span class="muControl">return-unless</span> len, editor/same-as-ingredient:0 + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Comment"># now we can start appending the rest, character by character</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal idx, len + done?:bool <span class="Special"><-</span> greater-or-equal idx, len <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *text, idx + c:char <span class="Special"><-</span> index *text, idx insert c, curr <span class="Comment"># next iter</span> - curr<span class="Special"> <- </span>next curr - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">return</span> editor/same-as-ingredient:<span class="Constant">0</span> + <span class="muControl">return</span> editor/same-as-ingredient:0 ] <span class="muScenario">scenario</span> editor-initializes-without-data [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">3/height</span> run [ - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">0/data</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> - <span class="Constant">2</span>:editor/<span class="Special">raw <- </span>copy *e + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">0/data</span>, screen:&:screen, <span class="Constant">2/left</span>, <span class="Constant">5/right</span> + 2:editor/<span class="Special">raw</span> <span class="Special"><-</span> copy *e ] memory-should-contain [ <span class="Comment"># 2 (data) <- just the § sentinel</span> <span class="Comment"># 3 (top of screen) <- the § sentinel</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># bottom-of-screen; null since text fits on screen</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># bottom-of-screen; null since text fits on screen</span> <span class="Comment"># 5 (before cursor) <- the § sentinel</span> - <span class="Constant">6</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># left</span> - <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># right (inclusive)</span> - <span class="Constant">8</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># bottom</span> - <span class="Constant">9</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">10</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 6</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># left</span> + <span class="Constant"> 7</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># right (inclusive)</span> + <span class="Constant"> 8</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># bottom</span> + <span class="Constant"> 9</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 10</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -160,102 +160,102 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render screen:&:screen, editor:&:editor<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> <span class="Comment"># traversing editor</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> - curr<span class="Special"> <- </span>next curr + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char <span class="Special"><-</span> copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr <span class="Special"><-</span> next curr <span class="Comment"># traversing screen</span> <span class="Constant"> +render-loop-initialization</span> - color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:num<span class="Special"> <- </span>copy left - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + color:num <span class="Special"><-</span> copy <span class="Constant">7/white</span> + row:num <span class="Special"><-</span> copy <span class="Constant">1/top</span> + column:num <span class="Special"><-</span> copy left + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># update editor.before-cursor</span> <span class="Comment"># Doing so at the start of each iteration ensures it stays one step behind</span> <span class="Comment"># the current character.</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - at-cursor?:bool<span class="Special"> <- </span>equal column, cursor-column + at-cursor?:bool <span class="Special"><-</span> equal column, cursor-column <span class="muControl">break-unless</span> at-cursor? - before-cursor<span class="Special"> <- </span>copy prev + before-cursor <span class="Special"><-</span> copy prev <span class="Delimiter">}</span> - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> <span class="Constant"> <character-c-received></span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># adjust cursor if necessary</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - left-of-cursor?:bool<span class="Special"> <- </span>lesser-than column, cursor-column + left-of-cursor?:bool <span class="Special"><-</span> lesser-than column, cursor-column <span class="muControl">break-unless</span> left-of-cursor? - cursor-column<span class="Special"> <- </span>copy column - before-cursor<span class="Special"> <- </span>prev curr + cursor-column <span class="Special"><-</span> copy column + before-cursor <span class="Special"><-</span> prev curr <span class="Delimiter">}</span> <span class="Comment"># clear rest of line in this window</span> clear-line-until screen, right <span class="Comment"># skip to next line</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span> <span class="Comment"># room for clicking on the cursor after it.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special"><-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Comment"># don't increment curr</span> <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr + *editor <span class="Special"><-</span> put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row - cursor-outside-line?:bool<span class="Special"> <- </span>lesser-or-equal column, cursor-column - before-cursor-on-same-line?:bool<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? - above-cursor-row?:bool<span class="Special"> <- </span>lesser-than row, cursor-row - before-cursor?:bool<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row + cursor-outside-line?:bool <span class="Special"><-</span> lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool <span class="Special"><-</span> and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool <span class="Special"><-</span> lesser-than row, cursor-row + before-cursor?:bool <span class="Special"><-</span> or before-cursor-on-same-line?, above-cursor-row? <span class="muControl">break-unless</span> before-cursor? - cursor-row<span class="Special"> <- </span>copy row - cursor-column<span class="Special"> <- </span>copy column - before-cursor<span class="Special"> <- </span>copy prev + cursor-row <span class="Special"><-</span> copy row + cursor-column <span class="Special"><-</span> copy column + before-cursor <span class="Special"><-</span> copy prev <span class="Delimiter">}</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">bottom:offset</span>, row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - <span class="muControl">return</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">bottom:offset</span>, row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + <span class="muControl">return</span> row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] <span class="muRecipe">def</span> clear-screen-from screen:&:screen, row:num, column:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ @@ -265,27 +265,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-if</span> screen clear-display-from row, column, left, right - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span> + <span class="muControl">return</span> screen/same-as-ingredient:0 <span class="Delimiter">}</span> <span class="Comment"># if not, go the slower route</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + screen <span class="Special"><-</span> move-cursor screen, row, column clear-line-until screen, right clear-rest-of-screen screen, row, left, right - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span> + <span class="muControl">return</span> screen/same-as-ingredient:0 ] <span class="muRecipe">def</span> clear-rest-of-screen screen:&:screen, row:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - screen-height:num<span class="Special"> <- </span>screen-height screen + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, left + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Delimiter">{</span> - at-bottom-of-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + at-bottom-of-screen?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> at-bottom-of-screen? - screen<span class="Special"> <- </span>move-cursor screen, row, left + screen <span class="Special"><-</span> move-cursor screen, row, left clear-line-until screen, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -294,7 +294,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] @@ -310,7 +310,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc]</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc]</span> new-editor s, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ @@ -324,7 +324,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> new-editor s, screen:&:screen, <span class="Constant">1/left</span>, <span class="Constant">5/right</span> ] @@ -340,7 +340,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc def]</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc def]</span> new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] screen-should-contain [ @@ -361,7 +361,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abcde]</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcde]</span> new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> ] <span class="Comment"># still wrap, even though the line would fit. We need room to click on the</span> @@ -384,9 +384,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -394,8 +394,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column</span> ] ] @@ -405,7 +405,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant"># de</span> <span class="Constant">f]</span> new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> @@ -434,48 +434,48 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><character-c-received></span> [ - color<span class="Special"> <- </span>get-color color, c + color <span class="Special"><-</span> get-color color, c ] <span class="Comment"># so far the previous color is all the information we need; that may change</span> <span class="muRecipe">def</span> get-color color:num, c:char<span class="muRecipe"> -> </span>color:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - color-is-white?:bool<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> + color-is-white?:bool <span class="Special"><-</span> equal color, <span class="Constant">7/white</span> <span class="Comment"># if color is white and next character is '#', switch color to blue</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> color-is-white? - starting-comment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">35/#</span> + starting-comment?:bool <span class="Special"><-</span> equal c, <span class="Constant">35/#</span> <span class="muControl">break-unless</span> starting-comment? - trace <span class="Constant">90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to blue]</span> - color<span class="Special"> <- </span>copy <span class="Constant">12/lightblue</span> + trace<span class="Constant"> 90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to blue]</span> + color <span class="Special"><-</span> copy <span class="Constant">12/lightblue</span> <span class="muControl">jump</span> <span class="Constant">+exit</span> <span class="Delimiter">}</span> <span class="Comment"># if color is blue and next character is newline, switch color to white</span> <span class="Delimiter">{</span> - color-is-blue?:bool<span class="Special"> <- </span>equal color, <span class="Constant">12/lightblue</span> + color-is-blue?:bool <span class="Special"><-</span> equal color, <span class="Constant">12/lightblue</span> <span class="muControl">break-unless</span> color-is-blue? - ending-comment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + ending-comment?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> ending-comment? - trace <span class="Constant">90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to white]</span> - color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + trace<span class="Constant"> 90</span>, <span class="Constant">[app]</span>, <span class="Constant">[switch color back to white]</span> + color <span class="Special"><-</span> copy <span class="Constant">7/white</span> <span class="muControl">jump</span> <span class="Constant">+exit</span> <span class="Delimiter">}</span> <span class="Comment"># if color is white (no comments) and next character is '<', switch color to red</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> color-is-white? - starting-assignment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">60/<</span> + starting-assignment?:bool <span class="Special"><-</span> equal c, <span class="Constant">60/<</span> <span class="muControl">break-unless</span> starting-assignment? - color<span class="Special"> <- </span>copy <span class="Constant">1/red</span> + color <span class="Special"><-</span> copy <span class="Constant">1/red</span> <span class="muControl">jump</span> <span class="Constant">+exit</span> <span class="Delimiter">}</span> <span class="Comment"># if color is red and next character is space, switch color to white</span> <span class="Delimiter">{</span> - color-is-red?:bool<span class="Special"> <- </span>equal color, <span class="Constant">1/red</span> + color-is-red?:bool <span class="Special"><-</span> equal color, <span class="Constant">1/red</span> <span class="muControl">break-unless</span> color-is-red? - ending-assignment?:bool<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> + ending-assignment?:bool <span class="Special"><-</span> equal c, <span class="Constant">32/space</span> <span class="muControl">break-unless</span> ending-assignment? - color<span class="Special"> <- </span>copy <span class="Constant">7/white</span> + color <span class="Special"><-</span> copy <span class="Constant">7/white</span> <span class="muControl">jump</span> <span class="Constant">+exit</span> <span class="Delimiter">}</span> <span class="Comment"># otherwise no change</span> @@ -487,7 +487,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">8/width</span>, <span class="Constant">5/height</span> run [ - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d <- e</span> <span class="Constant">f]</span> new-editor s, screen:&:screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 325e7f6e..dbca61b2 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -41,7 +41,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console - editor:&:editor<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> + editor:&:editor <span class="Special"><-</span> new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> editor-event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, editor close-console ] @@ -52,15 +52,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span> <span class="Constant"> +next-event</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - e:event, found?:bool, quit?:bool, console<span class="Special"> <- </span>read-event console + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column + e:event, found?:bool, quit?:bool, console <span class="Special"><-</span> read-event console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? <span class="Comment"># only in tests</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> <span class="Comment"># 'touch' event</span> - t:touch-event, is-touch?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool <span class="Special"><-</span> maybe-convert e, <span class="Constant">touch:variant</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-touch? move-cursor-in-editor screen, editor, t @@ -69,10 +69,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># keyboard events</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-touch? - screen, editor, go-render?:bool<span class="Special"> <- </span>handle-keyboard-event screen, editor, e + screen, editor, go-render?:bool <span class="Special"><-</span> handle-keyboard-event screen, editor, e <span class="Delimiter">{</span> <span class="muControl">break-unless</span> go-render? - screen<span class="Special"> <- </span>editor-render screen, editor + screen <span class="Special"><-</span> editor-render screen, editor <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -84,19 +84,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor, <span class="Constant">0/false</span> - click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + click-row:num <span class="Special"><-</span> get t, <span class="Constant">row:offset</span> <span class="muControl">return-unless</span> click-row, <span class="Constant">0/false</span> <span class="Comment"># ignore clicks on 'menu'</span> - click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - too-far-left?:bool<span class="Special"> <- </span>lesser-than click-column, left + click-column:num <span class="Special"><-</span> get t, <span class="Constant">column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + too-far-left?:bool <span class="Special"><-</span> lesser-than click-column, left <span class="muControl">return-if</span> too-far-left?, <span class="Constant">0/false</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - too-far-right?:bool<span class="Special"> <- </span>greater-than click-column, right + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + too-far-right?:bool <span class="Special"><-</span> greater-than click-column, right <span class="muControl">return-if</span> too-far-right?, <span class="Constant">0/false</span> <span class="Comment"># position cursor</span> <span class="Constant"> <move-cursor-begin></span> - editor<span class="Special"> <- </span>snap-cursor screen, editor, click-row, click-column - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + editor <span class="Special"><-</span> snap-cursor screen, editor, click-row, click-column + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> <span class="Comment"># gain focus</span> <span class="muControl">return</span> <span class="Constant">1/true</span> @@ -109,88 +109,88 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># count newlines until screen row</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> - curr<span class="Special"> <- </span>next curr - row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:num<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, target-row - cursor-row:num<span class="Special"> <- </span>copy target-row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, target-column - cursor-column:num<span class="Special"> <- </span>copy target-column - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char <span class="Special"><-</span> copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr <span class="Special"><-</span> next curr + row:num <span class="Special"><-</span> copy <span class="Constant">1/top</span> + column:num <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, target-row + cursor-row:num <span class="Special"><-</span> copy target-row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, target-column + cursor-column:num <span class="Special"><-</span> copy target-column + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># update editor.before-cursor</span> <span class="Comment"># Doing so at the start of each iteration ensures it stays one step behind</span> <span class="Comment"># the current character.</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - at-cursor?:bool<span class="Special"> <- </span>equal column, cursor-column + at-cursor?:bool <span class="Special"><-</span> equal column, cursor-column <span class="muControl">break-unless</span> at-cursor? - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># adjust cursor if necessary</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - left-of-cursor?:bool<span class="Special"> <- </span>lesser-than column, cursor-column + left-of-cursor?:bool <span class="Special"><-</span> lesser-than column, cursor-column <span class="muControl">break-unless</span> left-of-cursor? - cursor-column<span class="Special"> <- </span>copy column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special"><-</span> copy column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> <span class="Comment"># skip to next line</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span> <span class="Comment"># room for clicking on the cursor after it.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Comment"># don't increment curr/prev</span> <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row - cursor-outside-line?:bool<span class="Special"> <- </span>lesser-or-equal column, cursor-column - before-cursor-on-same-line?:bool<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? - above-cursor-row?:bool<span class="Special"> <- </span>lesser-than row, cursor-row - before-cursor?:bool<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row + cursor-outside-line?:bool <span class="Special"><-</span> lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool <span class="Special"><-</span> and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool <span class="Special"><-</span> lesser-than row, cursor-row + before-cursor?:bool <span class="Special"><-</span> or before-cursor-on-same-line?, above-cursor-row? <span class="muControl">break-unless</span> before-cursor? - cursor-row<span class="Special"> <- </span>copy row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special"><-</span> copy row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> ] @@ -199,105 +199,105 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> handle-keyboard-event screen:&:screen, editor:&:editor, e:event<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> editor - screen-width:num<span class="Special"> <- </span>screen-width screen - screen-height:num<span class="Special"> <- </span>screen-height screen - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - save-row:num<span class="Special"> <- </span>copy cursor-row - save-column:num<span class="Special"> <- </span>copy cursor-column + screen-width:num <span class="Special"><-</span> screen-width screen + screen-height:num <span class="Special"><-</span> screen-height screen + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + save-row:num <span class="Special"><-</span> copy cursor-row + save-column:num <span class="Special"><-</span> copy cursor-column <span class="Comment"># character</span> <span class="Delimiter">{</span> - c:char, is-unicode?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool <span class="Special"><-</span> maybe-convert e, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[handle-keyboard-event: special character]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[handle-keyboard-event: special character]</span> <span class="Comment"># exceptions for special characters go here</span> <span class="Constant"> <handle-special-character></span> <span class="Comment"># ignore any other special characters</span> - regular-character?:bool<span class="Special"> <- </span>greater-or-equal c, <span class="Constant">32/space</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + regular-character?:bool <span class="Special"><-</span> greater-or-equal c, <span class="Constant">32/space</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> regular-character? <span class="Comment"># otherwise type it in</span> <span class="Constant"> <insert-character-begin></span> - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, c, screen + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, c, screen <span class="Constant"> <insert-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># special key to modify the text or move the cursor</span> - k:num, is-keycode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">keycode:variant</span> assert is-keycode?, <span class="Constant">[event was of unknown type; neither keyboard nor mouse]</span> <span class="Comment"># handlers for each special key will go here</span> <span class="Constant"> <handle-special-key></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> ] <span class="muRecipe">def</span> insert-at-cursor editor:&:editor, c:char, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> insert c, before-cursor - before-cursor<span class="Special"> <- </span>next before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - save-row:num<span class="Special"> <- </span>copy cursor-row - save-column:num<span class="Special"> <- </span>copy cursor-column - screen-width:num<span class="Special"> <- </span>screen-width screen - screen-height:num<span class="Special"> <- </span>screen-height screen + before-cursor <span class="Special"><-</span> next before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + save-row:num <span class="Special"><-</span> copy cursor-row + save-column:num <span class="Special"><-</span> copy cursor-column + screen-width:num <span class="Special"><-</span> screen-width screen + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># occasionally we'll need to mess with the cursor</span> <span class="Constant"> <insert-character-special-case></span> <span class="Comment"># but mostly we'll just move the cursor right</span> - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Delimiter">{</span> <span class="Comment"># at end of all text? no need to scroll? just print the character and leave</span> - at-end?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0/null</span> + at-end?:bool <span class="Special"><-</span> equal next, <span class="Constant">0/null</span> <span class="muControl">break-unless</span> at-end? - bottom:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> - at-bottom?:bool<span class="Special"> <- </span>equal save-row, bottom - at-right?:bool<span class="Special"> <- </span>equal save-column, right - overflow?:bool<span class="Special"> <- </span>and at-bottom?, at-right? + bottom:num <span class="Special"><-</span> subtract screen-height,<span class="Constant"> 1</span> + at-bottom?:bool <span class="Special"><-</span> equal save-row, bottom + at-right?:bool <span class="Special"><-</span> equal save-column, right + overflow?:bool <span class="Special"><-</span> and at-bottom?, at-right? <span class="muControl">break-if</span> overflow? move-cursor screen, save-row, save-column print screen, c - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># not at right margin? print the character and rest of line</span> <span class="muControl">break-unless</span> next - at-right?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, screen-width + at-right?:bool <span class="Special"><-</span> greater-or-equal cursor-column, screen-width <span class="muControl">break-if</span> at-right? - curr:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor + curr:&:duplex-list:char <span class="Special"><-</span> copy before-cursor move-cursor screen, save-row, save-column - curr-column:num<span class="Special"> <- </span>copy save-column + curr-column:num <span class="Special"><-</span> copy save-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - at-right?:bool<span class="Special"> <- </span>greater-than curr-column, right + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special"><-</span> greater-than curr-column, right <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? print screen, currc - curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> <- </span>next curr + curr-column <span class="Special"><-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> ] @@ -305,20 +305,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> editor-render screen:&:screen, editor:&:editor<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - row:num, column:num<span class="Special"> <- </span>render screen, editor + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + row:num, column:num <span class="Special"><-</span> render screen, editor clear-line-until screen, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console <span class="Constant">[]</span> run [ @@ -335,16 +335,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> <span class="Comment"># on the 'b'</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> <span class="Comment"># on the 'b'</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -353,91 +353,91 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor is at row 0..</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># ..and column 1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor is at row 0..</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># ..and column 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 7</span> <span class="Comment"># last line, to the right of text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 7</span> <span class="Comment"># interior line, to the right of text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 7</span> <span class="Comment"># below text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor occupies only left half of screen</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on right half of screen</span> - left-click <span class="Constant">3</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 8</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -446,38 +446,38 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># no change to cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># ..or column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># no change to cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># ..or column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on first, 'menu' row</span> - left-click <span class="Constant">0</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 0</span>,<span class="Constant"> 3</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -492,19 +492,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌ .</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ type <span class="Constant">[0]</span> - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[d]</span> ] run [ @@ -516,17 +516,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> + check-trace-count-for-label<span class="Constant"> 7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of last line</span> type <span class="Constant">[d]</span> ] run [ @@ -538,19 +538,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of non-last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of non-last line</span> type <span class="Constant">[e]</span> ] run [ @@ -563,17 +563,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[d]</span> ] run [ @@ -585,19 +585,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[e]</span> ] run [ @@ -610,19 +610,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[ef]</span> ] run [ @@ -635,13 +635,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e assume-console [ type <span class="Constant">[01]</span> @@ -662,7 +662,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type a letter</span> assume-console [ @@ -700,24 +700,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type more text at the start</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> type <span class="Constant">[abc]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># but line is wrapped</span> screen-should-contain [ @@ -735,47 +735,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if either:</span> <span class="Comment"># a) we're at the end of the line and at the column of the wrap indicator, or</span> <span class="Comment"># b) we're not at end of line and just before the column of the wrap indicator</span> - wrap-column:num<span class="Special"> <- </span>copy right - before-wrap-column:num<span class="Special"> <- </span>subtract wrap-column, <span class="Constant">1</span> - at-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, wrap-column - just-before-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, before-wrap-column - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + wrap-column:num <span class="Special"><-</span> copy right + before-wrap-column:num <span class="Special"><-</span> subtract wrap-column,<span class="Constant"> 1</span> + at-wrap?:bool <span class="Special"><-</span> greater-or-equal cursor-column, wrap-column + just-before-wrap?:bool <span class="Special"><-</span> greater-or-equal cursor-column, before-wrap-column + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Comment"># at end of line? next == 0 || next.value == 10/newline</span> - at-end-of-line?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0</span> + at-end-of-line?:bool <span class="Special"><-</span> equal next,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - next-character:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char <span class="Special"><-</span> get *next, <span class="Constant">value:offset</span> + at-end-of-line? <span class="Special"><-</span> equal next-character, <span class="Constant">10/newline</span> <span class="Delimiter">}</span> <span class="Comment"># break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?))</span> - move-cursor-to-next-line?:bool<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + move-cursor-to-next-line?:bool <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> <- </span>copy just-before-wrap? + move-cursor-to-next-line? <span class="Special"><-</span> copy just-before-wrap? <span class="Comment"># if we're moving the cursor because it's in the middle of a wrapping</span> <span class="Comment"># line, adjust it to left-most column</span> - potential-new-cursor-column:num<span class="Special"> <- </span>copy left + potential-new-cursor-column:num <span class="Special"><-</span> copy left <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> <- </span>copy at-wrap? + move-cursor-to-next-line? <span class="Special"><-</span> copy at-wrap? <span class="Comment"># if we're moving the cursor because it's at the end of a wrapping line,</span> <span class="Comment"># adjust it to one past the left-most column to make room for the</span> <span class="Comment"># newly-inserted wrap-indicator</span> - potential-new-cursor-column:num<span class="Special"> <- </span>add left, <span class="Constant">1/make-room-for-wrap-indicator</span> + potential-new-cursor-column:num <span class="Special"><-</span> add left, <span class="Constant">1/make-room-for-wrap-indicator</span> <span class="Delimiter">}</span> <span class="muControl">break-unless</span> move-cursor-to-next-line? - cursor-column<span class="Special"> <- </span>copy potential-new-cursor-column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy potential-new-cursor-column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Comment"># if we're out of the screen, scroll down</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -783,15 +783,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> <span class="Comment"># right before the wrap icon</span> type <span class="Constant">[f]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -801,8 +801,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column</span> ] ] @@ -810,9 +810,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># create an editor containing two lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> @@ -820,7 +820,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> <span class="Comment"># at end of first line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> <span class="Comment"># at end of first line</span> type <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> ] run [ @@ -838,15 +838,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[01]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -856,8 +856,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] ] @@ -868,13 +868,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><editor-initialization></span> [ - *result<span class="Special"> <- </span>put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -893,12 +893,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Constant"> <insert-enter-begin></span> - editor<span class="Special"> <- </span>insert-new-line-and-indent editor, screen + editor <span class="Special"><-</span> insert-new-line-and-indent editor, screen <span class="Constant"> <insert-enter-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -906,41 +906,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> insert-new-line-and-indent editor:&:editor, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># insert newline</span> insert <span class="Constant">10/newline</span>, before-cursor - before-cursor<span class="Special"> <- </span>next before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> next before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># maybe scroll</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Comment"># indent if necessary</span> - indent?:bool<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> + indent?:bool <span class="Special"><-</span> get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">return-unless</span> indent? - d:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor - indent:num<span class="Special"> <- </span>line-indent end-of-previous-line, d - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + d:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:&:duplex-list:char <span class="Special"><-</span> prev before-cursor + indent:num <span class="Special"><-</span> line-indent end-of-previous-line, d + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - indent-done?:bool<span class="Special"> <- </span>greater-or-equal i, indent + indent-done?:bool <span class="Special"><-</span> greater-or-equal i, indent <span class="muControl">break-if</span> indent-done? - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -950,28 +950,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> line-indent curr:&:duplex-list:char, start:&:duplex-list:char<span class="muRecipe"> -> </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + result:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="muControl">return-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> - curr<span class="Special"> <- </span>prev curr + curr <span class="Special"><-</span> prev curr <span class="muControl">break-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">break-if</span> at-start? - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment"># if c is a space, increment result</span> - is-space?:bool<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> + is-space?:bool <span class="Special"><-</span> equal c, <span class="Constant">32/space</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-space? - result<span class="Special"> <- </span>add result, <span class="Constant">1</span> + result <span class="Special"><-</span> add result,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># if c is not a space, reset result</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-space? - result<span class="Special"> <- </span>copy <span class="Constant">0</span> + result <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -980,7 +980,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -1000,7 +1000,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1027,70 +1027,70 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> type [ ] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column (indented)</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column (indented)</span> ] ] <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> - press <span class="Constant">65507</span> <span class="Comment"># start paste</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> + press<span class="Constant"> 65507</span> <span class="Comment"># start paste</span> press enter - press <span class="Constant">65506</span> <span class="Comment"># end paste</span> + press<span class="Constant"> 65506</span> <span class="Comment"># end paste</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column (not indented)</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column (not indented)</span> ] ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-start?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65507/paste-start</span> + paste-start?:bool <span class="Special"><-</span> equal k, <span class="Constant">65507/paste-start</span> <span class="muControl">break-unless</span> paste-start? - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-end?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65506/paste-end</span> + paste-end?:bool <span class="Special"><-</span> equal k, <span class="Constant">65506/paste-end</span> <span class="muControl">break-unless</span> paste-end? - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1100,28 +1100,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> draw-horizontal screen:&:screen, row:num, x:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:char, style-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? - style<span class="Special"> <- </span>copy <span class="Constant">9472/horizontal</span> + style <span class="Special"><-</span> copy <span class="Constant">9472/horizontal</span> <span class="Delimiter">}</span> - color:num, color-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> <span class="muControl">break-if</span> color-found? - color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> + color <span class="Special"><-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - bg-color:num, bg-color-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + bg-color:num, bg-color-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> bg-color-found? - bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> + bg-color <span class="Special"><-</span> copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>move-cursor screen, row, x + screen <span class="Special"><-</span> move-cursor screen, row, x <span class="Delimiter">{</span> - continue?:bool<span class="Special"> <- </span>lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> + continue?:bool <span class="Special"><-</span> lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> <span class="muControl">break-unless</span> continue? print screen, style, color, bg-color - x<span class="Special"> <- </span>add x, <span class="Constant">1</span> + x <span class="Special"><-</span> add x,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] diff --git a/html/edit/003-shortcuts.mu.html b/html/edit/003-shortcuts.mu.html index 2dc6965f..cc243281 100644 --- a/html/edit/003-shortcuts.mu.html +++ b/html/edit/003-shortcuts.mu.html @@ -42,9 +42,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press tab ] @@ -60,13 +60,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - tab?:bool<span class="Special"> <- </span>equal c, <span class="Constant">9/tab</span> + tab?:bool <span class="Special"><-</span> equal c, <span class="Constant">9/tab</span> <span class="muControl">break-unless</span> tab? <span class="Constant"> <insert-character-begin></span> - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen <span class="Constant"> <insert-character-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -76,17 +76,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-backspace-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press backspace ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -95,18 +95,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-previous-character?:bool<span class="Special"> <- </span>equal c, <span class="Constant">8/backspace</span> + delete-previous-character?:bool <span class="Special"><-</span> equal c, <span class="Constant">8/backspace</span> <span class="muControl">break-unless</span> delete-previous-character? <span class="Constant"> <backspace-character-begin></span> - editor, screen, go-render?:bool, backspaced-cell:&:duplex-list:char<span class="Special"> <- </span>delete-before-cursor editor, screen + editor, screen, go-render?:bool, backspaced-cell:&:duplex-list:char <span class="Special"><-</span> delete-before-cursor editor, screen <span class="Constant"> <backspace-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -118,114 +118,114 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> delete-before-cursor editor:&:editor, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool, backspaced-cell:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + data:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># if at start of text (before-cursor at § sentinel), return</span> - prev:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor - go-render?, backspaced-cell<span class="Special"> <- </span>copy <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> + prev:&:duplex-list:char <span class="Special"><-</span> prev before-cursor + go-render?, backspaced-cell <span class="Special"><-</span> copy <span class="Constant">0/no-more-render</span>, <span class="Constant">0/nothing-deleted</span> <span class="muControl">return-unless</span> prev - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[delete-before-cursor]</span> - original-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - editor, scroll?:bool<span class="Special"> <- </span>move-cursor-coordinates-left editor - backspaced-cell:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor - data<span class="Special"> <- </span>remove before-cursor, data <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/before-cursor</span> - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[delete-before-cursor]</span> + original-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + editor, scroll?:bool <span class="Special"><-</span> move-cursor-coordinates-left editor + backspaced-cell:&:duplex-list:char <span class="Special"><-</span> copy before-cursor + data <span class="Special"><-</span> remove before-cursor, data <span class="Comment"># will also neatly trim next/prev pointers in backspaced-cell/before-cursor</span> + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> scroll? - screen-width:num<span class="Special"> <- </span>screen-width screen - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + screen-width:num <span class="Special"><-</span> screen-width screen + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># did we just backspace over a newline?</span> - same-row?:bool<span class="Special"> <- </span>equal cursor-row, original-row - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + same-row?:bool <span class="Special"><-</span> equal cursor-row, original-row + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-unless</span> same-row? - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - curr-column:num<span class="Special"> <- </span>copy cursor-column + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> next before-cursor + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column + curr-column:num <span class="Special"><-</span> copy cursor-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:bool<span class="Special"> <- </span>greater-or-equal curr-column, right - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special"><-</span> greater-or-equal curr-column, right + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - screen<span class="Special"> <- </span>print screen, currc - curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> <- </span>next curr + screen <span class="Special"><-</span> print screen, currc + curr-column <span class="Special"><-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> - screen<span class="Special"> <- </span>print screen, space - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> + screen <span class="Special"><-</span> print screen, space + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] <span class="muRecipe">def</span> move-cursor-coordinates-left editor:&:editor<span class="muRecipe"> -> </span>editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> <span class="Comment"># if not at left margin, move one character left</span> <span class="Delimiter">{</span> - at-left-margin?:bool<span class="Special"> <- </span>equal cursor-column, left + at-left-margin?:bool <span class="Special"><-</span> equal cursor-column, left <span class="muControl">break-if</span> at-left-margin? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[decrementing cursor column]</span> - cursor-column<span class="Special"> <- </span>subtract cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[decrementing cursor column]</span> + cursor-column <span class="Special"><-</span> subtract cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># if at left margin, we must move to previous row:</span> - top-of-screen?:bool<span class="Special"> <- </span>equal cursor-row, <span class="Constant">1</span> <span class="Comment"># exclude menu bar</span> - go-render?:bool<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + top-of-screen?:bool <span class="Special"><-</span> equal cursor-row,<span class="Constant"> 1</span> <span class="Comment"># exclude menu bar</span> + go-render?:bool <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> top-of-screen? - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> top-of-screen? <span class="Constant"> <scroll-up></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># case 1: if previous character was newline, figure out how long the previous line is</span> - previous-character:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - previous-character-is-newline?:bool<span class="Special"> <- </span>equal previous-character, <span class="Constant">10/newline</span> + previous-character:char <span class="Special"><-</span> get *before-cursor, <span class="Constant">value:offset</span> + previous-character-is-newline?:bool <span class="Special"><-</span> equal previous-character, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> previous-character-is-newline? <span class="Comment"># compute length of previous line</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[switching to previous line]</span> - d:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-line:num<span class="Special"> <- </span>previous-line-length before-cursor, d - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - width:num<span class="Special"> <- </span>subtract right, left - wrap?:bool<span class="Special"> <- </span>greater-than end-of-line, width + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[switching to previous line]</span> + d:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + end-of-line:num <span class="Special"><-</span> previous-line-length before-cursor, d + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + width:num <span class="Special"><-</span> subtract right, left + wrap?:bool <span class="Special"><-</span> greater-than end-of-line, width <span class="Delimiter">{</span> <span class="muControl">break-unless</span> wrap? - _, column-offset:num<span class="Special"> <- </span>divide-with-remainder end-of-line, width - cursor-column<span class="Special"> <- </span>add left, column-offset - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + _, column-offset:num <span class="Special"><-</span> divide-with-remainder end-of-line, width + cursor-column <span class="Special"><-</span> add left, column-offset + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> wrap? - cursor-column<span class="Special"> <- </span>add left, end-of-line - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-column <span class="Special"><-</span> add left, end-of-line + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">}</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># case 2: if previous-character was not newline, we're just at a wrapped line</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[wrapping to previous line]</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - cursor-column<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> <span class="Comment"># leave room for wrap icon</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[wrapping to previous line]</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + cursor-column <span class="Special"><-</span> subtract right,<span class="Constant"> 1</span> <span class="Comment"># leave room for wrap icon</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column ] <span class="Comment"># takes a pointer 'curr' into the doubly-linked list and its sentinel, counts</span> @@ -233,19 +233,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> previous-line-length curr:&:duplex-list:char, start:&:duplex-list:char<span class="muRecipe"> -> </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + result:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="muControl">return-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> - curr<span class="Special"> <- </span>prev curr + curr <span class="Special"><-</span> prev curr <span class="muControl">break-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">break-if</span> at-start? - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - result<span class="Special"> <- </span>add result, <span class="Constant">1</span> + result <span class="Special"><-</span> add result,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -254,17 +254,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># just one character in final line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant">cd]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> <span class="Comment"># cursor at only character in final line</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> <span class="Comment"># cursor at only character in final line</span> press backspace ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -273,8 +273,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] ] @@ -282,14 +282,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two long-ish but non-wrapping lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc def</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc def</span> <span class="Constant">ghi jkl]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor at the start of the second and hit backspace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press backspace ] run [ @@ -309,7 +309,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor in part of the screen with a long line</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc def ghij]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc def ghij]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">8/right</span> editor-render screen, e <span class="Comment"># confirm that it wraps</span> screen-should-contain [ @@ -321,7 +321,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> $clear-trace</span> <span class="Comment"># position the cursor somewhere in the middle of the top screen line and hit backspace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> press backspace ] run [ @@ -342,7 +342,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-delete-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -357,7 +357,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of original line to overwrite</span> <span class="Constant"> $clear-trace</span> assume-console [ press delete @@ -371,15 +371,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length to overwrite</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length to overwrite</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - delete-next-character?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65522/delete</span> + delete-next-character?:bool <span class="Special"><-</span> equal k, <span class="Constant">65522/delete</span> <span class="muControl">break-unless</span> delete-next-character? <span class="Constant"> <delete-character-begin></span> - editor, screen, go-render?:bool, deleted-cell:&:duplex-list:char<span class="Special"> <- </span>delete-at-cursor editor, screen + editor, screen, go-render?:bool, deleted-cell:&:duplex-list:char <span class="Special"><-</span> delete-at-cursor editor, screen <span class="Constant"> <delete-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -388,42 +388,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> delete-at-cursor editor:&:editor, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool, deleted-cell:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - data:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - deleted-cell:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + data:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + deleted-cell:&:duplex-list:char <span class="Special"><-</span> next before-cursor + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> deleted-cell - currc:char<span class="Special"> <- </span>get *deleted-cell, <span class="Constant">value:offset</span> - data<span class="Special"> <- </span>remove deleted-cell, data - deleted-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + currc:char <span class="Special"><-</span> get *deleted-cell, <span class="Constant">value:offset</span> + data <span class="Special"><-</span> remove deleted-cell, data + deleted-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> deleted-newline? <span class="Comment"># wasn't a newline? render rest of line</span> - curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor <span class="Comment"># refresh after remove above</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - curr-column:num<span class="Special"> <- </span>copy cursor-column - screen-width:num<span class="Special"> <- </span>screen-width screen + curr:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Comment"># refresh after remove above</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column + curr-column:num <span class="Special"><-</span> copy cursor-column + screen-width:num <span class="Special"><-</span> screen-width screen <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - at-right?:bool<span class="Special"> <- </span>greater-or-equal curr-column, screen-width - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special"><-</span> greater-or-equal curr-column, screen-width + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - screen<span class="Special"> <- </span>print screen, currc - curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> <- </span>next curr + screen <span class="Special"><-</span> print screen, currc + curr-column <span class="Special"><-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># we're guaranteed not to be at the right margin</span> - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> - screen<span class="Special"> <- </span>print screen, space - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> + screen <span class="Special"><-</span> print screen, space + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] <span class="Comment"># right arrow</span> @@ -431,7 +431,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-right-with-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -447,23 +447,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 0 and following characters</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 0 and following characters</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-next-character?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65514/right-arrow</span> + move-to-next-character?:bool <span class="Special"><-</span> equal k, <span class="Constant">65514/right-arrow</span> <span class="muControl">break-unless</span> move-to-next-character? <span class="Comment"># if not at end of text</span> - next-cursor:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + next-cursor:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="muControl">break-unless</span> next-cursor <span class="Comment"># scan to next character</span> <span class="Constant"> <move-cursor-begin></span> - before-cursor<span class="Special"> <- </span>copy next-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - editor, go-render?:bool<span class="Special"> <- </span>move-cursor-coordinates-right editor, screen-height - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">2/right-arrow</span> + before-cursor <span class="Special"><-</span> copy next-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + editor, go-render?:bool <span class="Special"><-</span> move-cursor-coordinates-right editor, screen-height + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">2/right-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -472,65 +472,65 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> move-cursor-coordinates-right editor:&:editor, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> <span class="Comment"># if crossed a newline, move cursor to start of next row</span> <span class="Delimiter">{</span> - old-cursor-character:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - was-at-newline?:bool<span class="Special"> <- </span>equal old-cursor-character, <span class="Constant">10/newline</span> + old-cursor-character:char <span class="Special"><-</span> get *before-cursor, <span class="Constant">value:offset</span> + was-at-newline?:bool <span class="Special"><-</span> equal old-cursor-character, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> was-at-newline? - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> below-screen? <span class="Constant"> <scroll-down></span> - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># if the line wraps, move cursor to start of next row</span> <span class="Delimiter">{</span> <span class="Comment"># if we're at the column just before the wrap indicator</span> - wrap-column:num<span class="Special"> <- </span>subtract right, <span class="Constant">1</span> - at-wrap?:bool<span class="Special"> <- </span>equal cursor-column, wrap-column + wrap-column:num <span class="Special"><-</span> subtract right,<span class="Constant"> 1</span> + at-wrap?:bool <span class="Special"><-</span> equal cursor-column, wrap-column <span class="muControl">break-unless</span> at-wrap? <span class="Comment"># and if next character isn't newline</span> - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="muControl">break-unless</span> next - next-character:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - newline?:bool<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char <span class="Special"><-</span> get *next, <span class="Constant">value:offset</span> + newline?:bool <span class="Special"><-</span> equal next-character, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> newline? - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> - <span class="muControl">return-unless</span> below-screen?, editor/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/no-more-render</span> + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal</span> + <span class="muControl">return-unless</span> below-screen?, editor/same-as-ingredient:0, <span class="Constant">0/no-more-render</span> <span class="Constant"> <scroll-down></span> - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># otherwise move cursor one character right</span> - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type right-arrow a few times to get to start of second line</span> @@ -543,7 +543,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># type something and ensure it goes where it should</span> assume-console [ type <span class="Constant">[0]</span> @@ -558,15 +558,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length of second line</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> <span class="Comment"># new length of second line</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ press right-arrow @@ -590,17 +590,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -610,32 +610,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># line just barely wrapping</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at last character before wrap and hit right-arrow</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># now hit right arrow again</span> assume-console [ @@ -643,30 +643,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-wrapped-line-with-right-arrow-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">6/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -676,23 +676,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-next-line-with-right-arrow-at-end-of-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># move to end of line, press right-arrow, type a character</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press right-arrow type <span class="Constant">[0]</span> ] @@ -707,7 +707,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># todo: ctrl-right: next word-end</span> @@ -717,11 +717,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-left-with-key [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -734,23 +734,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-previous-character?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65515/left-arrow</span> + move-to-previous-character?:bool <span class="Special"><-</span> equal k, <span class="Constant">65515/left-arrow</span> <span class="muControl">break-unless</span> move-to-previous-character? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[left arrow]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[left arrow]</span> <span class="Comment"># if not at start of text (before-cursor at § sentinel)</span> - prev:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + prev:&:duplex-list:char <span class="Special"><-</span> prev before-cursor + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> prev <span class="Constant"> <move-cursor-begin></span> - editor, go-render?<span class="Special"> <- </span>move-cursor-coordinates-left editor - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">1/left-arrow</span> + editor, go-render? <span class="Special"><-</span> move-cursor-coordinates-left editor + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">1/left-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -760,42 +760,42 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with two lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of second line (so there's no previous newline)</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with three lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - e:&:editor<span class="Special"> <- </span>new-editor s:text, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s:text, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor further down (so there's a newline before the character at</span> <span class="Comment"># the cursor)</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -809,21 +809,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .g .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">g]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor at start of text, press left-arrow, then type a character</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -838,22 +838,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .g .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">4</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of first line</span> + check-trace-count-for-label<span class="Constant"> 4</span>, <span class="Constant">[print-character]</span> <span class="Comment"># length of first line</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-to-previous-line-with-left-arrow-at-start-of-line-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with text containing an empty line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> d] - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e:&:editor <span class="Constant"> $clear-trace</span> <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow type <span class="Constant">[0]</span> ] @@ -867,14 +867,14 @@ d] <span class="Constant"> .d .</span> <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> <span class="Comment"># just the '0'</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-across-wrap-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcdef]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -886,28 +886,28 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># right margin except wrap icon</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># right margin except wrap icon</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-wrapping-line-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a wrapping line followed by a second line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -919,28 +919,28 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># end of wrapped line</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># end of wrapped line</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-across-screen-lines-to-non-wrapping-line-with-left-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize editor with a line on the verge of wrapping, followed by a second line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcd</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcd</span> <span class="Constant">e]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> screen-should-contain [ @@ -952,19 +952,19 @@ d] ] <span class="Comment"># position cursor right after empty line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press left-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># previous row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">4</span> <span class="Comment"># end of wrapped line</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># previous row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 4</span> <span class="Comment"># end of wrapped line</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># todo: ctrl-left: previous word-start</span> @@ -974,25 +974,25 @@ d] <span class="muScenario">scenario</span> editor-moves-to-previous-line-with-up-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1010,11 +1010,11 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-previous-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65517/up-arrow</span> + move-to-previous-line?:bool <span class="Special"><-</span> equal k, <span class="Constant">65517/up-arrow</span> <span class="muControl">break-unless</span> move-to-previous-line? <span class="Constant"> <move-cursor-begin></span> - editor, go-render?<span class="Special"> <- </span>move-to-previous-line editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">3/up-arrow</span> + editor, go-render? <span class="Special"><-</span> move-to-previous-line editor + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">3/up-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -1023,67 +1023,67 @@ d] <span class="muRecipe">def</span> move-to-previous-line editor:&:editor<span class="muRecipe"> -> </span>editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - already-at-top?:bool<span class="Special"> <- </span>lesser-or-equal cursor-row, <span class="Constant">1/top</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + already-at-top?:bool <span class="Special"><-</span> lesser-or-equal cursor-row, <span class="Constant">1/top</span> <span class="Delimiter">{</span> <span class="Comment"># if cursor not at top, move it</span> <span class="muControl">break-if</span> already-at-top? <span class="Comment"># if not at newline, move to start of line (previous newline)</span> <span class="Comment"># then scan back another line</span> <span class="Comment"># if either step fails, give up without modifying cursor or coordinates</span> - curr:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor + curr:&:duplex-list:char <span class="Special"><-</span> copy before-cursor <span class="Delimiter">{</span> - old:&:duplex-list:char<span class="Special"> <- </span>copy curr - c2:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c2, <span class="Constant">10/newline</span> + old:&:duplex-list:char <span class="Special"><-</span> copy curr + c2:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c2, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr:&:duplex-list:char<span class="Special"> <- </span>before-previous-line curr, editor - no-motion?:bool<span class="Special"> <- </span>equal curr, old - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + curr:&:duplex-list:char <span class="Special"><-</span> before-previous-line curr, editor + no-motion?:bool <span class="Special"><-</span> equal curr, old + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-motion? <span class="Delimiter">}</span> <span class="Delimiter">{</span> - old<span class="Special"> <- </span>copy curr - curr<span class="Special"> <- </span>before-previous-line curr, editor - no-motion?:bool<span class="Special"> <- </span>equal curr, old - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + old <span class="Special"><-</span> copy curr + curr <span class="Special"><-</span> before-previous-line curr, editor + no-motion?:bool <span class="Special"><-</span> equal curr, old + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-motion? <span class="Delimiter">}</span> - before-cursor<span class="Special"> <- </span>copy curr - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + before-cursor <span class="Special"><-</span> copy curr + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Comment"># scan ahead to right column or until end of line</span> - target-column:num<span class="Special"> <- </span>copy cursor-column - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + target-column:num <span class="Special"><-</span> copy cursor-column + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, target-column + done?:bool <span class="Special"><-</span> greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + curr:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="muControl">break-unless</span> curr - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment">#</span> - before-cursor<span class="Special"> <- </span>copy curr - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy curr + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if cursor already at top, scroll up</span> <span class="muControl">break-unless</span> already-at-top? <span class="Constant"> <scroll-up></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1091,25 +1091,25 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-previous-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1128,25 +1128,25 @@ d] <span class="muScenario">scenario</span> editor-adjusts-column-at-empty-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new [ + s:text <span class="Special"><-</span> new [ <span class="muRecipe">def</span>] - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1166,27 +1166,27 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># start out with three lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># click on the third line and hit up-arrow, so you end up just after a newline</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press up-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1207,9 +1207,9 @@ d] <span class="muScenario">scenario</span> editor-moves-to-next-line-with-down-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># cursor starts out at (1, 0)</span> @@ -1218,15 +1218,15 @@ d] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># ..and ends at (2, 0)</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1244,11 +1244,11 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-next-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> + move-to-next-line?:bool <span class="Special"><-</span> equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> move-to-next-line? <span class="Constant"> <move-cursor-begin></span> - editor, go-render?<span class="Special"> <- </span>move-to-next-line editor, screen-height - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">4/down-arrow</span> + editor, go-render? <span class="Special"><-</span> move-to-next-line editor, screen-height + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">4/down-arrow</span> <span class="Constant"> <move-cursor-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> @@ -1257,81 +1257,81 @@ d] <span class="muRecipe">def</span> move-to-next-line editor:&:editor, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - last-line:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> - already-at-bottom?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, last-line + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + last-line:num <span class="Special"><-</span> subtract screen-height,<span class="Constant"> 1</span> + already-at-bottom?:bool <span class="Special"><-</span> greater-or-equal cursor-row, last-line <span class="Delimiter">{</span> <span class="Comment"># if cursor not at bottom, move it</span> <span class="muControl">break-if</span> already-at-bottom? <span class="Comment"># scan to start of next line, then to right column or until end of line</span> - max:num<span class="Special"> <- </span>subtract right, left - next-line:&:duplex-list:char<span class="Special"> <- </span>before-start-of-next-line before-cursor, max + max:num <span class="Special"><-</span> subtract right, left + next-line:&:duplex-list:char <span class="Special"><-</span> before-start-of-next-line before-cursor, max <span class="Delimiter">{</span> <span class="Comment"># already at end of buffer? try to scroll up (so we can see more</span> <span class="Comment"># warnings or sandboxes below)</span> - no-motion?:bool<span class="Special"> <- </span>equal next-line, before-cursor + no-motion?:bool <span class="Special"><-</span> equal next-line, before-cursor <span class="muControl">break-unless</span> no-motion? - scroll?:bool<span class="Special"> <- </span>greater-than cursor-row, <span class="Constant">1</span> + scroll?:bool <span class="Special"><-</span> greater-than cursor-row,<span class="Constant"> 1</span> <span class="muControl">break-if</span> scroll?, <span class="Constant">+try-to-scroll</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - before-cursor<span class="Special"> <- </span>copy next-line - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - target-column:num<span class="Special"> <- </span>copy cursor-column - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + before-cursor <span class="Special"><-</span> copy next-line + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + target-column:num <span class="Special"><-</span> copy cursor-column + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, target-column + done?:bool <span class="Special"><-</span> greater-or-equal cursor-column, target-column <span class="muControl">break-if</span> done? - curr:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + curr:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="muControl">break-unless</span> curr - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment">#</span> - before-cursor<span class="Special"> <- </span>copy curr - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy curr + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Constant"> +try-to-scroll</span> <span class="Constant"> <scroll-down></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> editor-adjusts-column-at-next-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">de]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[0]</span> ] @@ -1352,51 +1352,51 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press ctrl-a</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-a ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">1/ctrl-a</span> + move-to-start-of-line?:bool <span class="Special"><-</span> equal c, <span class="Constant">1/ctrl-a</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-start-of-line editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-start-of-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65521/home</span> + move-to-start-of-line?:bool <span class="Special"><-</span> equal k, <span class="Constant">65521/home</span> <span class="muControl">break-unless</span> move-to-start-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-start-of-line editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1405,21 +1405,21 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># update cursor column</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - cursor-column:num<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + cursor-column:num <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># update before-cursor</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - init:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + init:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> - at-start-of-text?:bool<span class="Special"> <- </span>equal before-cursor, init + at-start-of-text?:bool <span class="Special"><-</span> equal before-cursor, init <span class="muControl">break-if</span> at-start-of-text? - prev:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - at-start-of-line?:bool<span class="Special"> <- </span>equal prev, <span class="Constant">10/newline</span> + prev:char <span class="Special"><-</span> get *before-cursor, <span class="Constant">value:offset</span> + at-start-of-line?:bool <span class="Special"><-</span> equal prev, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? - before-cursor<span class="Special"> <- </span>prev before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special"><-</span> prev before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor assert before-cursor, <span class="Constant">[move-to-start-of-line tried to move before start of text]</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -1428,78 +1428,78 @@ d] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-ctrl-a-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press ctrl-a</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-a ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line, press 'home'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press home ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-start-of-line-with-home-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line (no newline before), press 'home'</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press home ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to start of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># ctrl-e/end - move cursor to end of line</span> @@ -1507,39 +1507,39 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press ctrl-e</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-e ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> <span class="Comment"># editor inserts future characters at cursor</span> assume-console [ type <span class="Constant">[z]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">4</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 4</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1548,31 +1548,31 @@ d] <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">5/ctrl-e</span> + move-to-end-of-line?:bool <span class="Special"><-</span> equal c, <span class="Constant">5/ctrl-e</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-end-of-line editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - move-to-end-of-line?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65520/end</span> + move-to-end-of-line?:bool <span class="Special"><-</span> equal k, <span class="Constant">65520/end</span> <span class="muControl">break-unless</span> move-to-end-of-line? <span class="Constant"> <move-cursor-begin></span> move-to-end-of-line editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1580,19 +1580,19 @@ d] <span class="muRecipe">def</span> move-to-end-of-line editor:&:editor<span class="muRecipe"> -> </span>editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Comment"># while not at start of line, move </span> <span class="Delimiter">{</span> - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="muControl">break-unless</span> next <span class="Comment"># end of text</span> - nextc:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?:bool<span class="Special"> <- </span>equal nextc, <span class="Constant">10/newline</span> + nextc:char <span class="Special"><-</span> get *next, <span class="Constant">value:offset</span> + at-end-of-line?:bool <span class="Special"><-</span> equal nextc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? - before-cursor<span class="Special"> <- </span>copy next - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy next + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -1600,79 +1600,79 @@ d] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-ctrl-e-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press ctrl-e</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-e ] run [ editor-event-loop screen, console, e - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on first line, press 'end'</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press end ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-to-end-of-line-with-end-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># start on second line (no newline after), press 'end'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press end ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves to end of line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="Comment"># ctrl-u - delete text from start of line until (but not at) cursor</span> @@ -1680,12 +1680,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 2</span> press ctrl-u ] run [ @@ -1703,12 +1703,12 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-to-start-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">21/ctrl-u</span> + delete-to-start-of-line?:bool <span class="Special"><-</span> equal c, <span class="Constant">21/ctrl-u</span> <span class="muControl">break-unless</span> delete-to-start-of-line? <span class="Constant"> <delete-to-start-of-line-begin></span> - deleted-cells:&:duplex-list:char<span class="Special"> <- </span>delete-to-start-of-line editor + deleted-cells:&:duplex-list:char <span class="Special"><-</span> delete-to-start-of-line editor <span class="Constant"> <delete-to-start-of-line-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1717,39 +1717,39 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - init:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - start:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor - end:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + init:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + start:&:duplex-list:char <span class="Special"><-</span> copy before-cursor + end:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Delimiter">{</span> - at-start-of-text?:bool<span class="Special"> <- </span>equal start, init + at-start-of-text?:bool <span class="Special"><-</span> equal start, init <span class="muControl">break-if</span> at-start-of-text? - curr:char<span class="Special"> <- </span>get *start, <span class="Constant">value:offset</span> - at-start-of-line?:bool<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> + curr:char <span class="Special"><-</span> get *start, <span class="Constant">value:offset</span> + at-start-of-line?:bool <span class="Special"><-</span> equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-start-of-line? - start<span class="Special"> <- </span>prev start + start <span class="Special"><-</span> prev start assert start, <span class="Constant">[delete-to-start-of-line tried to move before start of text]</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result:&:duplex-list:char<span class="Special"> <- </span>next start + result:&:duplex-list:char <span class="Special"><-</span> next start remove-between start, end <span class="Comment"># adjust cursor</span> - before-cursor<span class="Special"> <- </span>copy start - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, left + before-cursor <span class="Special"><-</span> copy start + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, left ] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line (no newline before), press ctrl-u</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-u ] run [ @@ -1768,12 +1768,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-line-with-ctrl-u-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-u ] run [ @@ -1792,12 +1792,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-start-of-final-line-with-ctrl-u [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of final line, press ctrl-u</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-u ] run [ @@ -1818,12 +1818,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on first line, press ctrl-k</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-k ] run [ @@ -1841,12 +1841,12 @@ d] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - delete-to-end-of-line?:bool<span class="Special"> <- </span>equal c, <span class="Constant">11/ctrl-k</span> + delete-to-end-of-line?:bool <span class="Special"><-</span> equal c, <span class="Constant">11/ctrl-k</span> <span class="muControl">break-unless</span> delete-to-end-of-line? <span class="Constant"> <delete-to-end-of-line-begin></span> - deleted-cells:&:duplex-list:char<span class="Special"> <- </span>delete-to-end-of-line editor + deleted-cells:&:duplex-list:char <span class="Special"><-</span> delete-to-end-of-line editor <span class="Constant"> <delete-to-end-of-line-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1855,31 +1855,31 @@ d] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># compute range to delete</span> - start:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - end:&:duplex-list:char<span class="Special"> <- </span>next start + start:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + end:&:duplex-list:char <span class="Special"><-</span> next start <span class="Delimiter">{</span> - at-end-of-text?:bool<span class="Special"> <- </span>equal end, <span class="Constant">0/null</span> + at-end-of-text?:bool <span class="Special"><-</span> equal end, <span class="Constant">0/null</span> <span class="muControl">break-if</span> at-end-of-text? - curr:char<span class="Special"> <- </span>get *end, <span class="Constant">value:offset</span> - at-end-of-line?:bool<span class="Special"> <- </span>equal curr, <span class="Constant">10/newline</span> + curr:char <span class="Special"><-</span> get *end, <span class="Constant">value:offset</span> + at-end-of-line?:bool <span class="Special"><-</span> equal curr, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-end-of-line? - end<span class="Special"> <- </span>next end + end <span class="Special"><-</span> next end <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip it out</span> - result<span class="Special"> <- </span>next start + result <span class="Special"><-</span> next start remove-between start, end ] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start on second line (no newline after), press ctrl-k</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-k ] run [ @@ -1898,12 +1898,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-k ] run [ @@ -1922,12 +1922,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> press ctrl-k ] run [ @@ -1946,12 +1946,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-5 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start at end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 2</span> press ctrl-k ] run [ @@ -1970,12 +1970,12 @@ d] <span class="muScenario">scenario</span> editor-deletes-to-end-of-line-with-ctrl-k-6 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[123</span> + s:text <span class="Special"><-</span> new <span class="Constant">[123</span> <span class="Constant">456]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># start past end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 3</span> press ctrl-k ] run [ @@ -1998,11 +1998,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2011,7 +2011,7 @@ d] ] <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2027,16 +2027,16 @@ d] ] <span class="muRecipe">after</span> <span class="Constant"><scroll-down></span> [ - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - max:num<span class="Special"> <- </span>subtract right, left - old-top:&:duplex-list:char<span class="Special"> <- </span>copy top-of-screen - top-of-screen<span class="Special"> <- </span>before-start-of-next-line top-of-screen, max - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:bool<span class="Special"> <- </span>equal old-top, top-of-screen - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll down]</span> + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + max:num <span class="Special"><-</span> subtract right, left + old-top:&:duplex-list:char <span class="Special"><-</span> copy top-of-screen + top-of-screen <span class="Special"><-</span> before-start-of-next-line top-of-screen, max + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + no-movement?:bool <span class="Special"><-</span> equal old-top, top-of-screen + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2046,25 +2046,25 @@ d] <span class="muRecipe">def</span> before-start-of-next-line original:&:duplex-list:char, max:num<span class="muRecipe"> -> </span>curr:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:&:duplex-list:char<span class="Special"> <- </span>copy original + count:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + curr:&:duplex-list:char <span class="Special"><-</span> copy original <span class="Comment"># skip the initial newline if it exists</span> <span class="Delimiter">{</span> - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> at-newline? - curr<span class="Special"> <- </span>next curr - count<span class="Special"> <- </span>add count, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + count <span class="Special"><-</span> add count,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">return-unless</span> curr, original - done?:bool<span class="Special"> <- </span>greater-or-equal count, max + done?:bool <span class="Special"><-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? - curr<span class="Special"> <- </span>next curr - count<span class="Special"> <- </span>add count, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + count <span class="Special"><-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return-unless</span> curr, original @@ -2077,11 +2077,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2090,7 +2090,7 @@ d] ] <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2110,14 +2110,14 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor starts with a long line wrapping twice</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at last line, then try to move further down</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2151,19 +2151,19 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long line in the third line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdef]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end, type a character</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 4</span> type <span class="Constant">[g]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2173,8 +2173,8 @@ d] <span class="Constant"> .g .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] ] @@ -2182,19 +2182,19 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># position cursor after last line and type newline</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">4</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 4</span> type [ ] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2204,8 +2204,8 @@ d] <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] @@ -2214,19 +2214,19 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2236,8 +2236,8 @@ d] <span class="Constant"> .gh .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] @@ -2246,20 +2246,20 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains more lines than can fit on screen</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2269,33 +2269,33 @@ d] <span class="Constant"> .d .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <span class="muScenario">scenario</span> editor-scrolls-at-end-on-down-arrow [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">de]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># try to move down past end of text</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen should scroll, moving cursor to end of text</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] assume-console [ type <span class="Constant">[0]</span> @@ -2312,20 +2312,20 @@ d] <span class="Comment"># try to move down again</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 0</span> press down-arrow ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen stops scrolling because cursor is already at top</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> assume-console [ type <span class="Constant">[1]</span> ] @@ -2345,18 +2345,18 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a few pages of lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f</span> <span class="Constant">g]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># scroll down one page and one line</span> assume-console [ press page-down - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -2378,11 +2378,11 @@ d] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2407,13 +2407,13 @@ d] ] <span class="muRecipe">after</span> <span class="Constant"><scroll-up></span> [ - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - old-top:&:duplex-list:char<span class="Special"> <- </span>copy top-of-screen - top-of-screen<span class="Special"> <- </span>before-previous-line top-of-screen, editor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - no-movement?:bool<span class="Special"> <- </span>equal old-top, top-of-screen - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[scroll up]</span> + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char <span class="Special"><-</span> copy top-of-screen + top-of-screen <span class="Special"><-</span> before-previous-line top-of-screen, editor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + no-movement?:bool <span class="Special"><-</span> equal old-top, top-of-screen + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-if</span> no-movement? ] @@ -2423,39 +2423,39 @@ d] <span class="muRecipe">def</span> before-previous-line in:&:duplex-list:char, editor:&:editor<span class="muRecipe"> -> </span>out:&:duplex-list:char [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:&:duplex-list:char<span class="Special"> <- </span>copy in - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> copy in + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> <span class="Comment"># compute max, number of characters to skip</span> <span class="Comment"># 1 + len%(width-1)</span> <span class="Comment"># except rotate second term to vary from 1 to width-1 rather than 0 to width-2</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - max-line-length:num<span class="Special"> <- </span>subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> - sentinel:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - len:num<span class="Special"> <- </span>previous-line-length curr, sentinel + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + max-line-length:num <span class="Special"><-</span> subtract right, left, <span class="Constant">-1/exclusive-right</span>, <span class="Constant">1/wrap-icon</span> + sentinel:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + len:num <span class="Special"><-</span> previous-line-length curr, sentinel <span class="Delimiter">{</span> <span class="muControl">break-if</span> len <span class="Comment"># empty line; just skip this newline</span> - prev:&:duplex-list:char<span class="Special"> <- </span>prev curr + prev:&:duplex-list:char <span class="Special"><-</span> prev curr <span class="muControl">return-unless</span> prev, curr <span class="muControl">return</span> prev <span class="Delimiter">}</span> - _, max:num<span class="Special"> <- </span>divide-with-remainder len, max-line-length + _, max:num <span class="Special"><-</span> divide-with-remainder len, max-line-length <span class="Comment"># remainder 0 => scan one width-worth</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> max - max<span class="Special"> <- </span>copy max-line-length + max <span class="Special"><-</span> copy max-line-length <span class="Delimiter">}</span> - max<span class="Special"> <- </span>add max, <span class="Constant">1</span> - count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + max <span class="Special"><-</span> add max,<span class="Constant"> 1</span> + count:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Comment"># skip 'max' characters</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal count, max + done?:bool <span class="Special"><-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:&:duplex-list:char<span class="Special"> <- </span>prev curr + prev:&:duplex-list:char <span class="Special"><-</span> prev curr <span class="muControl">break-unless</span> prev - curr<span class="Special"> <- </span>copy prev - count<span class="Special"> <- </span>add count, <span class="Constant">1</span> + curr <span class="Special"><-</span> copy prev + count <span class="Special"><-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> curr @@ -2467,11 +2467,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcd↩ .</span> @@ -2512,11 +2512,11 @@ d] <span class="Comment"># screen has 1 line for menu + 4 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor starts with a long line wrapping twice, occupying 3 of the 4 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefghij</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdefghij</span> <span class="Constant">k</span> <span class="Constant">l</span> <span class="Constant">m]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2586,11 +2586,11 @@ d] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with a long, wrapped line and more than a screen of</span> <span class="Comment"># other lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdef</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdef</span> <span class="Constant">g</span> <span class="Constant">h</span> <span class="Constant">i]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abcde↩ .</span> @@ -2631,13 +2631,13 @@ d] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with some lines around an empty line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> c d e] - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">6/right</span> assume-console [ press page-down ] @@ -2681,12 +2681,12 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains >3 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at top of second page</span> assume-console [ press page-down @@ -2706,8 +2706,8 @@ e] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen scrolls</span> screen-should-contain [ @@ -2717,8 +2717,8 @@ e] <span class="Constant"> .d .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] ] @@ -2727,11 +2727,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with >3 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2776,11 +2776,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -2805,32 +2805,32 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - page-down?:bool<span class="Special"> <- </span>equal c, <span class="Constant">6/ctrl-f</span> + page-down?:bool <span class="Special"><-</span> equal c, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> page-down editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top - go-render?<span class="Special"> <- </span>not no-movement? + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special"><-</span> equal top-of-screen, old-top + go-render? <span class="Special"><-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> page-down editor - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top - go-render?<span class="Special"> <- </span>not no-movement? + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special"><-</span> equal top-of-screen, old-top + go-render? <span class="Special"><-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -2841,32 +2841,32 @@ e] <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># if editor contents don't overflow screen, do nothing</span> - bottom-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">bottom-of-screen:offset</span> + bottom-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">bottom-of-screen:offset</span> <span class="muControl">return-unless</span> bottom-of-screen <span class="Comment"># if not, position cursor at final character</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>prev bottom-of-screen - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> prev bottom-of-screen + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Comment"># keep one line in common with previous page</span> <span class="Delimiter">{</span> - last:char<span class="Special"> <- </span>get *before-cursor, <span class="Constant">value:offset</span> - newline?:bool<span class="Special"> <- </span>equal last, <span class="Constant">10/newline</span> + last:char <span class="Special"><-</span> get *before-cursor, <span class="Constant">value:offset</span> + newline?:bool <span class="Special"><-</span> equal last, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline?:bool - before-cursor<span class="Special"> <- </span>prev before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special"><-</span> prev before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> <span class="Comment"># move cursor and top-of-screen to start of that line</span> move-to-start-of-line editor - before-cursor<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, before-cursor + before-cursor <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, before-cursor ] <span class="muScenario">scenario</span> editor-does-not-scroll-past-end [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e screen-should-contain [ <span class="Constant"> . .</span> @@ -2895,11 +2895,11 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a long last line</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2929,9 +2929,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -2960,11 +2960,11 @@ e] <span class="muScenario">scenario</span> editor-can-scroll-up [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3003,33 +3003,33 @@ e] <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - page-up?:bool<span class="Special"> <- </span>equal c, <span class="Constant">2/ctrl-b</span> + page-up?:bool <span class="Special"><-</span> equal c, <span class="Constant">2/ctrl-b</span> <span class="muControl">break-unless</span> page-up? - old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> - editor<span class="Special"> <- </span>page-up editor, screen-height - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + editor <span class="Special"><-</span> page-up editor, screen-height + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top - go-render?<span class="Special"> <- </span>not no-movement? + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special"><-</span> equal top-of-screen, old-top + go-render? <span class="Special"><-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - page-up?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool <span class="Special"><-</span> equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - old-top:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + old-top:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Constant"> <move-cursor-begin></span> - editor<span class="Special"> <- </span>page-up editor, screen-height - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + editor <span class="Special"><-</span> page-up editor, screen-height + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - no-movement?:bool<span class="Special"> <- </span>equal top-of-screen, old-top + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + no-movement?:bool <span class="Special"><-</span> equal top-of-screen, old-top <span class="Comment"># don't bother re-rendering if nothing changed. todo: test this</span> - go-render?<span class="Special"> <- </span>not no-movement? + go-render? <span class="Special"><-</span> not no-movement? <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -3037,17 +3037,17 @@ e] <span class="muRecipe">def</span> page-up editor:&:editor, screen-height:num<span class="muRecipe"> -> </span>editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - max:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> - count:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + max:num <span class="Special"><-</span> subtract screen-height, <span class="Constant">1/menu-bar</span>, <span class="Constant">1/overlapping-line</span> + count:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal count, max + done?:bool <span class="Special"><-</span> greater-or-equal count, max <span class="muControl">break-if</span> done? - prev:&:duplex-list:char<span class="Special"> <- </span>before-previous-line top-of-screen, editor + prev:&:duplex-list:char <span class="Special"><-</span> before-previous-line top-of-screen, editor <span class="muControl">break-unless</span> prev - top-of-screen<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen - count<span class="Special"> <- </span>add count, <span class="Constant">1</span> + top-of-screen <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top-of-screen + count <span class="Special"><-</span> add count,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -3057,7 +3057,7 @@ e] <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># initialize editor with 8 lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> @@ -3065,7 +3065,7 @@ e] <span class="Constant">f</span> <span class="Constant">g</span> <span class="Constant">h]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .a .</span> @@ -3122,7 +3122,7 @@ e] <span class="Comment"># screen has 1 line for menu + 5 lines for text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">6/height</span> <span class="Comment"># editor contains a long line in the first page</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh</span> <span class="Constant">i</span> @@ -3133,7 +3133,7 @@ e] <span class="Constant">n</span> <span class="Constant">o]</span> <span class="Comment"># editor screen triggers wrap of last line</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3146,7 +3146,7 @@ e] <span class="Comment"># scroll down a page and a line</span> assume-console [ press page-down - left-click <span class="Constant">5</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 0</span> press down-arrow ] run [ @@ -3185,9 +3185,9 @@ e] assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a very long line that occupies last two lines of screen</span> <span class="Comment"># and still has something left over</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + s:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">bcdefgh]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> <span class="Comment"># some part of last line is not displayed</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -3229,7 +3229,7 @@ e] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[axx</span> + s:text <span class="Special"><-</span> new <span class="Constant">[axx</span> <span class="Constant">bxx</span> <span class="Constant">cxx</span> <span class="Constant">dxx</span> @@ -3238,7 +3238,7 @@ e] <span class="Constant">gxx</span> <span class="Constant">hxx</span> <span class="Constant">]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axx .</span> @@ -3288,7 +3288,7 @@ e] <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">4/height</span> <span class="Comment"># text with empty line in second screen</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[axy</span> + s:text <span class="Special"><-</span> new <span class="Constant">[axy</span> <span class="Constant">bxy</span> <span class="Constant">cxy</span> @@ -3297,7 +3297,7 @@ exy fxy gxy ] - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">4/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .axy .</span> diff --git a/html/edit/004-programming-environment.mu.html b/html/edit/004-programming-environment.mu.html index 14ff221b..9019e0d1 100644 --- a/html/edit/004-programming-environment.mu.html +++ b/html/edit/004-programming-environment.mu.html @@ -41,10 +41,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:text <span class="Special"><-</span> restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text <span class="Special"><-</span> new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox render-all <span class="Constant">0/screen</span>, env, render event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> @@ -59,111 +59,111 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> new-programming-environment screen:&:screen, initial-recipe-contents:text, initial-sandbox-contents:text<span class="muRecipe"> -> </span>result:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - width:num<span class="Special"> <- </span>screen-width screen - height:num<span class="Special"> <- </span>screen-height screen + width:num <span class="Special"><-</span> screen-width screen + height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># top menu</span> - result<span class="Special"> <- </span>new <span class="Constant">environment:type</span> - draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> - button-start:num<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:bool<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> + result <span class="Special"><-</span> new <span class="Constant">environment:type</span> + draw-horizontal screen,<span class="Constant"> 0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> + button-start:num <span class="Special"><-</span> subtract width,<span class="Constant"> 20</span> + button-on-screen?:bool <span class="Special"><-</span> greater-or-equal button-start,<span class="Constant"> 0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start + screen <span class="Special"><-</span> move-cursor screen, <span class="Constant">0/row</span>, button-start print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> - divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> + divider:num, _ <span class="Special"><-</span> divide-with-remainder width,<span class="Constant"> 2</span> draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment"># recipe editor on the left</span> - recipes:&:editor<span class="Special"> <- </span>new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right + recipes:&:editor <span class="Special"><-</span> new-editor initial-recipe-contents, screen, <span class="Constant">0/left</span>, divider/right <span class="Comment"># sandbox editor on the right</span> - sandbox-left:num<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - current-sandbox:&:editor<span class="Special"> <- </span>new-editor initial-sandbox-contents, screen, sandbox-left, width/right - *result<span class="Special"> <- </span>put *result, <span class="Constant">recipes:offset</span>, recipes - *result<span class="Special"> <- </span>put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox - *result<span class="Special"> <- </span>put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> + sandbox-left:num <span class="Special"><-</span> add divider,<span class="Constant"> 1</span> + current-sandbox:&:editor <span class="Special"><-</span> new-editor initial-sandbox-contents, screen, sandbox-left, width/right + *result <span class="Special"><-</span> put *result, <span class="Constant">recipes:offset</span>, recipes + *result <span class="Special"><-</span> put *result, <span class="Constant">current-sandbox:offset</span>, current-sandbox + *result <span class="Special"><-</span> put *result, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">0/false</span> <span class="Constant"> <programming-environment-initialization></span> ] <span class="muRecipe">def</span> event-loop screen:&:screen, console:&:console, env:&:environment<span class="muRecipe"> -> </span>screen:&:screen, console:&:console, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool <span class="Special"><-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Comment"># if we fall behind we'll stop updating the screen, but then we have to</span> <span class="Comment"># render the entire screen when we catch up.</span> <span class="Comment"># todo: test this</span> - render-all-on-no-more-events?:bool<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + render-all-on-no-more-events?:bool <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span> <span class="Constant"> +next-event</span> - e:event, found?:bool, quit?:bool, console<span class="Special"> <- </span>read-event console + e:event, found?:bool, quit?:bool, console <span class="Special"><-</span> read-event console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? <span class="Comment"># only in tests</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> <span class="Constant"> <handle-event></span> <span class="Comment"># check for global events that will trigger regardless of which editor has focus</span> <span class="Delimiter">{</span> - k:num, is-keycode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">keycode:variant</span> <span class="muControl">break-unless</span> is-keycode? <span class="Constant"> <global-keypress></span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - c:char, is-unicode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? <span class="Constant"> <global-type></span> <span class="Delimiter">}</span> <span class="Comment"># 'touch' event - send to both sides, see what picks it up</span> <span class="Delimiter">{</span> - t:touch-event, is-touch?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">touch:variant</span> <span class="muControl">break-unless</span> is-touch? <span class="Comment"># ignore all but 'left-click' events for now</span> <span class="Comment"># todo: test this</span> - touch-type:num<span class="Special"> <- </span>get t, <span class="Constant">type:offset</span> - is-left-click?:bool<span class="Special"> <- </span>equal touch-type, <span class="Constant">65513/mouse-left</span> + touch-type:num <span class="Special"><-</span> get t, <span class="Constant">type:offset</span> + is-left-click?:bool <span class="Special"><-</span> equal touch-type, <span class="Constant">65513/mouse-left</span> <span class="muControl">loop-unless</span> is-left-click?, <span class="Constant">+next-event</span> - click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> + click-row:num <span class="Special"><-</span> get t, <span class="Constant">row:offset</span> + click-column:num <span class="Special"><-</span> get t, <span class="Constant">column:offset</span> <span class="Comment"># later exceptions for non-editor touches will go here</span> <span class="Constant"> <global-touch></span> <span class="Comment"># send to both editors</span> - _<span class="Special"> <- </span>move-cursor-in-editor screen, recipes, t - sandbox-in-focus?:bool<span class="Special"> <- </span>move-cursor-in-editor screen, current-sandbox, t - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + _ <span class="Special"><-</span> move-cursor-in-editor screen, recipes, t + sandbox-in-focus?:bool <span class="Special"><-</span> move-cursor-in-editor screen, current-sandbox, t + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Comment"># 'resize' event - redraw editor</span> <span class="Comment"># todo: test this after supporting resize in assume-console</span> <span class="Delimiter">{</span> - r:resize-event, is-resize?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">resize:variant</span> + r:resize-event, is-resize?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">resize:variant</span> <span class="muControl">break-unless</span> is-resize? <span class="Comment"># if more events, we're still resizing; wait until we stop</span> - more-events?:bool<span class="Special"> <- </span>has-more-events? console + more-events?:bool <span class="Special"><-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> more-events? - env, screen<span class="Special"> <- </span>resize screen, env - screen<span class="Special"> <- </span>render-all screen, env, render-without-moving-cursor - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> <span class="Comment"># full render done</span> + env, screen <span class="Special"><-</span> resize screen, env + screen <span class="Special"><-</span> render-all screen, env, render-without-moving-cursor + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Comment"># full render done</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Comment"># if it's not global and not a touch event, send to appropriate editor</span> <span class="Delimiter">{</span> hide-screen screen - sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus?:bool <span class="Special"><-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - screen, recipes, render?:bool<span class="Special"> <- </span>handle-keyboard-event screen, recipes, e:event + screen, recipes, render?:bool <span class="Special"><-</span> handle-keyboard-event screen, recipes, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> - more-events?:bool<span class="Special"> <- </span>has-more-events? console + more-events?:bool <span class="Special"><-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> @@ -171,27 +171,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render-all-on-no-more-events? <span class="Comment"># no more events, and we have to force render</span> - screen<span class="Special"> <- </span>render-all screen, env, render - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + screen <span class="Special"><-</span> render-all screen, env, render + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Comment"># no more events, no force render</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render? - screen<span class="Special"> <- </span>render-recipes screen, env, render + screen <span class="Special"><-</span> render-recipes screen, env, render <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - screen, current-sandbox, render?:bool<span class="Special"> <- </span>handle-keyboard-event screen, current-sandbox, e:event + screen, current-sandbox, render?:bool <span class="Special"><-</span> handle-keyboard-event screen, current-sandbox, e:event <span class="Comment"># refresh screen only if no more events</span> <span class="Comment"># if there are more events to process, wait for them to clear up, then make sure you render-all afterward.</span> - more-events?:bool<span class="Special"> <- </span>has-more-events? console + more-events?:bool <span class="Special"><-</span> has-more-events? console <span class="Delimiter">{</span> <span class="muControl">break-unless</span> more-events? - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Comment"># no rendering now, full rendering on some future event</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> @@ -199,20 +199,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render-all-on-no-more-events? <span class="Comment"># no more events, and we have to force render</span> - screen<span class="Special"> <- </span>render-all screen, env, render - render-all-on-no-more-events?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + screen <span class="Special"><-</span> render-all screen, env, render + render-all-on-no-more-events? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Comment"># no more events, no force render</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> render? - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render + screen <span class="Special"><-</span> render-sandbox-side screen, env, render <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="Constant"> +finish-event</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -223,24 +223,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> clear-screen screen <span class="Comment"># update screen dimensions</span> - width:num<span class="Special"> <- </span>screen-width screen - divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> + width:num <span class="Special"><-</span> screen-width screen + divider:num, _ <span class="Special"><-</span> divide-with-remainder width,<span class="Constant"> 2</span> <span class="Comment"># update recipe editor</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - right:num<span class="Special"> <- </span>subtract divider, <span class="Constant">1</span> - *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">right:offset</span>, right + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + right:num <span class="Special"><-</span> subtract divider,<span class="Constant"> 1</span> + *recipes <span class="Special"><-</span> put *recipes, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> - *recipes<span class="Special"> <- </span>put *recipes, <span class="Constant">cursor-column:offset</span>, <span class="Constant">0</span> + *recipes <span class="Special"><-</span> put *recipes, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 1</span> + *recipes <span class="Special"><-</span> put *recipes, <span class="Constant">cursor-column:offset</span>,<span class="Constant"> 0</span> <span class="Comment"># update sandbox editor</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:num<span class="Special"> <- </span>add divider, <span class="Constant">1</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">left:offset</span>, left - right:num<span class="Special"> <- </span>subtract width, <span class="Constant">1</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">right:offset</span>, right + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + left:num <span class="Special"><-</span> add divider,<span class="Constant"> 1</span> + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">left:offset</span>, left + right:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">right:offset</span>, right <span class="Comment"># reset cursor (later we'll try to preserve its position)</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">cursor-row:offset</span>, <span class="Constant">1</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">cursor-column:offset</span>, left + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 1</span> + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">cursor-column:offset</span>, left ] <span class="Comment"># Variant of 'render' that updates cursor-row and cursor-column based on</span> @@ -249,81 +249,81 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-without-moving-cursor screen:&:screen, editor:&:editor<span class="muRecipe"> -> </span>last-row:num, last-column:num, screen:&:screen, editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> - curr<span class="Special"> <- </span>next curr + <span class="muControl">return-unless</span> editor, <span class="Constant">1/top</span>, <span class="Constant">0/left</span>, screen/same-as-ingredient:0, editor/same-as-ingredient:1 + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char <span class="Special"><-</span> copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr <span class="Special"><-</span> next curr <span class="Constant"> +render-loop-initialization</span> - color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:num<span class="Special"> <- </span>copy left + color:num <span class="Special"><-</span> copy <span class="Constant">7/white</span> + row:num <span class="Special"><-</span> copy <span class="Constant">1/top</span> + column:num <span class="Special"><-</span> copy left <span class="Comment"># save before-cursor</span> - old-before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + old-before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> <span class="Comment"># initialze cursor-row/cursor-column/before-cursor to the top of the screen</span> <span class="Comment"># by default</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column - top-of-screen:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, top-of-screen - screen<span class="Special"> <- </span>move-cursor screen, row, column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, column + top-of-screen:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, top-of-screen + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># if we find old-before-cursor still on the new resized screen, update</span> <span class="Comment"># editor.cursor-row and editor.cursor-column based on</span> <span class="Comment"># old-before-cursor</span> <span class="Delimiter">{</span> - at-cursor?:bool<span class="Special"> <- </span>equal old-before-cursor, prev + at-cursor?:bool <span class="Special"><-</span> equal old-before-cursor, prev <span class="muControl">break-unless</span> at-cursor? - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, old-before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, old-before-cursor <span class="Delimiter">}</span> - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> <span class="Constant"> <character-c-received></span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> clear-line-until screen, right <span class="Comment"># skip to next line</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span> <span class="Comment"># room for clicking on the cursor after it.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special"><-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Comment"># don't increment curr</span> <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># save first character off-screen</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">bottom:offset</span>, row - <span class="muControl">return</span> row, column, screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">bottom-of-screen:offset</span>, curr + *editor <span class="Special"><-</span> put *editor, <span class="Constant">bottom:offset</span>, row + <span class="muControl">return</span> row, column, screen/same-as-ingredient:0, editor/same-as-ingredient:1 ] @@ -332,23 +332,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> <span class="Comment"># focus on both sides</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> - left-click <span class="Constant">1</span>, <span class="Constant">17</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 17</span> ] <span class="Comment"># check cursor column in each</span> run [ event-loop screen, console, env - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> - sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num/<span class="Special">raw <- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + 7:num/<span class="Special">raw</span> <span class="Special"><-</span> get *sandbox, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">17</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 7</span> <span class="Special"><-</span><span class="Constant"> 17</span> ] ] @@ -357,21 +357,21 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize both halves of screen</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render <span class="Comment"># type one letter in each of them</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> type <span class="Constant">[0]</span> - left-click <span class="Constant">1</span>, <span class="Constant">17</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 17</span> type <span class="Constant">[1]</span> ] run [ event-loop screen, console, env - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - <span class="Constant">5</span>:num/<span class="Special">raw <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> - sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - <span class="Constant">7</span>:num/<span class="Special">raw <- </span>get *sandbox, <span class="Constant">cursor-column:offset</span> + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + 5:num/<span class="Special">raw</span> <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-column:offset</span> + sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + 7:num/<span class="Special">raw</span> <span class="Special"><-</span> get *sandbox, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . run (F4) . # this line has a different background, but we don't test that yet</span> @@ -380,12 +380,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . ╎ .</span> ] memory-should-contain [ - <span class="Constant">5</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column of recipe editor</span> - <span class="Constant">7</span><span class="Special"> <- </span><span class="Constant">18</span> <span class="Comment"># cursor column of sandbox editor</span> + <span class="Constant"> 5</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column of recipe editor</span> + <span class="Constant"> 7</span> <span class="Special"><-</span><span class="Constant"> 18</span> <span class="Comment"># cursor column of sandbox editor</span> ] <span class="Comment"># show the cursor at the right window</span> run [ - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] screen-should-contain [ @@ -401,7 +401,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">60/width</span>, <span class="Constant">10/height</span> run [ - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render ] <span class="Comment"># divider isn't messed up</span> @@ -418,13 +418,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[abc]</span>, <span class="Constant">[def]</span> render-all screen, env, render <span class="Comment"># initialize programming environment and highlight cursor</span> assume-console <span class="Constant">[]</span> run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># is cursor at the right place?</span> @@ -440,7 +440,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor should still be right</span> @@ -457,9 +457,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">30/width</span>, <span class="Constant">5/height</span> <span class="Comment"># initialize sandbox side with two lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, s:text + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, s:text render-all screen, env, render screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -470,12 +470,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># position cursor at start of second line and hit backspace</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">16</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 16</span> press backspace ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor moves to end of old line</span> @@ -490,31 +490,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-all screen:&:screen, env:&:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -> </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[render all]</span> hide-screen screen <span class="Comment"># top menu</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render top menu]</span> - width:num<span class="Special"> <- </span>screen-width screen - draw-horizontal screen, <span class="Constant">0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> - button-start:num<span class="Special"> <- </span>subtract width, <span class="Constant">20</span> - button-on-screen?:bool<span class="Special"> <- </span>greater-or-equal button-start, <span class="Constant">0</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render top menu]</span> + width:num <span class="Special"><-</span> screen-width screen + draw-horizontal screen,<span class="Constant"> 0</span>, <span class="Constant">0/left</span>, width, <span class="Constant">32/space</span>, <span class="Constant">0/black</span>, <span class="Constant">238/grey</span> + button-start:num <span class="Special"><-</span> subtract width,<span class="Constant"> 20</span> + button-on-screen?:bool <span class="Special"><-</span> greater-or-equal button-start,<span class="Constant"> 0</span> assert button-on-screen?, <span class="Constant">[screen too narrow for menu]</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0/row</span>, button-start + screen <span class="Special"><-</span> move-cursor screen, <span class="Constant">0/row</span>, button-start print screen, <span class="Constant">[ run (F4) ]</span>, <span class="Constant">255/white</span>, <span class="Constant">161/reddish</span> <span class="Comment"># dotted line down the middle</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> - divider:num, _<span class="Special"> <- </span>divide-with-remainder width, <span class="Constant">2</span> - height:num<span class="Special"> <- </span>screen-height screen + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render divider]</span> + divider:num, _ <span class="Special"><-</span> divide-with-remainder width,<span class="Constant"> 2</span> + height:num <span class="Special"><-</span> screen-height screen draw-vertical screen, divider, <span class="Constant">1/top</span>, height, <span class="Constant">9482/vertical-dotted</span> <span class="Comment">#</span> - screen<span class="Special"> <- </span>render-recipes screen, env, render-editor - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render-editor + screen <span class="Special"><-</span> render-recipes screen, env, render-editor + screen <span class="Special"><-</span> render-sandbox-side screen, env, render-editor <span class="Constant"> <render-components-end></span> <span class="Comment">#</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-in-focus?:bool <span class="Special"><-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment">#</span> show-screen screen ] @@ -522,18 +522,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-recipes screen:&:screen, env:&:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -> </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render recipes]</span> + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> <span class="Comment"># render recipes</span> - left:num<span class="Special"> <- </span>get *recipes, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *recipes, <span class="Constant">right:offset</span> - row:num, column:num, screen<span class="Special"> <- </span>call render-editor, screen, recipes + left:num <span class="Special"><-</span> get *recipes, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *recipes, <span class="Constant">right:offset</span> + row:num, column:num, screen <span class="Special"><-</span> call render-editor, screen, recipes clear-line-until screen, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Constant"> <render-recipe-components-end></span> <span class="Comment"># draw dotted line after recipes</span> draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] @@ -541,15 +541,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> render-sandbox-side screen:&:screen, env:&:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -> </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - left:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> - row:num, column:num, screen, current-sandbox<span class="Special"> <- </span>call render-editor, screen, current-sandbox + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + left:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">right:offset</span> + row:num, column:num, screen, current-sandbox <span class="Special"><-</span> call render-editor, screen, current-sandbox clear-line-until screen, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Comment"># draw solid line after code (you'll see why in later layers)</span> draw-horizontal screen, row, left, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] @@ -559,15 +559,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> <update-cursor-special-cases></span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - cursor-row:num<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *recipes, <span class="Constant">cursor-column:offset</span> + cursor-row:num <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *recipes, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - cursor-row:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">cursor-column:offset</span> + cursor-row:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column ] <span class="Comment"># like 'render' for texts, but with colorization for comments like in the editor</span> @@ -575,60 +575,60 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - color:num<span class="Special"> <- </span>copy <span class="Constant">7/white</span> - column:num<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column - screen-height:num<span class="Special"> <- </span>screen-height screen - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *s + color:num <span class="Special"><-</span> copy <span class="Constant">7/white</span> + column:num <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column + screen-height:num <span class="Special"><-</span> screen-height screen + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len + done?:bool <span class="Special"><-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>greater-or-equal row, screen-height + done? <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *s, i + c:char <span class="Special"><-</span> index *s, i <span class="Constant"><character-c-received></span> <span class="Comment"># only line different from render</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special"><-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Comment"># retry i</span> <span class="Delimiter">}</span> - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-than column, right + done?:bool <span class="Special"><-</span> greater-than column, right <span class="muControl">break-if</span> done? - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> print screen, space - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:bool<span class="Special"> <- </span>equal column, left + was-at-left?:bool <span class="Special"><-</span> equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> move-cursor screen, row, left ] @@ -637,9 +637,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - redraw-screen?:bool<span class="Special"> <- </span>equal c, <span class="Constant">12/ctrl-l</span> + redraw-screen?:bool <span class="Special"><-</span> equal c, <span class="Constant">12/ctrl-l</span> <span class="muControl">break-unless</span> redraw-screen? - screen<span class="Special"> <- </span>render-all screen, env:&:environment, render + screen <span class="Special"><-</span> render-all screen, env:&:environment, render sync-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -650,12 +650,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> - switch-side?:bool<span class="Special"> <- </span>equal c, <span class="Constant">14/ctrl-n</span> + switch-side?:bool <span class="Special"><-</span> equal c, <span class="Constant">14/ctrl-n</span> <span class="muControl">break-unless</span> switch-side? - sandbox-in-focus?:bool<span class="Special"> <- </span>get *env, <span class="Constant">sandbox-in-focus?:offset</span> - sandbox-in-focus?<span class="Special"> <- </span>not sandbox-in-focus? - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + sandbox-in-focus?:bool <span class="Special"><-</span> get *env, <span class="Constant">sandbox-in-focus?:offset</span> + sandbox-in-focus? <span class="Special"><-</span> not sandbox-in-focus? + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, sandbox-in-focus? + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> ] @@ -665,23 +665,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> draw-vertical screen:&:screen, col:num, y:num, bottom:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:char, style-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? - style<span class="Special"> <- </span>copy <span class="Constant">9474/vertical</span> + style <span class="Special"><-</span> copy <span class="Constant">9474/vertical</span> <span class="Delimiter">}</span> - color:num, color-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> <span class="muControl">break-if</span> color-found? - color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> + color <span class="Special"><-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> - continue?:bool<span class="Special"> <- </span>lesser-than y, bottom + continue?:bool <span class="Special"><-</span> lesser-than y, bottom <span class="muControl">break-unless</span> continue? - screen<span class="Special"> <- </span>move-cursor screen, y, col + screen <span class="Special"><-</span> move-cursor screen, y, col print screen, style, color - y<span class="Special"> <- </span>add y, <span class="Constant">1</span> + y <span class="Special"><-</span> add y,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] diff --git a/html/edit/005-sandbox.mu.html b/html/edit/005-sandbox.mu.html index 735a45de..91e61166 100644 --- a/html/edit/005-sandbox.mu.html +++ b/html/edit/005-sandbox.mu.html @@ -45,11 +45,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> main [ <span class="Constant">local-scope</span> open-console - initial-recipe:text<span class="Special"> <- </span>restore <span class="Constant">[recipes.mu]</span> - initial-sandbox:text<span class="Special"> <- </span>new <span class="Constant">[]</span> + initial-recipe:text <span class="Special"><-</span> restore <span class="Constant">[recipes.mu]</span> + initial-sandbox:text <span class="Special"><-</span> new <span class="Constant">[]</span> hide-screen <span class="Constant">0/screen</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox - env<span class="Special"> <- </span>restore-sandboxes env + env:&:environment <span class="Special"><-</span> new-programming-environment <span class="Constant">0/screen</span>, initial-recipe, initial-sandbox + env <span class="Special"><-</span> restore-sandboxes env render-all <span class="Constant">0/screen</span>, env, render event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, env <span class="Comment"># never gets here</span> @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ - *result<span class="Special"> <- </span>put *result, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> ] <span class="muData">container</span> sandbox [ @@ -82,7 +82,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe editor is empty</span> <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[divide-with-remainder 11, 3]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># run another command</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> type <span class="Constant">[add 2, 2]</span> press F4 ] @@ -161,17 +161,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Comment"># F4? load all code and run all sandboxes.</span> <span class="Delimiter">{</span> - do-run?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65532/F4</span> + do-run?:bool <span class="Special"><-</span> equal k, <span class="Constant">65532/F4</span> <span class="muControl">break-unless</span> do-run? - screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> - error?:bool, env, screen<span class="Special"> <- </span>run-sandboxes env, screen + screen <span class="Special"><-</span> update-status screen, <span class="Constant">[running... ]</span>, <span class="Constant">245/grey</span> + error?:bool, env, screen <span class="Special"><-</span> run-sandboxes env, screen <span class="Comment"># F4 might update warnings and results on both sides</span> - screen<span class="Special"> <- </span>render-all screen, env, render + screen <span class="Special"><-</span> render-all screen, env, render <span class="Delimiter">{</span> <span class="muControl">break-if</span> error? - screen<span class="Special"> <- </span>update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> + screen <span class="Special"><-</span> update-status screen, <span class="Constant">[ ]</span>, <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> ] @@ -179,41 +179,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> run-sandboxes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - errors-found?:bool, env, screen<span class="Special"> <- </span>update-recipes env, screen + errors-found?:bool, env, screen <span class="Special"><-</span> update-recipes env, screen <span class="muControl">return-if</span> errors-found? <span class="Comment"># check contents of right editor (sandbox)</span> <span class="Constant"> <run-sandboxes-begin></span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> <span class="Delimiter">{</span> - sandbox-contents:text<span class="Special"> <- </span>editor-contents current-sandbox + sandbox-contents:text <span class="Special"><-</span> editor-contents current-sandbox <span class="muControl">break-unless</span> sandbox-contents <span class="Comment"># if contents exist, first save them</span> <span class="Comment"># run them and turn them into a new sandbox</span> - new-sandbox:&:sandbox<span class="Special"> <- </span>new <span class="Constant">sandbox:type</span> - *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents + new-sandbox:&:sandbox <span class="Special"><-</span> new <span class="Constant">sandbox:type</span> + *new-sandbox <span class="Special"><-</span> put *new-sandbox, <span class="Constant">data:offset</span>, sandbox-contents <span class="Comment"># push to head of sandbox list</span> - dest:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - *new-sandbox<span class="Special"> <- </span>put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, new-sandbox + dest:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + *new-sandbox <span class="Special"><-</span> put *new-sandbox, <span class="Constant">next-sandbox:offset</span>, dest + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox:offset</span>, new-sandbox <span class="Comment"># update sandbox count</span> - sandbox-count:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - sandbox-count<span class="Special"> <- </span>add sandbox-count, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count + sandbox-count:num <span class="Special"><-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count <span class="Special"><-</span> add sandbox-count,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># clear sandbox editor</span> - init:&:duplex-list:char<span class="Special"> <- </span>push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">data:offset</span>, init - *current-sandbox<span class="Special"> <- </span>put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init + init:&:duplex-list:char <span class="Special"><-</span> push <span class="Constant">167/§</span>, <span class="Constant">0/tail</span> + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">data:offset</span>, init + *current-sandbox <span class="Special"><-</span> put *current-sandbox, <span class="Constant">top-of-screen:offset</span>, init <span class="Delimiter">}</span> <span class="Comment"># save all sandboxes before running, just in case we die when running</span> save-sandboxes env <span class="Comment"># run all sandboxes</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - curr<span class="Special"> <- </span>update-sandbox curr, env, idx - curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> + curr <span class="Special"><-</span> update-sandbox curr, env, idx + curr <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Constant"> <run-sandboxes-end></span> @@ -224,46 +224,46 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> update-recipes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:text<span class="Special"> <- </span>editor-contents recipes + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + in:text <span class="Special"><-</span> editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in <span class="Comment"># newlayer: persistence</span> reload in - errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + errors-found? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] <span class="Comment"># replaced in a later layer</span> <span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox, env:&:environment, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:&:screen<span class="Special"> <- </span>run-sandboxed data - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:&:screen <span class="Special"><-</span> run-sandboxed data + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen ] <span class="muRecipe">def</span> update-status screen:&:screen, msg:text, color:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">0</span>, <span class="Constant">2</span> - screen<span class="Special"> <- </span>print screen, msg, color, <span class="Constant">238/grey/background</span> + screen <span class="Special"><-</span> move-cursor screen,<span class="Constant"> 0</span>,<span class="Constant"> 2</span> + screen <span class="Special"><-</span> print screen, msg, color, <span class="Constant">238/grey/background</span> ] <span class="muRecipe">def</span> save-sandboxes env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> <span class="Comment"># first clear previous versions, in case we deleted some sandbox</span> - $system <span class="Constant">[rm lesson/[0-9]</span>* <span class="Constant">>/dev/null</span> <span class="Constant">2</span>>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + $system <span class="Constant">[rm lesson/[0-9]</span>* <span class="Constant">>/dev/null</span> 2>/dev/null] <span class="Comment"># some shells can't handle '>&'</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - data:text<span class="Special"> <- </span>get *curr, <span class="Constant">data:offset</span> - filename:text<span class="Special"> <- </span>to-text idx + data:text <span class="Special"><-</span> get *curr, <span class="Constant">data:offset</span> + filename:text <span class="Special"><-</span> to-text idx save filename, data <span class="Constant"> <end-save-sandbox></span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - curr<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -271,24 +271,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> render-sandbox-side screen:&:screen, env:&:environment, <span class="Delimiter">{</span>render-editor: (recipe (address screen) (address editor)<span class="muRecipe"> -> </span>number number (address screen) (address editor))<span class="Delimiter">}</span><span class="muRecipe"> -> </span>screen:&:screen, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - row:num, column:num<span class="Special"> <- </span>copy <span class="Constant">1</span>, <span class="Constant">0</span> - left:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">right:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render sandbox side]</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + row:num, column:num <span class="Special"><-</span> copy<span class="Constant"> 1</span>,<span class="Constant"> 0</span> + left:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">right:offset</span> <span class="Comment"># render sandbox editor</span> - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> <span class="Delimiter">{</span> - render-current-sandbox?:bool<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-current-sandbox?:bool <span class="Special"><-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-unless</span> render-current-sandbox? - row, column, screen, current-sandbox<span class="Special"> <- </span>call render-editor, screen, current-sandbox + row, column, screen, current-sandbox <span class="Special"><-</span> call render-editor, screen, current-sandbox clear-screen-from screen, row, column, left, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># render sandboxes</span> draw-horizontal screen, row, left, right - sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, sandbox, left, right, row, render-from + sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + row, screen <span class="Special"><-</span> render-sandboxes screen, sandbox, left, right, row, render-from clear-rest-of-screen screen, row, left, right ] @@ -296,40 +296,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox - screen-height:num<span class="Special"> <- </span>screen-height screen - at-bottom?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + screen-height:num <span class="Special"><-</span> screen-height screen + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom?:bool - hidden?:bool<span class="Special"> <- </span>lesser-than idx, render-from + hidden?:bool <span class="Special"><-</span> lesser-than idx, render-from <span class="Delimiter">{</span> <span class="muControl">break-if</span> hidden? <span class="Comment"># render sandbox menu</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - screen<span class="Special"> <- </span>render-sandbox-menu screen, idx, left, right + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, left + screen <span class="Special"><-</span> render-sandbox-menu screen, idx, left, right <span class="Comment"># save menu row so we can detect clicks to it later</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, row <span class="Comment"># render sandbox contents</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, left - sandbox-data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - row, screen<span class="Special"> <- </span>render-code screen, sandbox-data, left, right, row - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, left + sandbox-data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + row, screen <span class="Special"><-</span> render-code screen, sandbox-data, left, right, row + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, row <span class="Comment"># render sandbox warnings, screen or response, in that order</span> - sandbox-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> + sandbox-response:text <span class="Special"><-</span> get *sandbox, <span class="Constant">response:offset</span> <span class="Constant"> <render-sandbox-results></span> <span class="Delimiter">{</span> - sandbox-screen:&:screen<span class="Special"> <- </span>get *sandbox, <span class="Constant">screen:offset</span> - empty-screen?:bool<span class="Special"> <- </span>fake-screen-is-empty? sandbox-screen + sandbox-screen:&:screen <span class="Special"><-</span> get *sandbox, <span class="Constant">screen:offset</span> + empty-screen?:bool <span class="Special"><-</span> fake-screen-is-empty? sandbox-screen <span class="muControl">break-if</span> empty-screen? - row, screen<span class="Special"> <- </span>render-screen screen, sandbox-screen, left, right, row + row, screen <span class="Special"><-</span> render-screen screen, sandbox-screen, left, right, row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> empty-screen? <span class="Constant"> <render-sandbox-response></span> - row, screen<span class="Special"> <- </span>render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row + row, screen <span class="Special"><-</span> render-text screen, sandbox-response, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> <span class="Constant"> +render-sandbox-end</span> - at-bottom?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">return-if</span> at-bottom? <span class="Comment"># draw solid line after sandbox</span> draw-horizontal screen, row, left, right @@ -337,33 +337,33 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if hidden, reset row attributes</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> hidden? - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>, <span class="Constant">0</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span>,<span class="Constant"> 0</span> <span class="Constant"> <end-render-sandbox-reset-hidden></span> <span class="Delimiter">}</span> <span class="Comment"># draw next sandbox</span> - next-sandbox:&:sandbox<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> - next-idx:num<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - row, screen<span class="Special"> <- </span>render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx + next-sandbox:&:sandbox <span class="Special"><-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-idx:num <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + row, screen <span class="Special"><-</span> render-sandboxes screen, next-sandbox, left, right, row, render-from, next-idx ] <span class="muRecipe">def</span> render-sandbox-menu screen:&:screen, sandbox-index:num, left:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> move-cursor-to-column screen, left - edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num<span class="Special"> <- </span>sandbox-menu-columns left, right + edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num <span class="Special"><-</span> sandbox-menu-columns left, right print screen, sandbox-index, <span class="Constant">232/dark-grey</span>, <span class="Constant">245/grey</span> - start-buttons:num<span class="Special"> <- </span>subtract edit-button-left, <span class="Constant">1</span> + start-buttons:num <span class="Special"><-</span> subtract edit-button-left,<span class="Constant"> 1</span> clear-line-until screen, start-buttons, <span class="Constant">245/grey</span> print screen, <span class="Constant">[edit]</span>, <span class="Constant">232/black</span>, <span class="Constant">94/background-orange</span> clear-line-until screen, edit-button-right, <span class="Constant">94/background-orange</span> - _, col:num<span class="Special"> <- </span>cursor-position screen - at-start-of-copy-button?:bool<span class="Special"> <- </span>equal col, copy-button-left + _, col:num <span class="Special"><-</span> cursor-position screen + at-start-of-copy-button?:bool <span class="Special"><-</span> equal col, copy-button-left assert at-start-of-copy-button?, <span class="Constant">[aaa]</span> print screen, <span class="Constant">[copy]</span>, <span class="Constant">232/black</span>, <span class="Constant">58/background-green</span> clear-line-until screen, copy-button-right, <span class="Constant">58/background-green</span> - _, col:num<span class="Special"> <- </span>cursor-position screen - at-start-of-delete-button?:bool<span class="Special"> <- </span>equal col, delete-button-left + _, col:num <span class="Special"><-</span> cursor-position screen + at-start-of-delete-button?:bool <span class="Special"><-</span> equal col, delete-button-left assert at-start-of-delete-button?, <span class="Constant">[bbb]</span> print screen, <span class="Constant">[delete]</span>, <span class="Constant">232/black</span>, <span class="Constant">52/background-red</span> clear-line-until screen, right, <span class="Constant">52/background-red</span> @@ -375,16 +375,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> sandbox-menu-columns left:num, right:num<span class="muRecipe"> -> </span>edit-button-left:num, edit-button-right:num, copy-button-left:num, copy-button-right:num, delete-button-left:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - start-buttons:num<span class="Special"> <- </span>add left, <span class="Constant">4/space-for-sandbox-index</span> - buttons-space:num<span class="Special"> <- </span>subtract right, start-buttons - button-width:num<span class="Special"> <- </span>divide-with-remainder buttons-space, <span class="Constant">3</span> <span class="Comment"># integer division</span> - buttons-wide-enough?:bool<span class="Special"> <- </span>greater-or-equal button-width, <span class="Constant">8</span> + start-buttons:num <span class="Special"><-</span> add left, <span class="Constant">4/space-for-sandbox-index</span> + buttons-space:num <span class="Special"><-</span> subtract right, start-buttons + button-width:num <span class="Special"><-</span> divide-with-remainder buttons-space,<span class="Constant"> 3</span> <span class="Comment"># integer division</span> + buttons-wide-enough?:bool <span class="Special"><-</span> greater-or-equal button-width,<span class="Constant"> 8</span> assert buttons-wide-enough?, <span class="Constant">[sandbox must be at least 30 or so characters wide]</span> - edit-button-left:num<span class="Special"> <- </span>copy start-buttons - copy-button-left:num<span class="Special"> <- </span>add start-buttons, button-width - edit-button-right:num<span class="Special"> <- </span>subtract copy-button-left, <span class="Constant">1</span> - delete-button-left:num<span class="Special"> <- </span>subtract right, button-width - copy-button-right:num<span class="Special"> <- </span>subtract delete-button-left, <span class="Constant">1</span> + edit-button-left:num <span class="Special"><-</span> copy start-buttons + copy-button-left:num <span class="Special"><-</span> add start-buttons, button-width + edit-button-right:num <span class="Special"><-</span> subtract copy-button-left,<span class="Constant"> 1</span> + delete-button-left:num <span class="Special"><-</span> subtract right, button-width + copy-button-right:num <span class="Special"><-</span> subtract delete-button-left,<span class="Constant"> 1</span> ] <span class="Comment"># print a text 's' to 'editor' in 'color' starting at 'row'</span> @@ -393,58 +393,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> s - column:num<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column - screen-height:num<span class="Special"> <- </span>screen-height screen - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *s + column:num <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column + screen-height:num <span class="Special"><-</span> screen-height screen + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *s <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len + done?:bool <span class="Special"><-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>greater-or-equal row, screen-height + done? <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - c:char<span class="Special"> <- </span>index *s, i + c:char <span class="Special"><-</span> index *s, i <span class="Delimiter">{</span> <span class="Comment"># at right? wrap.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? <span class="Comment"># print wrap icon</span> - wrap-icon:char<span class="Special"> <- </span>copy <span class="Constant">8617/loop-back-to-left</span> + wrap-icon:char <span class="Special"><-</span> copy <span class="Constant">8617/loop-back-to-left</span> print screen, wrap-icon, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Comment"># retry i</span> <span class="Delimiter">}</span> - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># clear rest of line in this window</span> <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-than column, right + done?:bool <span class="Special"><-</span> greater-than column, right <span class="muControl">break-if</span> done? - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> print screen, space - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - was-at-left?:bool<span class="Special"> <- </span>equal column, left + was-at-left?:bool <span class="Special"><-</span> equal column, left clear-line-until screen, right <span class="Delimiter">{</span> <span class="muControl">break-if</span> was-at-left? - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Delimiter">}</span> move-cursor screen, row, left ] @@ -454,32 +454,32 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># read all scenarios, pushing them to end of a list of scenarios</span> - idx:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - curr:&:sandbox<span class="Special"> <- </span>copy <span class="Constant">0</span> - prev:&:sandbox<span class="Special"> <- </span>copy <span class="Constant">0</span> + idx:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + curr:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> + prev:&:sandbox <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - filename:text<span class="Special"> <- </span>to-text idx - contents:text<span class="Special"> <- </span>restore filename + filename:text <span class="Special"><-</span> to-text idx + contents:text <span class="Special"><-</span> restore filename <span class="muControl">break-unless</span> contents <span class="Comment"># stop at first error; assuming file didn't exist</span> <span class="Comment"># todo: handle empty sandbox</span> <span class="Comment"># create new sandbox for file</span> - curr<span class="Special"> <- </span>new <span class="Constant">sandbox:type</span> - *curr<span class="Special"> <- </span>put *curr, <span class="Constant">data:offset</span>, contents + curr <span class="Special"><-</span> new <span class="Constant">sandbox:type</span> + *curr <span class="Special"><-</span> put *curr, <span class="Constant">data:offset</span>, contents <span class="Constant"> <end-restore-sandbox></span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> idx - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, curr + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox:offset</span>, curr <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> idx - *prev<span class="Special"> <- </span>put *prev, <span class="Constant">next-sandbox:offset</span>, curr + *prev <span class="Special"><-</span> put *prev, <span class="Constant">next-sandbox:offset</span>, curr <span class="Delimiter">}</span> - idx<span class="Special"> <- </span>add idx, <span class="Constant">1</span> - prev<span class="Special"> <- </span>copy curr + idx <span class="Special"><-</span> add idx,<span class="Constant"> 1</span> + prev <span class="Special"><-</span> copy curr <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># update sandbox count</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx + *env <span class="Special"><-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, idx ] <span class="Comment"># print the fake sandbox screen to 'screen' with appropriate delimiters</span> @@ -489,62 +489,62 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> sandbox-screen <span class="Comment"># print 'screen:'</span> - row<span class="Special"> <- </span>render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row - screen<span class="Special"> <- </span>move-cursor screen, row, left + row <span class="Special"><-</span> render-text screen, <span class="Constant">[screen:]</span>, left, right, <span class="Constant">245/grey</span>, row + screen <span class="Special"><-</span> move-cursor screen, row, left <span class="Comment"># start printing sandbox-screen</span> - column:num<span class="Special"> <- </span>copy left - s-width:num<span class="Special"> <- </span>screen-width sandbox-screen - s-height:num<span class="Special"> <- </span>screen-height sandbox-screen - buf:&:@:screen-cell<span class="Special"> <- </span>get *sandbox-screen, <span class="Constant">data:offset</span> - stop-printing:num<span class="Special"> <- </span>add left, s-width, <span class="Constant">3</span> - max-column:num<span class="Special"> <- </span>min stop-printing, right - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> - len:num<span class="Special"> <- </span>length *buf - screen-height:num<span class="Special"> <- </span>screen-height screen + column:num <span class="Special"><-</span> copy left + s-width:num <span class="Special"><-</span> screen-width sandbox-screen + s-height:num <span class="Special"><-</span> screen-height sandbox-screen + buf:&:@:screen-cell <span class="Special"><-</span> get *sandbox-screen, <span class="Constant">data:offset</span> + stop-printing:num <span class="Special"><-</span> add left, s-width,<span class="Constant"> 3</span> + max-column:num <span class="Special"><-</span> min stop-printing, right + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + len:num <span class="Special"><-</span> length *buf + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Delimiter">{</span> - done?:bool<span class="Special"> <- </span>greater-or-equal i, len + done?:bool <span class="Special"><-</span> greater-or-equal i, len <span class="muControl">break-if</span> done? - done?<span class="Special"> <- </span>greater-or-equal row, screen-height + done? <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> done? - column<span class="Special"> <- </span>copy left - screen<span class="Special"> <- </span>move-cursor screen, row, column + column <span class="Special"><-</span> copy left + screen <span class="Special"><-</span> move-cursor screen, row, column <span class="Comment"># initial leader for each row: two spaces and a '.'</span> - space:char<span class="Special"> <- </span>copy <span class="Constant">32/space</span> + space:char <span class="Special"><-</span> copy <span class="Constant">32/space</span> print screen, space, <span class="Constant">245/grey</span> print screen, space, <span class="Constant">245/grey</span> - full-stop:char<span class="Special"> <- </span>copy <span class="Constant">46/period</span> + full-stop:char <span class="Special"><-</span> copy <span class="Constant">46/period</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>add left, <span class="Constant">3</span> + column <span class="Special"><-</span> add left,<span class="Constant"> 3</span> <span class="Delimiter">{</span> <span class="Comment"># print row</span> - row-done?:bool<span class="Special"> <- </span>greater-or-equal column, max-column + row-done?:bool <span class="Special"><-</span> greater-or-equal column, max-column <span class="muControl">break-if</span> row-done? - curr:screen-cell<span class="Special"> <- </span>index *buf, i - c:char<span class="Special"> <- </span>get curr, <span class="Constant">contents:offset</span> - color:num<span class="Special"> <- </span>get curr, <span class="Constant">color:offset</span> + curr:screen-cell <span class="Special"><-</span> index *buf, i + c:char <span class="Special"><-</span> get curr, <span class="Constant">contents:offset</span> + color:num <span class="Special"><-</span> get curr, <span class="Constant">color:offset</span> <span class="Delimiter">{</span> <span class="Comment"># damp whites down to grey</span> - white?:bool<span class="Special"> <- </span>equal color, <span class="Constant">7/white</span> + white?:bool <span class="Special"><-</span> equal color, <span class="Constant">7/white</span> <span class="muControl">break-unless</span> white? - color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> + color <span class="Special"><-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> print screen, c, color - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># print final '.'</span> print screen, full-stop, <span class="Constant">245/grey</span> - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="Delimiter">{</span> <span class="Comment"># clear rest of current line</span> - line-done?:bool<span class="Special"> <- </span>greater-than column, right + line-done?:bool <span class="Special"><-</span> greater-than column, right <span class="muControl">break-if</span> line-done? print screen, space - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -554,14 +554,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">12/height</span> <span class="Comment"># define a recipe (no indent for the 'add' line below so column numbers are more obvious)</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">z:num <- add 2, 2</span> <span class="Constant">reply z</span> <span class="Constant">]</span>] <span class="Comment"># sandbox editor contains an instruction without storing outputs</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -580,7 +580,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># make a change (incrementing one of the args to 'add'), then rerun</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">28</span> <span class="Comment"># one past the value of the second arg</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 28</span> <span class="Comment"># one past the value of the second arg</span> press backspace type <span class="Constant">[3]</span> press F4 @@ -608,7 +608,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> <span class="Comment"># right editor contains an instruction</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the code in the editor</span> assume-console [ press F4 @@ -637,37 +637,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> editor-contents editor:&:editor<span class="muRecipe"> -> </span>result:text [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - buf:&:buffer<span class="Special"> <- </span>new-buffer <span class="Constant">80</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + buf:&:buffer <span class="Special"><-</span> new-buffer<span class="Constant"> 80</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> <span class="Comment"># skip § sentinel</span> assert curr, <span class="Constant">[editor without data is illegal; must have at least a sentinel]</span> - curr<span class="Special"> <- </span>next curr - <span class="muControl">return-unless</span> curr, <span class="Constant">0</span> + curr <span class="Special"><-</span> next curr + <span class="muControl">return-unless</span> curr,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - buf<span class="Special"> <- </span>append buf, c - curr<span class="Special"> <- </span>next curr + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + buf <span class="Special"><-</span> append buf, c + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - result<span class="Special"> <- </span>buffer-to-array buf + result <span class="Special"><-</span> buffer-to-array buf ] <span class="muScenario">scenario</span> editor-provides-edited-contents [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[def]</span> ] run [ editor-event-loop screen, console, e - s:text<span class="Special"> <- </span>editor-contents e - <span class="Constant">1</span>:@:char/<span class="Special">raw <- </span>copy *s + s:text <span class="Special"><-</span> editor-contents e + 1:@:char/<span class="Special">raw</span> <span class="Special"><-</span> copy *s ] memory-should-contain [ - <span class="Constant">1</span>:array:character<span class="Special"> <- </span><span class="Constant">[abdefc]</span> + 1:array:character <span class="Special"><-</span> <span class="Constant">[abdefc]</span> ] ] @@ -677,7 +677,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -698,7 +698,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ press enter @@ -706,7 +706,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow <span class="Comment"># while cursor isn't at bottom</span> ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># cursor moves back to bottom</span> screen-should-contain [ @@ -726,28 +726,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><render-recipe-components-end></span> [ - *env<span class="Special"> <- </span>put *env, <span class="Constant">recipe-bottom:offset</span>, row + *env <span class="Special"><-</span> put *env, <span class="Constant">recipe-bottom:offset</span>, row ] <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - down-arrow?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65516/down-arrow</span> + down-arrow?:bool <span class="Special"><-</span> equal k, <span class="Constant">65516/down-arrow</span> <span class="muControl">break-unless</span> down-arrow? - recipe-editor:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - recipe-cursor-row:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">cursor-row:offset</span> - recipe-editor-bottom:num<span class="Special"> <- </span>get *recipe-editor, <span class="Constant">bottom:offset</span> - at-bottom-of-editor?:bool<span class="Special"> <- </span>greater-or-equal recipe-cursor-row, recipe-editor-bottom + recipe-editor:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + recipe-cursor-row:num <span class="Special"><-</span> get *recipe-editor, <span class="Constant">cursor-row:offset</span> + recipe-editor-bottom:num <span class="Special"><-</span> get *recipe-editor, <span class="Constant">bottom:offset</span> + at-bottom-of-editor?:bool <span class="Special"><-</span> greater-or-equal recipe-cursor-row, recipe-editor-bottom <span class="muControl">break-unless</span> at-bottom-of-editor? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -756,9 +756,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-type></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">6/ctrl-f</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">6/ctrl-f</span> <span class="muControl">break-unless</span> page-down? - more-to-scroll?:bool<span class="Special"> <- </span>more-to-scroll? env, screen + more-to-scroll?:bool <span class="Special"><-</span> more-to-scroll? env, screen <span class="muControl">break-if</span> more-to-scroll? <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -767,16 +767,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> more-to-scroll? env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipe-bottom:num<span class="Special"> <- </span>get *env, <span class="Constant">recipe-bottom:offset</span> - height:num<span class="Special"> <- </span>screen-height screen - result<span class="Special"> <- </span>greater-or-equal recipe-bottom, height + recipe-bottom:num <span class="Special"><-</span> get *env, <span class="Constant">recipe-bottom:offset</span> + height:num <span class="Special"><-</span> screen-height screen + result <span class="Special"><-</span> greater-or-equal recipe-bottom, height ] <span class="muScenario">scenario</span> scrolling-down-past-bottom-of-recipe-editor-2 [ <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render assume-console [ <span class="Comment"># add a line</span> @@ -801,7 +801,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[ab</span> <span class="Constant">cd]</span> render-all screen, env, render assume-console [ @@ -813,7 +813,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press down-arrow ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor <span class="Comment"># no scroll on recipe side, cursor moves on sandbox side</span> screen-should-contain [ @@ -832,7 +832,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ <span class="Comment"># create a sandbox</span> @@ -853,7 +853,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -871,7 +871,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor displays again, cursor is in editor</span> @@ -888,22 +888,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-down?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65518/page-down</span> + page-down?:bool <span class="Special"><-</span> equal k, <span class="Constant">65518/page-down</span> <span class="muControl">break-unless</span> page-down? - sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> sandbox <span class="Comment"># slide down if possible</span> <span class="Delimiter">{</span> - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - number-of-sandboxes:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - max:num<span class="Special"> <- </span>subtract number-of-sandboxes, <span class="Constant">1</span> - at-end?:bool<span class="Special"> <- </span>greater-or-equal render-from, max + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + number-of-sandboxes:num <span class="Special"><-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + max:num <span class="Special"><-</span> subtract number-of-sandboxes,<span class="Constant"> 1</span> + at-end?:bool <span class="Special"><-</span> greater-or-equal render-from, max <span class="muControl">jump-if</span> at-end?, <span class="Constant">+finish-event</span> <span class="Comment"># render nothing</span> - render-from<span class="Special"> <- </span>add render-from, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special"><-</span> add render-from,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>, render-from <span class="Delimiter">}</span> hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render + screen <span class="Special"><-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -913,11 +913,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><update-cursor-special-cases></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - scrolling?:bool<span class="Special"> <- </span>greater-or-equal render-from, <span class="Constant">0</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + scrolling?:bool <span class="Special"><-</span> greater-or-equal render-from,<span class="Constant"> 0</span> <span class="muControl">break-unless</span> scrolling? - cursor-column:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> + cursor-column:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + screen <span class="Special"><-</span> move-cursor screen, <span class="Constant">2/row</span>, cursor-column <span class="Comment"># highlighted sandbox will always start at row 2</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -926,15 +926,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-keypress></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-in-focus? - page-up?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65519/page-up</span> + page-up?:bool <span class="Special"><-</span> equal k, <span class="Constant">65519/page-up</span> <span class="muControl">break-unless</span> page-up? - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - at-beginning?:bool<span class="Special"> <- </span>equal render-from, <span class="Constant">-1</span> + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + at-beginning?:bool <span class="Special"><-</span> equal render-from,<span class="Constant"> -1</span> <span class="muControl">break-if</span> at-beginning? - render-from<span class="Special"> <- </span>subtract render-from, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, render-from + render-from <span class="Special"><-</span> subtract render-from,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>, render-from hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render + screen <span class="Special"><-</span> render-sandbox-side screen, env, render show-screen screen <span class="muControl">jump</span> <span class="Constant">+finish-event</span> <span class="Delimiter">}</span> @@ -945,15 +945,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> previous-sandbox env:&:environment, in:&:sandbox<span class="muRecipe"> -> </span>out:&:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> curr, <span class="Constant">0/nil</span> - next:&:sandbox<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + next:&:sandbox <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">return-unless</span> next, <span class="Constant">0/nil</span> - found?:bool<span class="Special"> <- </span>equal next, in + found?:bool <span class="Special"><-</span> equal next, in <span class="muControl">break-if</span> found? - curr<span class="Special"> <- </span>copy next - next<span class="Special"> <- </span>get *curr, <span class="Constant">next-sandbox:offset</span> + curr <span class="Special"><-</span> copy next + next <span class="Special"><-</span> get *curr, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> curr @@ -964,10 +964,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize sandbox side and create a sandbox</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">]</span> <span class="Comment"># create a sandbox</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes:text, <span class="Constant">[add 2, 2]</span> render-all screen, env, render assume-console [ press F4 @@ -979,7 +979,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># cursor moves down on recipe side</span> @@ -997,7 +997,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -1008,7 +1008,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color press F4 ] event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor screen-should-contain [ <span class="Constant"> . run (F4) .</span> @@ -1028,7 +1028,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># sandbox editor hidden; first sandbox displayed</span> @@ -1103,7 +1103,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># back to displaying both sandboxes as well as editor</span> @@ -1125,7 +1125,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># no change</span> @@ -1148,7 +1148,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create a sandbox</span> assume-console [ diff --git a/html/edit/006-sandbox-copy.mu.html b/html/edit/006-sandbox-copy.mu.html index 8f96e319..0ae24c18 100644 --- a/html/edit/006-sandbox-copy.mu.html +++ b/html/edit/006-sandbox-copy.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at left edge of 'copy' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">69</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 69</span> ] run [ event-loop screen, console, env @@ -102,11 +102,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -124,7 +124,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at right edge of 'copy' button (just before 'delete')</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">84</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 84</span> ] run [ event-loop screen, console, env @@ -162,13 +162,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'copy' button</span> <span class="Delimiter">{</span> - copy?:bool<span class="Special"> <- </span>should-attempt-copy? click-row, click-column, env + copy?:bool <span class="Special"><-</span> should-attempt-copy? click-row, click-column, env <span class="muControl">break-unless</span> copy? - copy?, env<span class="Special"> <- </span>try-copy-sandbox click-row, env + copy?, env <span class="Special"><-</span> try-copy-sandbox click-row, env <span class="muControl">break-unless</span> copy? hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> render-sandbox-side screen, env, render + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -179,47 +179,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special"><-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'copy' button?</span> - first-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, copy-button-left:num, copy-button-right:num, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - copy-button-vertical-area?:bool<span class="Special"> <- </span>within-range? click-column, copy-button-left, copy-button-right + sandbox-left-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">right:offset</span> + _, _, copy-button-left:num, copy-button-right:num, _ <span class="Special"><-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + copy-button-vertical-area?:bool <span class="Special"><-</span> within-range? click-column, copy-button-left, copy-button-right <span class="muControl">reply-unless</span> copy-button-vertical-area?, <span class="Constant">0/false</span> <span class="Comment"># finally, is sandbox editor empty?</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - result<span class="Special"> <- </span>empty-editor? current-sandbox + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + result <span class="Special"><-</span> empty-editor? current-sandbox ] <span class="muRecipe">def</span> try-copy-sandbox click-row:num, env:&:environment<span class="muRecipe"> -> </span>clicked-on-copy-button?:bool, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to copy, if the click was actually on the 'copy' button</span> - sandbox:&:sandbox<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox <span class="Special"><-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-copy-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text + clicked-on-copy-button? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + text:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox <span class="Special"><-</span> insert-text current-sandbox, text <span class="Comment"># reset scroll</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Comment"># position cursor in sandbox editor</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> ] <span class="muRecipe">def</span> find-sandbox env:&:environment, click-row:num<span class="muRecipe"> -> </span>result:&:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + curr-sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> curr-sandbox - start:num<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> <- </span>equal click-row, start + start:num <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special"><-</span> equal click-row, start <span class="muControl">return-if</span> found?, curr-sandbox - curr-sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + curr-sandbox <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="muControl">return</span> <span class="Constant">0/not-found</span> @@ -228,30 +228,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> click-on-sandbox-area? click-row:num, click-column:num, env:&:environment<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - on-sandbox-side?:bool<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + sandbox-left-margin:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + on-sandbox-side?:bool <span class="Special"><-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">return-unless</span> on-sandbox-side?, <span class="Constant">0/false</span> - first-sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">return-unless</span> first-sandbox, <span class="Constant">0/false</span> - first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - result<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + result <span class="Special"><-</span> greater-or-equal click-row, first-sandbox-begins ] <span class="muRecipe">def</span> empty-editor? editor:&:editor<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - head:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - first:&:duplex-list:char<span class="Special"> <- </span>next head - result<span class="Special"> <- </span>not first + head:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + first:&:duplex-list:char <span class="Special"><-</span> next head + result <span class="Special"><-</span> not first ] <span class="muRecipe">def</span> within-range? x:num, low:num, high:num<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - not-too-far-left?:bool<span class="Special"> <- </span>greater-or-equal x, low - not-too-far-right?:bool<span class="Special"> <- </span>lesser-or-equal x, high - result<span class="Special"> <- </span>and not-too-far-left? not-too-far-right? + not-too-far-left?:bool <span class="Special"><-</span> greater-or-equal x, low + not-too-far-right?:bool <span class="Special"><-</span> lesser-or-equal x, high + result <span class="Special"><-</span> and not-too-far-left? not-too-far-right? ] <span class="muScenario">scenario</span> copy-fails-if-sandbox-editor-not-empty [ @@ -259,11 +259,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -281,9 +281,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># type something into the sandbox editor, then click on the 'copy' button</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">70</span> <span class="Comment"># put cursor in sandbox editor</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 70</span> <span class="Comment"># put cursor in sandbox editor</span> type <span class="Constant">[0]</span> <span class="Comment"># type something</span> - left-click <span class="Constant">3</span>, <span class="Constant">70</span> <span class="Comment"># click 'copy' button</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 70</span> <span class="Comment"># click 'copy' button</span> ] run [ event-loop screen, console, env diff --git a/html/edit/007-sandbox-delete.mu.html b/html/edit/007-sandbox-delete.mu.html index ffae21e3..5fbf7441 100644 --- a/html/edit/007-sandbox-delete.mu.html +++ b/html/edit/007-sandbox-delete.mu.html @@ -38,10 +38,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> <span class="Comment"># run a few commands</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 80</span> type <span class="Constant">[divide-with-remainder 11, 3]</span> press F4 type <span class="Constant">[add 2, 2]</span> @@ -65,7 +65,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete second sandbox by clicking on left edge of 'delete' button</span> assume-console [ - left-click <span class="Constant">7</span>, <span class="Constant">85</span> + left-click<span class="Constant"> 7</span>,<span class="Constant"> 85</span> ] run [ event-loop screen, console, env @@ -83,7 +83,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete first sandbox by clicking at right edge of 'delete' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -100,13 +100,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'delete' button</span> <span class="Delimiter">{</span> - delete?:bool<span class="Special"> <- </span>should-attempt-delete? click-row, click-column, env + delete?:bool <span class="Special"><-</span> should-attempt-delete? click-row, click-column, env <span class="muControl">break-unless</span> delete? - delete?, env<span class="Special"> <- </span>try-delete-sandbox click-row, env + delete?, env <span class="Special"><-</span> try-delete-sandbox click-row, env <span class="muControl">break-unless</span> delete? hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> render-sandbox-side screen, env, render + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -117,66 +117,66 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special"><-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'copy' button?</span> - first-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - _, _, _, _, delete-button-left:num<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - result<span class="Special"> <- </span>within-range? click-column, delete-button-left, sandbox-right-margin + sandbox-left-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">right:offset</span> + _, _, _, _, delete-button-left:num <span class="Special"><-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + result <span class="Special"><-</span> within-range? click-column, delete-button-left, sandbox-right-margin ] <span class="muRecipe">def</span> try-delete-sandbox click-row:num, env:&:environment<span class="muRecipe"> -> </span>clicked-on-delete-button?:bool, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to delete, if the click was actually on the 'delete' button</span> - sandbox:&:sandbox<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox <span class="Special"><-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-delete-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - env<span class="Special"> <- </span>delete-sandbox env, sandbox + clicked-on-delete-button? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + env <span class="Special"><-</span> delete-sandbox env, sandbox ] <span class="muRecipe">def</span> delete-sandbox env:&:environment, sandbox:&:sandbox<span class="muRecipe"> -> </span>env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - curr-sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - first-sandbox?:bool<span class="Special"> <- </span>equal curr-sandbox, sandbox + curr-sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + first-sandbox?:bool <span class="Special"><-</span> equal curr-sandbox, sandbox <span class="Delimiter">{</span> <span class="Comment"># first sandbox? pop</span> <span class="muControl">break-unless</span> first-sandbox? - next-sandbox:&:sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox:offset</span>, next-sandbox + next-sandbox:&:sandbox <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox:offset</span>, next-sandbox <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># not first sandbox?</span> <span class="muControl">break-if</span> first-sandbox? - prev-sandbox:&:sandbox<span class="Special"> <- </span>copy curr-sandbox - curr-sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + prev-sandbox:&:sandbox <span class="Special"><-</span> copy curr-sandbox + curr-sandbox <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="Delimiter">{</span> assert curr-sandbox, <span class="Constant">[sandbox not found! something is wrong.]</span> - found?:bool<span class="Special"> <- </span>equal curr-sandbox, sandbox + found?:bool <span class="Special"><-</span> equal curr-sandbox, sandbox <span class="muControl">break-if</span> found? - prev-sandbox<span class="Special"> <- </span>copy curr-sandbox - curr-sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + prev-sandbox <span class="Special"><-</span> copy curr-sandbox + curr-sandbox <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># snip sandbox out of its list</span> - next-sandbox:&:sandbox<span class="Special"> <- </span>get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> - *prev-sandbox<span class="Special"> <- </span>put *prev-sandbox, <span class="Constant">next-sandbox:offset</span>, next-sandbox + next-sandbox:&:sandbox <span class="Special"><-</span> get *curr-sandbox, <span class="Constant">next-sandbox:offset</span> + *prev-sandbox <span class="Special"><-</span> put *prev-sandbox, <span class="Constant">next-sandbox:offset</span>, next-sandbox <span class="Delimiter">}</span> <span class="Comment"># update sandbox count</span> - sandbox-count:num<span class="Special"> <- </span>get *env, <span class="Constant">number-of-sandboxes:offset</span> - sandbox-count<span class="Special"> <- </span>subtract sandbox-count, <span class="Constant">1</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count + sandbox-count:num <span class="Special"><-</span> get *env, <span class="Constant">number-of-sandboxes:offset</span> + sandbox-count <span class="Special"><-</span> subtract sandbox-count,<span class="Constant"> 1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">number-of-sandboxes:offset</span>, sandbox-count <span class="Comment"># reset scroll if deleted sandbox was last</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> next-sandbox - render-from:num<span class="Special"> <- </span>get *env, <span class="Constant">render-from:offset</span> - reset-scroll?:bool<span class="Special"> <- </span>equal render-from, sandbox-count + render-from:num <span class="Special"><-</span> get *env, <span class="Constant">render-from:offset</span> + reset-scroll?:bool <span class="Special"><-</span> equal render-from, sandbox-count <span class="muControl">break-unless</span> reset-scroll? - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Delimiter">}</span> ] @@ -185,7 +185,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -208,7 +208,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">6</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 6</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -230,7 +230,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -253,7 +253,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -275,7 +275,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -299,7 +299,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 99</span> ] run [ event-loop screen, console, env @@ -322,7 +322,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -347,7 +347,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># delete the second sandbox, then try to scroll down twice</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">99</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 99</span> press page-down press page-down ] diff --git a/html/edit/008-sandbox-edit.mu.html b/html/edit/008-sandbox-edit.mu.html index 6b8599b5..43481161 100644 --- a/html/edit/008-sandbox-edit.mu.html +++ b/html/edit/008-sandbox-edit.mu.html @@ -39,11 +39,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -61,7 +61,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at left edge of 'edit' button</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -99,11 +99,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -121,7 +121,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click at right edge of 'edit' button (just before 'copy')</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">68</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 68</span> ] run [ event-loop screen, console, env @@ -157,13 +157,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># support 'edit' button</span> <span class="Delimiter">{</span> - edit?:bool<span class="Special"> <- </span>should-attempt-edit? click-row, click-column, env + edit?:bool <span class="Special"><-</span> should-attempt-edit? click-row, click-column, env <span class="muControl">break-unless</span> edit? - edit?, env<span class="Special"> <- </span>try-edit-sandbox click-row, env + edit?, env <span class="Special"><-</span> try-edit-sandbox click-row, env <span class="muControl">break-unless</span> edit? hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> render-sandbox-side screen, env, render + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> <span class="Delimiter">}</span> @@ -174,37 +174,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># are we below the sandbox editor?</span> - click-sandbox-area?:bool<span class="Special"> <- </span>click-on-sandbox-area? click-row, click-column, env + click-sandbox-area?:bool <span class="Special"><-</span> click-on-sandbox-area? click-row, click-column, env <span class="muControl">reply-unless</span> click-sandbox-area?, <span class="Constant">0/false</span> <span class="Comment"># narrower, is the click in the columns spanning the 'edit' button?</span> - first-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> + first-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> assert first-sandbox, <span class="Constant">[!!]</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">left:offset</span> - sandbox-right-margin:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">right:offset</span> - edit-button-left:num, edit-button-right:num, _<span class="Special"> <- </span>sandbox-menu-columns sandbox-left-margin, sandbox-right-margin - edit-button-vertical-area?:bool<span class="Special"> <- </span>within-range? click-column, edit-button-left, edit-button-right + sandbox-left-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">left:offset</span> + sandbox-right-margin:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">right:offset</span> + edit-button-left:num, edit-button-right:num, _ <span class="Special"><-</span> sandbox-menu-columns sandbox-left-margin, sandbox-right-margin + edit-button-vertical-area?:bool <span class="Special"><-</span> within-range? click-column, edit-button-left, edit-button-right <span class="muControl">reply-unless</span> edit-button-vertical-area?, <span class="Constant">0/false</span> <span class="Comment"># finally, is sandbox editor empty?</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - result<span class="Special"> <- </span>empty-editor? current-sandbox + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + result <span class="Special"><-</span> empty-editor? current-sandbox ] <span class="muRecipe">def</span> try-edit-sandbox click-row:num, env:&:environment<span class="muRecipe"> -> </span>clicked-on-edit-button?:bool, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># identify the sandbox to edit, if the click was actually on the 'edit' button</span> - sandbox:&:sandbox<span class="Special"> <- </span>find-sandbox env, click-row + sandbox:&:sandbox <span class="Special"><-</span> find-sandbox env, click-row <span class="muControl">return-unless</span> sandbox, <span class="Constant">0/false</span> - clicked-on-edit-button?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + clicked-on-edit-button? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Comment"># 'edit' button = 'copy' button + 'delete' button</span> - text:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - current-sandbox:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">current-sandbox:offset</span> - current-sandbox<span class="Special"> <- </span>insert-text current-sandbox, text - env<span class="Special"> <- </span>delete-sandbox env, sandbox + text:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + current-sandbox:&:editor <span class="Special"><-</span> get *env, <span class="Constant">current-sandbox:offset</span> + current-sandbox <span class="Special"><-</span> insert-text current-sandbox, text + env <span class="Special"><-</span> delete-sandbox env, sandbox <span class="Comment"># reset scroll</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">render-from:offset</span>, <span class="Constant">-1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">render-from:offset</span>,<span class="Constant"> -1</span> <span class="Comment"># position cursor in sandbox editor</span> - *env<span class="Special"> <- </span>put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">sandbox-in-focus?:offset</span>, <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> sandbox-with-print-can-be-edited [ @@ -213,7 +213,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> <span class="Comment"># right editor contains an instruction</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[print-integer screen, 4]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -236,7 +236,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the sandbox</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">65</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 65</span> ] run [ event-loop screen, console, env @@ -255,7 +255,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes and scroll to second</span> assume-console [ @@ -279,7 +279,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the second sandbox</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -302,7 +302,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># initialize environment</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> render-all screen, env, render <span class="Comment"># create 2 sandboxes</span> assume-console [ @@ -327,7 +327,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># edit the second sandbox, then resave</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">60</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 60</span> press F4 ] run [ diff --git a/html/edit/009-sandbox-test.mu.html b/html/edit/009-sandbox-test.mu.html index 1c350a57..30c731ea 100644 --- a/html/edit/009-sandbox-test.mu.html +++ b/html/edit/009-sandbox-test.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> reply 4</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes:text, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes:text, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -62,7 +62,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the '4' in the result</span> assume-console [ - left-click <span class="Constant">5</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env @@ -80,7 +80,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor should remain unmoved</span> run [ - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] screen-should-contain [ @@ -98,7 +98,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># now change the result</span> <span class="Comment"># then rerun</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">11</span> <span class="Comment"># cursor to end of line</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 11</span> <span class="Comment"># cursor to end of line</span> press backspace type <span class="Constant">[3]</span> press F4 @@ -128,19 +128,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># include expected response when saving or restoring a sandbox</span> <span class="muRecipe">before</span> <span class="Constant"><end-save-sandbox></span> [ <span class="Delimiter">{</span> - expected-response:text<span class="Special"> <- </span>get *curr, <span class="Constant">expected-response:offset</span> + expected-response:text <span class="Special"><-</span> get *curr, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response - filename<span class="Special"> <- </span>append filename, <span class="Constant">[.out]</span> + filename <span class="Special"><-</span> append filename, <span class="Constant">[.out]</span> save filename, expected-response <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><end-restore-sandbox></span> [ <span class="Delimiter">{</span> - filename<span class="Special"> <- </span>append filename, <span class="Constant">[.out]</span> - contents<span class="Special"> <- </span>restore filename + filename <span class="Special"><-</span> append filename, <span class="Constant">[.out]</span> + contents <span class="Special"><-</span> restore filename <span class="muControl">break-unless</span> contents - *curr<span class="Special"> <- </span>put *curr, <span class="Constant">expected-response:offset</span>, contents + *curr <span class="Special"><-</span> put *curr, <span class="Constant">expected-response:offset</span>, contents <span class="Delimiter">}</span> ] @@ -148,25 +148,25 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># check if it's inside the output of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:bool<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num <span class="Special"><-</span> get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool <span class="Special"><-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:bool<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num <span class="Special"><-</span> get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool <span class="Special"><-</span> greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose output is being clicked on</span> - sandbox:&:sandbox<span class="Special"> <- </span>find-click-in-sandbox-output env, click-row + sandbox:&:sandbox <span class="Special"><-</span> find-click-in-sandbox-output env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its expected-response, and save session</span> - sandbox<span class="Special"> <- </span>toggle-expected-response sandbox + sandbox <span class="Special"><-</span> toggle-expected-response sandbox save-sandboxes env hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> render-sandbox-side screen, env, render + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> @@ -177,24 +177,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> - sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:bool<span class="Special"> <- </span>greater-or-equal click-row, start + sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + start:num <span class="Special"><-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool <span class="Special"><-</span> greater-or-equal click-row, start assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:&:sandbox<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox <span class="Special"><-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:num<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> <- </span>lesser-than click-row, next-start + next-start:num <span class="Special"><-</span> get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special"><-</span> lesser-than click-row, next-start <span class="muControl">break-if</span> found? - sandbox<span class="Special"> <- </span>copy next-sandbox + sandbox <span class="Special"><-</span> copy next-sandbox <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># return sandbox if click is in its output region</span> - response-starting-row:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> + response-starting-row:num <span class="Special"><-</span> get *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span> <span class="muControl">return-unless</span> response-starting-row, <span class="Constant">0/no-click-in-sandbox-output</span> - click-in-response?:bool<span class="Special"> <- </span>greater-or-equal click-row, response-starting-row + click-in-response?:bool <span class="Special"><-</span> greater-or-equal click-row, response-starting-row <span class="muControl">return-unless</span> click-in-response?, <span class="Constant">0/no-click-in-sandbox-output</span> <span class="muControl">return</span> sandbox ] @@ -202,17 +202,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> toggle-expected-response sandbox:&:sandbox<span class="muRecipe"> -> </span>sandbox:&:sandbox [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - expected-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + expected-response:text <span class="Special"><-</span> get *sandbox, <span class="Constant">expected-response:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if expected-response is set, reset</span> <span class="muControl">break-unless</span> expected-response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">expected-response:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">expected-response:offset</span>,<span class="Constant"> 0</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># if not, set expected response to the current response</span> <span class="muControl">break-if</span> expected-response - response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">response:offset</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">expected-response:offset</span>, response + response:text <span class="Special"><-</span> get *sandbox, <span class="Constant">response:offset</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">expected-response:offset</span>, response <span class="Delimiter">}</span> ] @@ -220,24 +220,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-response></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> sandbox-response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row - expected-response:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">expected-response:offset</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, row + expected-response:text <span class="Special"><-</span> get *sandbox, <span class="Constant">expected-response:offset</span> <span class="muControl">break-unless</span> expected-response <span class="Comment"># fall-through to print in grey</span> - response-is-expected?:bool<span class="Special"> <- </span>equal expected-response, sandbox-response + response-is-expected?:bool <span class="Special"><-</span> equal expected-response, sandbox-response <span class="Delimiter">{</span> <span class="muControl">break-if</span> response-is-expected?:bool - row, screen<span class="Special"> <- </span>render-text screen, sandbox-response, left, right, <span class="Constant">1/red</span>, row + row, screen <span class="Special"><-</span> render-text screen, sandbox-response, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> response-is-expected?:bool - row, screen<span class="Special"> <- </span>render-text screen, sandbox-response, left, right, <span class="Constant">2/green</span>, row + row, screen <span class="Special"><-</span> render-text screen, sandbox-response, left, right, <span class="Constant">2/green</span>, row <span class="Delimiter">}</span> <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><end-render-sandbox-reset-hidden></span> [ - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, <span class="Constant">0</span> + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> ] </pre> </body> diff --git a/html/edit/010-sandbox-trace.mu.html b/html/edit/010-sandbox-trace.mu.html index ece61dee..66943462 100644 --- a/html/edit/010-sandbox-trace.mu.html +++ b/html/edit/010-sandbox-trace.mu.html @@ -40,11 +40,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> ]] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -61,11 +61,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the code in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env - cursor:char<span class="Special"> <- </span>copy <span class="Constant">9251/␣</span> + cursor:char <span class="Special"><-</span> copy <span class="Constant">9251/␣</span> print screen, cursor ] <span class="Comment"># trace now printed and cursor shouldn't have budged</span> @@ -87,7 +87,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click again on the same region</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env @@ -110,12 +110,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># basic recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> stash [abc]</span> - <span class="muControl">reply</span> <span class="Constant">4</span> + <span class="muControl">reply</span><span class="Constant"> 4</span> ]] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run it</span> assume-console [ press F4 @@ -133,7 +133,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the code in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] run [ event-loop screen, console, env @@ -157,11 +157,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[stash 123456789]</span> <span class="Comment"># create and expand the trace</span> assume-console [ press F4 - left-click <span class="Constant">4</span>, <span class="Constant">51</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 51</span> ] event-loop screen, console, env screen-should-contain [ @@ -174,7 +174,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># click on the stash under the edit-button region (or any of the other buttons, really)</span> assume-console [ - left-click <span class="Constant">5</span>, <span class="Constant">57</span> + left-click<span class="Constant"> 5</span>,<span class="Constant"> 57</span> ] run [ event-loop screen, console, env @@ -199,37 +199,37 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox, env:&:environment, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, _, fake-screen:&:screen, trace:text<span class="Special"> <- </span>run-sandboxed data - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace + data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, _, fake-screen:&:screen, trace:text <span class="Special"><-</span> run-sandboxed data + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">trace:offset</span>, trace ] <span class="Comment"># clicks on sandbox code toggle its display-trace? flag</span> <span class="muRecipe">after</span> <span class="Constant"><global-touch></span> [ <span class="Comment"># check if it's inside the code of any sandbox</span> <span class="Delimiter">{</span> - sandbox-left-margin:num<span class="Special"> <- </span>get *current-sandbox, <span class="Constant">left:offset</span> - click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - on-sandbox-side?:bool<span class="Special"> <- </span>greater-or-equal click-column, sandbox-left-margin + sandbox-left-margin:num <span class="Special"><-</span> get *current-sandbox, <span class="Constant">left:offset</span> + click-column:num <span class="Special"><-</span> get t, <span class="Constant">column:offset</span> + on-sandbox-side?:bool <span class="Special"><-</span> greater-or-equal click-column, sandbox-left-margin <span class="muControl">break-unless</span> on-sandbox-side? - first-sandbox:&:sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> + first-sandbox:&:sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> <span class="muControl">break-unless</span> first-sandbox - first-sandbox-begins:num<span class="Special"> <- </span>get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> - below-sandbox-editor?:bool<span class="Special"> <- </span>greater-or-equal click-row, first-sandbox-begins + first-sandbox-begins:num <span class="Special"><-</span> get *first-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-row:num <span class="Special"><-</span> get t, <span class="Constant">row:offset</span> + below-sandbox-editor?:bool <span class="Special"><-</span> greater-or-equal click-row, first-sandbox-begins <span class="muControl">break-unless</span> below-sandbox-editor? <span class="Comment"># identify the sandbox whose code is being clicked on</span> - sandbox:&:sandbox<span class="Special"> <- </span>find-click-in-sandbox-code env, click-row + sandbox:&:sandbox <span class="Special"><-</span> find-click-in-sandbox-code env, click-row <span class="muControl">break-unless</span> sandbox <span class="Comment"># toggle its display-trace? property</span> - x:bool<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> - x<span class="Special"> <- </span>not x - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">display-trace?:offset</span>, x + x:bool <span class="Special"><-</span> get *sandbox, <span class="Constant">display-trace?:offset</span> + x <span class="Special"><-</span> not x + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">display-trace?:offset</span>, x hide-screen screen - screen<span class="Special"> <- </span>render-sandbox-side screen, env, render - screen<span class="Special"> <- </span>update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env + screen <span class="Special"><-</span> render-sandbox-side screen, env, render + screen <span class="Special"><-</span> update-cursor screen, recipes, current-sandbox, sandbox-in-focus?, env <span class="Comment"># no change in cursor</span> show-screen screen <span class="muControl">loop</span> <span class="Constant">+next-event</span> @@ -240,26 +240,26 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Comment"># assert click-row >= sandbox.starting-row-on-screen</span> - sandbox<span class="Special"> <- </span>get *env, <span class="Constant">sandbox:offset</span> - start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - clicked-on-sandboxes?:bool<span class="Special"> <- </span>greater-or-equal click-row, start + sandbox <span class="Special"><-</span> get *env, <span class="Constant">sandbox:offset</span> + start:num <span class="Special"><-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + clicked-on-sandboxes?:bool <span class="Special"><-</span> greater-or-equal click-row, start assert clicked-on-sandboxes?, <span class="Constant">[extract-sandbox called on click to sandbox editor]</span> <span class="Comment"># while click-row < sandbox.next-sandbox.starting-row-on-screen</span> <span class="Delimiter">{</span> - next-sandbox:&:sandbox<span class="Special"> <- </span>get *sandbox, <span class="Constant">next-sandbox:offset</span> + next-sandbox:&:sandbox <span class="Special"><-</span> get *sandbox, <span class="Constant">next-sandbox:offset</span> <span class="muControl">break-unless</span> next-sandbox - next-start:num<span class="Special"> <- </span>get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> - found?:bool<span class="Special"> <- </span>lesser-than click-row, next-start + next-start:num <span class="Special"><-</span> get *next-sandbox, <span class="Constant">starting-row-on-screen:offset</span> + found?:bool <span class="Special"><-</span> lesser-than click-row, next-start <span class="muControl">break-if</span> found? - sandbox<span class="Special"> <- </span>copy next-sandbox + sandbox <span class="Special"><-</span> copy next-sandbox <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># return sandbox if click is in its code region</span> - code-ending-row:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> - click-above-response?:bool<span class="Special"> <- </span>lesser-than click-row, code-ending-row - start:num<span class="Special"> <- </span>get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> - click-below-menu?:bool<span class="Special"> <- </span>greater-than click-row, start - click-on-sandbox-code?:bool<span class="Special"> <- </span>and click-above-response?, click-below-menu? + code-ending-row:num <span class="Special"><-</span> get *sandbox, <span class="Constant">code-ending-row-on-screen:offset</span> + click-above-response?:bool <span class="Special"><-</span> lesser-than click-row, code-ending-row + start:num <span class="Special"><-</span> get *sandbox, <span class="Constant">starting-row-on-screen:offset</span> + click-below-menu?:bool <span class="Special"><-</span> greater-than click-row, start + click-on-sandbox-code?:bool <span class="Special"><-</span> and click-above-response?, click-below-menu? <span class="Delimiter">{</span> <span class="muControl">break-if</span> click-on-sandbox-code? <span class="muControl">return</span> <span class="Constant">0/no-click-in-sandbox-output</span> @@ -270,11 +270,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># when rendering a sandbox, dump its trace before response/warning if display-trace? property is set</span> <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-results></span> [ <span class="Delimiter">{</span> - display-trace?:bool<span class="Special"> <- </span>get *sandbox, <span class="Constant">display-trace?:offset</span> + display-trace?:bool <span class="Special"><-</span> get *sandbox, <span class="Constant">display-trace?:offset</span> <span class="muControl">break-unless</span> display-trace? - sandbox-trace:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">trace:offset</span> + sandbox-trace:text <span class="Special"><-</span> get *sandbox, <span class="Constant">trace:offset</span> <span class="muControl">break-unless</span> sandbox-trace <span class="Comment"># nothing to print; move on</span> - row, screen<span class="Special"> <- </span>render-text screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row + row, screen <span class="Special"><-</span> render-text screen, sandbox-trace, left, right, <span class="Constant">245/grey</span>, row <span class="Delimiter">}</span> <span class="Constant"> <render-sandbox-trace-done></span> ] diff --git a/html/edit/011-errors.mu.html b/html/edit/011-errors.mu.html index 146b2b15..2bdf811a 100644 --- a/html/edit/011-errors.mu.html +++ b/html/edit/011-errors.mu.html @@ -43,24 +43,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-recipes env:&:environment, screen:&:screen<span class="muRecipe"> -> </span>errors-found?:bool, env:&:environment, screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - recipes:&:editor<span class="Special"> <- </span>get *env, <span class="Constant">recipes:offset</span> - in:text<span class="Special"> <- </span>editor-contents recipes + recipes:&:editor <span class="Special"><-</span> get *env, <span class="Constant">recipes:offset</span> + in:text <span class="Special"><-</span> editor-contents recipes save <span class="Constant">[recipes.mu]</span>, in - recipe-errors:text<span class="Special"> <- </span>reload in - *env<span class="Special"> <- </span>put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors + recipe-errors:text <span class="Special"><-</span> reload in + *env <span class="Special"><-</span> put *env, <span class="Constant">recipe-errors:offset</span>, recipe-errors <span class="Comment"># if recipe editor has errors, stop</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-errors update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> - errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + errors-found? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - errors-found?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + errors-found? <span class="Special"><-</span> copy <span class="Constant">0/false</span> ] <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ - trace <span class="Constant">11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> - recipe-errors:text<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> + trace<span class="Constant"> 11</span>, <span class="Constant">[app]</span>, <span class="Constant">[render status]</span> + recipe-errors:text <span class="Special"><-</span> get *env, <span class="Constant">recipe-errors:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> recipe-errors update-status screen, <span class="Constant">[errors found ]</span>, <span class="Constant">1/red</span> @@ -69,9 +69,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">before</span> <span class="Constant"><render-recipe-components-end></span> [ <span class="Delimiter">{</span> - recipe-errors:text<span class="Special"> <- </span>get *env, <span class="Constant">recipe-errors:offset</span> + recipe-errors:text <span class="Special"><-</span> get *env, <span class="Constant">recipe-errors:offset</span> <span class="muControl">break-unless</span> recipe-errors - row, screen<span class="Special"> <- </span>render-text screen, recipe-errors, left, right, <span class="Constant">1/red</span>, row + row, screen <span class="Special"><-</span> render-text screen, recipe-errors, left, right, <span class="Constant">1/red</span>, row <span class="Delimiter">}</span> ] @@ -80,30 +80,30 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><programming-environment-initialization></span> [ - *result<span class="Special"> <- </span>put *result, <span class="Constant">error-index:offset</span>, <span class="Constant">-1</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">error-index:offset</span>,<span class="Constant"> -1</span> ] <span class="muRecipe">after</span> <span class="Constant"><run-sandboxes-begin></span> [ - *env<span class="Special"> <- </span>put *env, <span class="Constant">error-index:offset</span>, <span class="Constant">-1</span> + *env <span class="Special"><-</span> put *env, <span class="Constant">error-index:offset</span>,<span class="Constant"> -1</span> ] <span class="muRecipe">before</span> <span class="Constant"><run-sandboxes-end></span> [ <span class="Delimiter">{</span> - error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:bool<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special"><-</span> get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool <span class="Special"><-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? - errors-found?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + errors-found? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="Delimiter">}</span> ] <span class="muRecipe">before</span> <span class="Constant"><render-components-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-if</span> recipe-errors - error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - sandboxes-completed-successfully?:bool<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special"><-</span> get *env, <span class="Constant">error-index:offset</span> + sandboxes-completed-successfully?:bool <span class="Special"><-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-if</span> sandboxes-completed-successfully? - error-index-text:text<span class="Special"> <- </span>to-text error-index - status:text<span class="Special"> <- </span>interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text + error-index-text:text <span class="Special"><-</span> to-text error-index + status:text <span class="Special"><-</span> interpolate <span class="Constant">[errors found (_) ]</span>, error-index-text update-status screen, status, <span class="Constant">1/red</span> <span class="Delimiter">}</span> ] @@ -115,35 +115,35 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def!</span> update-sandbox sandbox:&:sandbox, env:&:environment, idx:num<span class="muRecipe"> -> </span>sandbox:&:sandbox, env:&:environment [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - data:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">data:offset</span> - response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool<span class="Special"> <- </span>run-sandboxed data - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response:offset</span>, response - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">screen:offset</span>, fake-screen - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">trace:offset</span>, trace + data:text <span class="Special"><-</span> get *sandbox, <span class="Constant">data:offset</span> + response:text, errors:text, fake-screen:&:screen, trace:text, completed?:bool <span class="Special"><-</span> run-sandboxed data + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response:offset</span>, response + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">errors:offset</span>, errors + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">screen:offset</span>, fake-screen + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">trace:offset</span>, trace <span class="Delimiter">{</span> <span class="muControl">break-if</span> errors <span class="muControl">break-if</span> completed?:bool - errors<span class="Special"> <- </span>new <span class="Constant">[took too long!</span> + errors <span class="Special"><-</span> new <span class="Constant">[took too long!</span> <span class="Constant">]</span> - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">errors:offset</span>, errors + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">errors:offset</span>, errors <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> errors - error-index:num<span class="Special"> <- </span>get *env, <span class="Constant">error-index:offset</span> - error-not-set?:bool<span class="Special"> <- </span>equal error-index, <span class="Constant">-1</span> + error-index:num <span class="Special"><-</span> get *env, <span class="Constant">error-index:offset</span> + error-not-set?:bool <span class="Special"><-</span> equal error-index,<span class="Constant"> -1</span> <span class="muControl">break-unless</span> error-not-set? - *env<span class="Special"> <- </span>put *env, <span class="Constant">error-index:offset</span>, idx + *env <span class="Special"><-</span> put *env, <span class="Constant">error-index:offset</span>, idx <span class="Delimiter">}</span> ] <span class="Comment"># make sure we render any trace</span> <span class="muRecipe">after</span> <span class="Constant"><render-sandbox-trace-done></span> [ <span class="Delimiter">{</span> - sandbox-errors:text<span class="Special"> <- </span>get *sandbox, <span class="Constant">errors:offset</span> + sandbox-errors:text <span class="Special"><-</span> get *sandbox, <span class="Constant">errors:offset</span> <span class="muControl">break-unless</span> sandbox-errors - *sandbox<span class="Special"> <- </span>put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>, <span class="Constant">0</span> <span class="Comment"># no response</span> - row, screen<span class="Special"> <- </span>render-text screen, sandbox-errors, left, right, <span class="Constant">1/red</span>, row + *sandbox <span class="Special"><-</span> put *sandbox, <span class="Constant">response-starting-row-on-screen:offset</span>,<span class="Constant"> 0</span> <span class="Comment"># no response</span> + row, screen <span class="Special"><-</span> render-text screen, sandbox-errors, left, right, <span class="Constant">1/red</span>, row <span class="Comment"># don't try to print anything more for this sandbox</span> <span class="muControl">jump</span> <span class="Constant">+render-sandbox-end</span> <span class="Delimiter">}</span> @@ -153,11 +153,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> get 123:num, foo:offset</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -193,9 +193,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 1</span> type <span class="Constant">[get foo, x:offset]</span> press F4 @@ -216,9 +216,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[]</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">80</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 80</span> <span class="Comment"># create invalid sandbox 2</span> type <span class="Constant">[get foo, x:offset]</span> press F4 @@ -242,7 +242,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, <span class="Constant">[get foo, x:offset]</span> <span class="Comment"># invalid</span> assume-console [ press F4 <span class="Comment"># generate error</span> ] @@ -250,7 +250,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color event-loop screen, console, env ] assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">58</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 58</span> press ctrl-k type <span class="Constant">[add 2, 2]</span> <span class="Comment"># valid code</span> press F4 <span class="Comment"># update sandbox</span> @@ -276,13 +276,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># define a shape-shifting recipe with an error</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo x:_elem -> z:_elem [</span> <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="Constant">y:&:num <- copy 0</span> <span class="Constant">z <- add x, y</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo 2]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 2]</span> assume-console [ press F4 ] @@ -324,12 +324,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># overload a well-known shape-shifting recipe</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe length l:&:list:_elem -> n:num [</span> <span class="Constant">]</span>] <span class="Comment"># call code that uses other variants of it, but not it itself</span> - sandbox:text<span class="Special"> <- </span>new <span class="Constant">[x:&:list:num <- copy 0</span> + sandbox:text <span class="Special"><-</span> new <span class="Constant">[x:&:list:num <- copy 0</span> <span class="Constant">to-text x]</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, sandbox + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, sandbox <span class="Comment"># run it once</span> assume-console [ press F4 @@ -384,11 +384,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -410,11 +410,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> <span class="Comment"># recipe is incomplete (unbalanced '[')</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo \\[</span> <span class="Constant"> x <- copy 0</span> <span class="Constant">]</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -437,13 +437,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:&:point <- new point:type</span> <span class="Constant"> get x:&:point, 1:offset</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -469,14 +469,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num <- copy 0</span> <span class="Constant"> y:&:point <- new point:type</span> <span class="Constant"> get *y:&:point, x:num</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -504,12 +504,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> <span class="Comment"># try to run a file with an error</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">15/height</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[ </span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[ </span> <span class="Constant">recipe foo [</span> <span class="Constant"> local-scope</span> <span class="Constant"> x:num <- copy y:num</span> <span class="Constant">]</span>] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> assume-console [ press F4 ] @@ -550,8 +550,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, sandbox + sandbox:text <span class="Special"><-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors</span> assume-console [ press F4 @@ -612,8 +612,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># right editor contains an illegal instruction</span> - sandbox:text<span class="Special"> <- </span>new <span class="Constant">[get 1234:num, foo:offset]</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, <span class="Constant">[]</span>, sandbox + sandbox:text <span class="Special"><-</span> new <span class="Constant">[get 1234:num, foo:offset]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, <span class="Constant">[]</span>, sandbox <span class="Comment"># run the code in the editors multiple times</span> assume-console [ press F4 @@ -642,13 +642,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">20/height</span> <span class="Comment"># left editor is empty</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo [</span> <span class="Constant"> {</span> <span class="Constant"> loop</span> <span class="Constant"> }</span> <span class="Constant">]</span>] <span class="Comment"># right editor contains an instruction</span> - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo]</span> <span class="Comment"># run the sandbox</span> assume-console [ press F4 @@ -673,15 +673,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color trace-until <span class="Constant">100/app</span> <span class="Comment"># trace too long</span> assume-screen <span class="Constant">100/width</span>, <span class="Constant">10/height</span> <span class="Comment"># generate a stash and a error</span> - recipes:text<span class="Special"> <- </span>new <span class="Constant">[recipe foo [</span> + recipes:text <span class="Special"><-</span> new <span class="Constant">[recipe foo [</span> <span class="Constant">local-scope</span> <span class="Constant">a:num <- next-ingredient</span> <span class="Constant">b:num <- next-ingredient</span> <span class="Constant">stash [dividing by]</span>, b -_, c:num<span class="Special"> <- </span>divide-with-remainder a, b +_, c:num <span class="Special"><-</span> divide-with-remainder a, b <span class="muControl">reply</span> b ]] - env:&:environment<span class="Special"> <- </span>new-programming-environment screen, recipes, <span class="Constant">[foo 4, 0]</span> + env:&:environment <span class="Special"><-</span> new-programming-environment screen, recipes, <span class="Constant">[foo 4, 0]</span> <span class="Comment"># run</span> assume-console [ press F4 @@ -701,7 +701,7 @@ _, c:num<span class="Special"> <- </span>divide-with-remainder a, b ] <span class="Comment"># click on the call in the sandbox</span> assume-console [ - left-click <span class="Constant">4</span>, <span class="Constant">55</span> + left-click<span class="Constant"> 4</span>,<span class="Constant"> 55</span> ] run [ event-loop screen, console, env diff --git a/html/edit/012-editor-undo.mu.html b/html/edit/012-editor-undo.mu.html index 0953fed1..56b85dbf 100644 --- a/html/edit/012-editor-undo.mu.html +++ b/html/edit/012-editor-undo.mu.html @@ -98,36 +98,36 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># ctrl-z - undo operation</span> <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - undo?:bool<span class="Special"> <- </span>equal c, <span class="Constant">26/ctrl-z</span> + undo?:bool <span class="Special"><-</span> equal c, <span class="Constant">26/ctrl-z</span> <span class="muControl">break-unless</span> undo? - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:&:operation<span class="Special"> <- </span>first undo - undo<span class="Special"> <- </span>rest undo - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> - redo<span class="Special"> <- </span>push op, redo - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo + op:&:operation <span class="Special"><-</span> first undo + undo <span class="Special"><-</span> rest undo + *editor <span class="Special"><-</span> put *editor, <span class="Constant">undo:offset</span>, undo + redo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">redo:offset</span> + redo <span class="Special"><-</span> push op, redo + *editor <span class="Special"><-</span> put *editor, <span class="Constant">redo:offset</span>, redo <span class="Constant"> <handle-undo></span> - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> + <span class="muControl">return</span> screen/same-as-ingredient:0, editor/same-as-ingredient:1, <span class="Constant">1/go-render</span> <span class="Delimiter">}</span> ] <span class="Comment"># ctrl-y - redo operation</span> <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - redo?:bool<span class="Special"> <- </span>equal c, <span class="Constant">25/ctrl-y</span> + redo?:bool <span class="Special"><-</span> equal c, <span class="Constant">25/ctrl-y</span> <span class="muControl">break-unless</span> redo? - redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> + redo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">redo:offset</span> <span class="muControl">break-unless</span> redo - op:&:operation<span class="Special"> <- </span>first redo - redo<span class="Special"> <- </span>rest redo - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> - undo<span class="Special"> <- </span>push op, undo - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo + op:&:operation <span class="Special"><-</span> first redo + redo <span class="Special"><-</span> rest redo + *editor <span class="Special"><-</span> put *editor, <span class="Constant">redo:offset</span>, redo + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> + undo <span class="Special"><-</span> push op, undo + *editor <span class="Special"><-</span> put *editor, <span class="Constant">undo:offset</span>, undo <span class="Constant"> <handle-redo></span> - <span class="muControl">return</span> screen/same-as-ingredient:<span class="Constant">0</span>, editor/same-as-ingredient:<span class="Constant">1</span>, <span class="Constant">1/go-render</span> + <span class="muControl">return</span> screen/same-as-ingredient:0, editor/same-as-ingredient:1, <span class="Constant">1/go-render</span> <span class="Delimiter">}</span> ] @@ -137,7 +137,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type a character</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[0]</span> @@ -174,58 +174,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant"><insert-character-begin></span> [ - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><insert-character-end></span> [ - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&:operation<span class="Special"> <- </span>first undo - typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + op:&:operation <span class="Special"><-</span> first undo + typing:insert-operation, is-insert?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - previous-coalesce-tag:num<span class="Special"> <- </span>get typing, <span class="Constant">tag:offset</span> + previous-coalesce-tag:num <span class="Special"><-</span> get typing, <span class="Constant">tag:offset</span> <span class="muControl">break-unless</span> previous-coalesce-tag - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - typing<span class="Special"> <- </span>put typing, <span class="Constant">insert-until:offset</span>, insert-until - typing<span class="Special"> <- </span>put typing, <span class="Constant">after-row:offset</span>, cursor-row - typing<span class="Special"> <- </span>put typing, <span class="Constant">after-column:offset</span>, cursor-column - typing<span class="Special"> <- </span>put typing, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, typing + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + typing <span class="Special"><-</span> put typing, <span class="Constant">insert-until:offset</span>, insert-until + typing <span class="Special"><-</span> put typing, <span class="Constant">after-row:offset</span>, cursor-row + typing <span class="Special"><-</span> put typing, <span class="Constant">after-column:offset</span>, cursor-column + typing <span class="Special"><-</span> put typing, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special"><-</span> merge <span class="Constant">0/insert-operation</span>, typing <span class="muControl">break</span> <span class="Constant">+done-adding-insert-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - insert-from:&:duplex-list:char<span class="Special"> <- </span>next cursor-before - insert-to:&:duplex-list:char<span class="Special"> <- </span>next insert-from - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> - editor<span class="Special"> <- </span>add-operation editor, op + insert-from:&:duplex-list:char <span class="Special"><-</span> next cursor-before + insert-to:&:duplex-list:char <span class="Special"><-</span> next insert-from + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + *op <span class="Special"><-</span> merge <span class="Constant">0/insert-operation</span>, save-row/before, save-column/before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">1/coalesce</span> + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-insert-operation</span> ] <span class="Comment"># enter operations never coalesce with typing before or after</span> <span class="muRecipe">after</span> <span class="Constant"><insert-enter-begin></span> [ - cursor-row-before:num<span class="Special"> <- </span>copy cursor-row - cursor-column-before:num<span class="Special"> <- </span>copy cursor-column - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row-before:num <span class="Special"><-</span> copy cursor-row + cursor-column-before:num <span class="Special"><-</span> copy cursor-column + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><insert-enter-end></span> [ - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> <span class="Comment"># never coalesce</span> - insert-from:&:duplex-list:char<span class="Special"> <- </span>next cursor-before - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-to:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> <- </span>merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> <- </span>add-operation editor, op + insert-from:&:duplex-list:char <span class="Special"><-</span> next cursor-before + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-to:&:duplex-list:char <span class="Special"><-</span> next before-cursor + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + *op <span class="Special"><-</span> merge <span class="Constant">0/insert-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, insert-from, insert-to, <span class="Constant">0/never-coalesce</span> + editor <span class="Special"><-</span> add-operation editor, op ] <span class="Comment"># Everytime you add a new operation to the undo stack, be sure to clear the</span> @@ -235,31 +235,31 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> add-operation editor:&:editor, op:&:operation<span class="muRecipe"> -> </span>editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> - undo<span class="Special"> <- </span>push op undo - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">undo:offset</span>, undo - redo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">redo:offset</span> - redo<span class="Special"> <- </span>copy <span class="Constant">0</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">redo:offset</span>, redo - <span class="muControl">return</span> editor/same-as-ingredient:<span class="Constant">0</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> + undo <span class="Special"><-</span> push op undo + *editor <span class="Special"><-</span> put *editor, <span class="Constant">undo:offset</span>, undo + redo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">redo:offset</span> + redo <span class="Special"><-</span> copy<span class="Constant"> 0</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">redo:offset</span>, redo + <span class="muControl">return</span> editor/same-as-ingredient:0 ] <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - start:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">insert-from:offset</span> - end:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">insert-until:offset</span> + start:&:duplex-list:char <span class="Special"><-</span> get typing, <span class="Constant">insert-from:offset</span> + end:&:duplex-list:char <span class="Special"><-</span> get typing, <span class="Constant">insert-until:offset</span> <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>prev start - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor:&:duplex-list:char <span class="Special"><-</span> prev start + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor remove-between before-cursor, end - cursor-row<span class="Special"> <- </span>get typing, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get typing, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special"><-</span> get typing, <span class="Constant">before-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get typing, <span class="Constant">before-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get typing, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -267,7 +267,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor and type multiple characters</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -293,7 +293,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># type some characters</span> assume-console [ @@ -339,11 +339,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[ abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[ abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># new line</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 8</span> press enter ] editor-event-loop screen, console, e @@ -355,11 +355,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] <span class="Comment"># line is indented</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] <span class="Comment"># undo</span> assume-console [ @@ -368,11 +368,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">5</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 5</span> ] <span class="Comment"># back to original text</span> screen-should-contain [ @@ -402,7 +402,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[a]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -446,19 +446,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - typing:insert-operation, is-insert?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">typing:variant</span> + typing:insert-operation, is-insert?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">typing:variant</span> <span class="muControl">break-unless</span> is-insert? - before-cursor<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - insert-from:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> + before-cursor <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + insert-from:&:duplex-list:char <span class="Special"><-</span> get typing, <span class="Constant">insert-from:offset</span> <span class="Comment"># ignore insert-to because it's already been spliced away</span> <span class="Comment"># assert insert-to matches next(before-cursor)</span> insert-range before-cursor, insert-from <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> <- </span>get typing, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get typing, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get typing, <span class="Constant">after-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special"><-</span> get typing, <span class="Constant">after-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get typing, <span class="Constant">after-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get typing, <span class="Constant">after-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -466,7 +466,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type something, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[012]</span> @@ -512,10 +512,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, do some work, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[1]</span> @@ -555,7 +555,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and tabs, hit enter, some more text and tabs</span> assume-console [ @@ -575,11 +575,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 7</span> ] <span class="Comment"># undo</span> assume-console [ @@ -589,11 +589,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># typing in second line deleted, but not indent</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -610,11 +610,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 8</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -630,11 +630,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># empty screen</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -650,11 +650,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">8</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 8</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -670,11 +670,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># newline and indent inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -691,11 +691,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># indent and newline deleted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">7</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 7</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -712,14 +712,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> ] editor-event-loop screen, console, e <span class="Comment"># undo</span> @@ -730,11 +730,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># click undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -753,49 +753,49 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><move-cursor-begin></span> [ - cursor-row-before:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column-before:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row-before:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column-before:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><move-cursor-end></span> [ - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> undo-coalesce-tag <span class="Comment"># if previous operation was also a move, and also had the same coalesce</span> <span class="Comment"># tag, coalesce with it</span> - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> <span class="muControl">break-unless</span> undo - op:&:operation<span class="Special"> <- </span>first undo - move:move-operation, is-move?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + op:&:operation <span class="Special"><-</span> first undo + move:move-operation, is-move?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? - previous-coalesce-tag:num<span class="Special"> <- </span>get move, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> <- </span>equal undo-coalesce-tag, previous-coalesce-tag + previous-coalesce-tag:num <span class="Special"><-</span> get move, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special"><-</span> equal undo-coalesce-tag, previous-coalesce-tag <span class="muControl">break-unless</span> coalesce? - move<span class="Special"> <- </span>put move, <span class="Constant">after-row:offset</span>, cursor-row - move<span class="Special"> <- </span>put move, <span class="Constant">after-column:offset</span>, cursor-column - move<span class="Special"> <- </span>put move, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> <- </span>merge <span class="Constant">1/move-operation</span>, move + move <span class="Special"><-</span> put move, <span class="Constant">after-row:offset</span>, cursor-row + move <span class="Special"><-</span> put move, <span class="Constant">after-column:offset</span>, cursor-column + move <span class="Special"><-</span> put move, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special"><-</span> merge <span class="Constant">1/move-operation</span>, move <span class="muControl">break</span> <span class="Constant">+done-adding-move-operation</span> <span class="Delimiter">}</span> - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> <- </span>merge <span class="Constant">1/move-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag - editor<span class="Special"> <- </span>add-operation editor, op + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + *op <span class="Special"><-</span> merge <span class="Constant">1/move-operation</span>, cursor-row-before, cursor-column-before, top-before, cursor-row/after, cursor-column/after, top-after, undo-coalesce-tag + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-move-operation</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> <- </span>get move, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get move, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get move, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special"><-</span> get move, <span class="Constant">before-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get move, <span class="Constant">before-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get move, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -804,18 +804,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># screen has 1 line for menu + 3 lines</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">4/height</span> <span class="Comment"># editor contains a wrapped line</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">cdefgh]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> <span class="Comment"># position cursor at end of screen and try to move right</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 3</span> press right-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> <span class="Comment"># screen scrolls</span> screen-should-contain [ <span class="Constant"> . .</span> @@ -824,8 +824,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .gh .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># undo</span> assume-console [ @@ -835,11 +835,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moved back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># scroll undone</span> screen-should-contain [ @@ -867,14 +867,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press left-arrow ] editor-event-loop screen, console, e @@ -886,11 +886,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -912,22 +912,22 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press up-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -937,11 +937,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -963,14 +963,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press down-arrow ] editor-event-loop screen, console, e @@ -982,11 +982,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1008,13 +1008,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ @@ -1042,13 +1042,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page</span> assume-console [ @@ -1076,13 +1076,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1111,13 +1111,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with multiple pages of text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[a</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[a</span> <span class="Constant">b</span> <span class="Constant">c</span> <span class="Constant">d</span> <span class="Constant">e</span> <span class="Constant">f]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># scroll the page down and up</span> assume-console [ @@ -1146,14 +1146,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-a ] editor-event-loop screen, console, e @@ -1165,11 +1165,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1191,14 +1191,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press home ] editor-event-loop screen, console, e @@ -1210,11 +1210,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1236,14 +1236,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press ctrl-e ] editor-event-loop screen, console, e @@ -1255,11 +1255,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1281,14 +1281,14 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor, then to start of line</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press end ] editor-event-loop screen, console, e @@ -1300,11 +1300,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves back</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1326,24 +1326,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># move the cursor</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 1</span> press right-arrow press right-arrow press up-arrow ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1353,11 +1353,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># up-arrow is undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1367,11 +1367,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># both right-arrows are undone</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] ] @@ -1381,13 +1381,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text, click on a character, undo</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def</span> <span class="Constant">ghi]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 1</span> press ctrl-z ] editor-event-loop screen, console, e @@ -1399,11 +1399,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># cursor moves to left-click</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -1423,15 +1423,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - move:move-operation, is-move?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">move:variant</span> + move:move-operation, is-move?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">move:variant</span> <span class="muControl">break-unless</span> is-move? <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> <- </span>get move, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get move, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get move, <span class="Constant">after-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special"><-</span> get move, <span class="Constant">after-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get move, <span class="Constant">after-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get move, <span class="Constant">after-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1439,16 +1439,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor, type some text, move the cursor, type some more text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console [ type <span class="Constant">[abc]</span> - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> type <span class="Constant">[d]</span> ] editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .adbc .</span> @@ -1456,8 +1456,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1465,8 +1465,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># last letter typed is deleted</span> screen-should-contain [ @@ -1476,8 +1476,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1485,8 +1485,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to screen; cursor moves</span> screen-should-contain [ @@ -1496,8 +1496,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># undo again</span> assume-console [ @@ -1505,8 +1505,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># screen empty</span> screen-should-contain [ @@ -1516,8 +1516,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># redo</span> assume-console [ @@ -1525,8 +1525,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># first insert</span> screen-should-contain [ @@ -1536,8 +1536,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># redo again</span> assume-console [ @@ -1545,8 +1545,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor moves</span> screen-should-contain [ @@ -1557,8 +1557,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="Comment"># cursor moves</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># redo again</span> assume-console [ @@ -1566,8 +1566,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># second insert</span> screen-should-contain [ @@ -1577,8 +1577,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] ] @@ -1588,7 +1588,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit backspace</span> assume-console [ @@ -1603,11 +1603,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1616,11 +1616,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1635,11 +1635,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1651,79 +1651,79 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># save operation to undo</span> <span class="muRecipe">after</span> <span class="Constant"><backspace-character-begin></span> [ - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><backspace-character-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> backspaced-cell <span class="Comment"># backspace failed; don't add an undo operation</span> - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&:operation<span class="Special"> <- </span>first undo - deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&:operation <span class="Special"><-</span> first undo + deletion:delete-operation, is-delete?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:num<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> + previous-coalesce-tag:num <span class="Special"><-</span> get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special"><-</span> equal previous-coalesce-tag, <span class="Constant">1/coalesce-backspace</span> <span class="muControl">break-unless</span> coalesce? - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">delete-from:offset</span>, before-cursor - backspaced-so-far:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> + deletion <span class="Special"><-</span> put deletion, <span class="Constant">delete-from:offset</span>, before-cursor + backspaced-so-far:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">deleted-text:offset</span> insert-range backspaced-cell, backspaced-so-far - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">deleted-text:offset</span>, backspaced-cell - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-column:offset</span>, cursor-column - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, deletion + deletion <span class="Special"><-</span> put deletion, <span class="Constant">deleted-text:offset</span>, backspaced-cell + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-row:offset</span>, cursor-row + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-column:offset</span>, cursor-column + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, deletion <span class="muControl">break</span> <span class="Constant">+done-adding-backspace-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">1/coalesce-backspace</span> - editor<span class="Special"> <- </span>add-operation editor, op + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + deleted-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">1/coalesce-backspace</span> + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-backspace-operation</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-undo></span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - anchor:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> + anchor:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">delete-from:offset</span> <span class="muControl">break-unless</span> anchor - deleted:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> - old-cursor:&:duplex-list:char<span class="Special"> <- </span>last deleted + deleted:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">deleted-text:offset</span> + old-cursor:&:duplex-list:char <span class="Special"><-</span> last deleted insert-range anchor, deleted <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - before-cursor<span class="Special"> <- </span>copy old-cursor - cursor-row<span class="Special"> <- </span>get deletion, <span class="Constant">before-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get deletion, <span class="Constant">before-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + before-cursor <span class="Special"><-</span> copy old-cursor + cursor-row <span class="Special"><-</span> get deletion, <span class="Constant">before-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get deletion, <span class="Constant">before-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-redo></span> [ <span class="Delimiter">{</span> - deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + deletion:delete-operation, is-delete?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - start:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-from:offset</span> - end:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">delete-until:offset</span> - data:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> + start:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">delete-from:offset</span> + end:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">delete-until:offset</span> + data:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> remove-between start, end <span class="Comment"># assert cursor-row/cursor-column/top-of-screen match after-row/after-column/after-top-of-screen</span> - cursor-row<span class="Special"> <- </span>get deletion, <span class="Constant">after-row:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>get deletion, <span class="Constant">after-column:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - top:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">before-top-of-screen:offset</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">top-of-screen:offset</span>, top + cursor-row <span class="Special"><-</span> get deletion, <span class="Constant">after-row:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> get deletion, <span class="Constant">after-column:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + top:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">before-top-of-screen:offset</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">top-of-screen:offset</span>, top <span class="Delimiter">}</span> ] @@ -1733,12 +1733,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ type <span class="Constant">[abcdef]</span> - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press delete press backspace press delete @@ -1751,11 +1751,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo deletes</span> assume-console [ @@ -1764,11 +1764,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1783,11 +1783,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1802,11 +1802,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color run [ editor-event-loop screen, console, e ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1822,11 +1822,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1842,11 +1842,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1862,11 +1862,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color editor-event-loop screen, console, e ] <span class="Comment"># first line inserted</span> - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -1877,41 +1877,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-character-begin></span> [ - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-character-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cell <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - undo:&:list:&:operation<span class="Special"> <- </span>get *editor, <span class="Constant">undo:offset</span> + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + undo:&:list:&:operation <span class="Special"><-</span> get *editor, <span class="Constant">undo:offset</span> <span class="Delimiter">{</span> <span class="Comment"># if previous operation was an insert, coalesce this operation with it</span> <span class="muControl">break-unless</span> undo - op:&:operation<span class="Special"> <- </span>first undo - deletion:delete-operation, is-delete?:bool<span class="Special"> <- </span>maybe-convert *op, <span class="Constant">delete:variant</span> + op:&:operation <span class="Special"><-</span> first undo + deletion:delete-operation, is-delete?:bool <span class="Special"><-</span> maybe-convert *op, <span class="Constant">delete:variant</span> <span class="muControl">break-unless</span> is-delete? - previous-coalesce-tag:num<span class="Special"> <- </span>get deletion, <span class="Constant">tag:offset</span> - coalesce?:bool<span class="Special"> <- </span>equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> + previous-coalesce-tag:num <span class="Special"><-</span> get deletion, <span class="Constant">tag:offset</span> + coalesce?:bool <span class="Special"><-</span> equal previous-coalesce-tag, <span class="Constant">2/coalesce-delete</span> <span class="muControl">break-unless</span> coalesce? - delete-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">delete-until:offset</span>, delete-until - deleted-so-far:&:duplex-list:char<span class="Special"> <- </span>get deletion, <span class="Constant">deleted-text:offset</span> - deleted-so-far<span class="Special"> <- </span>append deleted-so-far, deleted-cell - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">deleted-text:offset</span>, deleted-so-far - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-row:offset</span>, cursor-row - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-column:offset</span>, cursor-column - deletion<span class="Special"> <- </span>put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, deletion + delete-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + deletion <span class="Special"><-</span> put deletion, <span class="Constant">delete-until:offset</span>, delete-until + deleted-so-far:&:duplex-list:char <span class="Special"><-</span> get deletion, <span class="Constant">deleted-text:offset</span> + deleted-so-far <span class="Special"><-</span> append deleted-so-far, deleted-cell + deletion <span class="Special"><-</span> put deletion, <span class="Constant">deleted-text:offset</span>, deleted-so-far + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-row:offset</span>, cursor-row + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-column:offset</span>, cursor-column + deletion <span class="Special"><-</span> put deletion, <span class="Constant">after-top-of-screen:offset</span>, top-after + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, deletion <span class="muControl">break</span> <span class="Constant">+done-adding-delete-operation</span> <span class="Delimiter">}</span> <span class="Comment"># if not, create a new operation</span> - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">2/coalesce-delete</span> - editor<span class="Special"> <- </span>add-operation editor, op + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + deleted-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">2/coalesce-delete</span> + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -1922,13 +1922,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> press ctrl-k ] editor-event-loop screen, console, e @@ -1939,11 +1939,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># undo</span> assume-console [ @@ -1959,11 +1959,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># redo</span> assume-console [ @@ -1980,11 +1980,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -2003,18 +2003,18 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-end-of-line-begin></span> [ - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-end-of-line-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> <- </span>add-operation editor, op + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + deleted-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">0/never-coalesce</span> + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -2025,13 +2025,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - contents:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + contents:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor contents, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> press ctrl-u ] editor-event-loop screen, console, e @@ -2042,11 +2042,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># undo</span> assume-console [ @@ -2062,11 +2062,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> ] <span class="Comment"># redo</span> assume-console [ @@ -2083,11 +2083,11 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] <span class="Comment"># cursor should be in the right place</span> assume-console [ @@ -2106,19 +2106,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><delete-to-start-of-line-begin></span> [ - top-before:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> + top-before:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> ] <span class="muRecipe">before</span> <span class="Constant"><delete-to-start-of-line-end></span> [ <span class="Delimiter">{</span> <span class="muControl">break-unless</span> deleted-cells <span class="Comment"># delete failed; don't add an undo operation</span> - top-after:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - op:&:operation<span class="Special"> <- </span>new <span class="Constant">operation:type</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - deleted-until:&:duplex-list:char<span class="Special"> <- </span>next before-cursor - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - *op<span class="Special"> <- </span>merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">0/never-coalesce</span> - editor<span class="Special"> <- </span>add-operation editor, op + top-after:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + op:&:operation <span class="Special"><-</span> new <span class="Constant">operation:type</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + deleted-until:&:duplex-list:char <span class="Special"><-</span> next before-cursor + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + *op <span class="Special"><-</span> merge <span class="Constant">2/delete-operation</span>, 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, <span class="Constant">0/never-coalesce</span> + editor <span class="Special"><-</span> add-operation editor, op <span class="Constant"> +done-adding-delete-operation</span> <span class="Delimiter">}</span> ] @@ -2127,7 +2127,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Comment"># insert some text and hit delete and backspace a few times</span> assume-console [ |