diff options
Diffstat (limited to 'html/edit/003-shortcuts.mu.html')
-rw-r--r-- | html/edit/003-shortcuts.mu.html | 1418 |
1 files changed, 709 insertions, 709 deletions
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> |