diff options
Diffstat (limited to 'html/edit/002-typing.mu.html')
-rw-r--r-- | html/edit/002-typing.mu.html | 596 |
1 files changed, 298 insertions, 298 deletions
diff --git a/html/edit/002-typing.mu.html b/html/edit/002-typing.mu.html index 325e7f6e..dbca61b2 100644 --- a/html/edit/002-typing.mu.html +++ b/html/edit/002-typing.mu.html @@ -41,7 +41,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> open-console - editor:&:editor<span class="Special"> <- </span>new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> + editor:&:editor <span class="Special"><-</span> new-editor text, <span class="Constant">0/screen</span>, <span class="Constant">5/left</span>, <span class="Constant">45/right</span> editor-event-loop <span class="Constant">0/screen</span>, <span class="Constant">0/console</span>, editor close-console ] @@ -52,15 +52,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">{</span> <span class="Comment"># looping over each (keyboard or touch) event as it occurs</span> <span class="Constant"> +next-event</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - screen<span class="Special"> <- </span>move-cursor screen, cursor-row, cursor-column - e:event, found?:bool, quit?:bool, console<span class="Special"> <- </span>read-event console + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + screen <span class="Special"><-</span> move-cursor screen, cursor-row, cursor-column + e:event, found?:bool, quit?:bool, console <span class="Special"><-</span> read-event console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? <span class="Comment"># only in tests</span> - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[next-event]</span> <span class="Comment"># 'touch' event</span> - t:touch-event, is-touch?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">touch:variant</span> + t:touch-event, is-touch?:bool <span class="Special"><-</span> maybe-convert e, <span class="Constant">touch:variant</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-touch? move-cursor-in-editor screen, editor, t @@ -69,10 +69,10 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># keyboard events</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-touch? - screen, editor, go-render?:bool<span class="Special"> <- </span>handle-keyboard-event screen, editor, e + screen, editor, go-render?:bool <span class="Special"><-</span> handle-keyboard-event screen, editor, e <span class="Delimiter">{</span> <span class="muControl">break-unless</span> go-render? - screen<span class="Special"> <- </span>editor-render screen, editor + screen <span class="Special"><-</span> editor-render screen, editor <span class="Delimiter">}</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> @@ -84,19 +84,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor, <span class="Constant">0/false</span> - click-row:num<span class="Special"> <- </span>get t, <span class="Constant">row:offset</span> + click-row:num <span class="Special"><-</span> get t, <span class="Constant">row:offset</span> <span class="muControl">return-unless</span> click-row, <span class="Constant">0/false</span> <span class="Comment"># ignore clicks on 'menu'</span> - click-column:num<span class="Special"> <- </span>get t, <span class="Constant">column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - too-far-left?:bool<span class="Special"> <- </span>lesser-than click-column, left + click-column:num <span class="Special"><-</span> get t, <span class="Constant">column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + too-far-left?:bool <span class="Special"><-</span> lesser-than click-column, left <span class="muControl">return-if</span> too-far-left?, <span class="Constant">0/false</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - too-far-right?:bool<span class="Special"> <- </span>greater-than click-column, right + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + too-far-right?:bool <span class="Special"><-</span> greater-than click-column, right <span class="muControl">return-if</span> too-far-right?, <span class="Constant">0/false</span> <span class="Comment"># position cursor</span> <span class="Constant"> <move-cursor-begin></span> - editor<span class="Special"> <- </span>snap-cursor screen, editor, click-row, click-column - undo-coalesce-tag:num<span class="Special"> <- </span>copy <span class="Constant">0/never</span> + editor <span class="Special"><-</span> snap-cursor screen, editor, click-row, click-column + undo-coalesce-tag:num <span class="Special"><-</span> copy <span class="Constant">0/never</span> <span class="Constant"> <move-cursor-end></span> <span class="Comment"># gain focus</span> <span class="muControl">return</span> <span class="Constant">1/true</span> @@ -109,88 +109,88 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> <span class="muControl">return-unless</span> editor - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># count newlines until screen row</span> - curr:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">top-of-screen:offset</span> - prev:&:duplex-list:char<span class="Special"> <- </span>copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> - curr<span class="Special"> <- </span>next curr - row:num<span class="Special"> <- </span>copy <span class="Constant">1/top</span> - column:num<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, target-row - cursor-row:num<span class="Special"> <- </span>copy target-row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, target-column - cursor-column:num<span class="Special"> <- </span>copy target-column - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + curr:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">top-of-screen:offset</span> + prev:&:duplex-list:char <span class="Special"><-</span> copy curr <span class="Comment"># just in case curr becomes null and we can't compute prev</span> + curr <span class="Special"><-</span> next curr + row:num <span class="Special"><-</span> copy <span class="Constant">1/top</span> + column:num <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, target-row + cursor-row:num <span class="Special"><-</span> copy target-row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, target-column + cursor-column:num <span class="Special"><-</span> copy target-column + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> <span class="Delimiter">{</span> <span class="Constant"> +next-character</span> <span class="muControl">break-unless</span> curr - off-screen?:bool<span class="Special"> <- </span>greater-or-equal row, screen-height + off-screen?:bool <span class="Special"><-</span> greater-or-equal row, screen-height <span class="muControl">break-if</span> off-screen? <span class="Comment"># update editor.before-cursor</span> <span class="Comment"># Doing so at the start of each iteration ensures it stays one step behind</span> <span class="Comment"># the current character.</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - at-cursor?:bool<span class="Special"> <- </span>equal column, cursor-column + at-cursor?:bool <span class="Special"><-</span> equal column, cursor-column <span class="muControl">break-unless</span> at-cursor? - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> <span class="Delimiter">{</span> <span class="Comment"># newline? move to left rather than 0</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Comment"># adjust cursor if necessary</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row <span class="muControl">break-unless</span> at-cursor-row? - left-of-cursor?:bool<span class="Special"> <- </span>lesser-than column, cursor-column + left-of-cursor?:bool <span class="Special"><-</span> lesser-than column, cursor-column <span class="muControl">break-unless</span> left-of-cursor? - cursor-column<span class="Special"> <- </span>copy column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-column <span class="Special"><-</span> copy column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> <span class="Comment"># skip to next line</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> - column<span class="Special"> <- </span>copy left - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + column <span class="Special"><-</span> copy left + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># at right? wrap. even if there's only one more letter left; we need</span> <span class="Comment"># room for clicking on the cursor after it.</span> - at-right?:bool<span class="Special"> <- </span>equal column, right + at-right?:bool <span class="Special"><-</span> equal column, right <span class="muControl">break-unless</span> at-right? - column<span class="Special"> <- </span>copy left - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + column <span class="Special"><-</span> copy left + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> <span class="Comment"># don't increment curr/prev</span> <span class="muControl">loop</span> <span class="Constant">+next-character</span> <span class="Delimiter">}</span> - curr<span class="Special"> <- </span>next curr - prev<span class="Special"> <- </span>next prev - column<span class="Special"> <- </span>add column, <span class="Constant">1</span> + curr <span class="Special"><-</span> next curr + prev <span class="Special"><-</span> next prev + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> <span class="Comment"># is cursor to the right of the last line? move to end</span> <span class="Delimiter">{</span> - at-cursor-row?:bool<span class="Special"> <- </span>equal row, cursor-row - cursor-outside-line?:bool<span class="Special"> <- </span>lesser-or-equal column, cursor-column - before-cursor-on-same-line?:bool<span class="Special"> <- </span>and at-cursor-row?, cursor-outside-line? - above-cursor-row?:bool<span class="Special"> <- </span>lesser-than row, cursor-row - before-cursor?:bool<span class="Special"> <- </span>or before-cursor-on-same-line?, above-cursor-row? + at-cursor-row?:bool <span class="Special"><-</span> equal row, cursor-row + cursor-outside-line?:bool <span class="Special"><-</span> lesser-or-equal column, cursor-column + before-cursor-on-same-line?:bool <span class="Special"><-</span> and at-cursor-row?, cursor-outside-line? + above-cursor-row?:bool <span class="Special"><-</span> lesser-than row, cursor-row + before-cursor?:bool <span class="Special"><-</span> or before-cursor-on-same-line?, above-cursor-row? <span class="muControl">break-unless</span> before-cursor? - cursor-row<span class="Special"> <- </span>copy row - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - before-cursor<span class="Special"> <- </span>copy prev - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special"><-</span> copy row + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> copy prev + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor <span class="Delimiter">}</span> ] @@ -199,105 +199,105 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> handle-keyboard-event screen:&:screen, editor:&:editor, e:event<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> editor - screen-width:num<span class="Special"> <- </span>screen-width screen - screen-height:num<span class="Special"> <- </span>screen-height screen - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - save-row:num<span class="Special"> <- </span>copy cursor-row - save-column:num<span class="Special"> <- </span>copy cursor-column + screen-width:num <span class="Special"><-</span> screen-width screen + screen-height:num <span class="Special"><-</span> screen-height screen + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + save-row:num <span class="Special"><-</span> copy cursor-row + save-column:num <span class="Special"><-</span> copy cursor-column <span class="Comment"># character</span> <span class="Delimiter">{</span> - c:char, is-unicode?:bool<span class="Special"> <- </span>maybe-convert e, <span class="Constant">text:variant</span> + c:char, is-unicode?:bool <span class="Special"><-</span> maybe-convert e, <span class="Constant">text:variant</span> <span class="muControl">break-unless</span> is-unicode? - trace <span class="Constant">10</span>, <span class="Constant">[app]</span>, <span class="Constant">[handle-keyboard-event: special character]</span> + trace<span class="Constant"> 10</span>, <span class="Constant">[app]</span>, <span class="Constant">[handle-keyboard-event: special character]</span> <span class="Comment"># exceptions for special characters go here</span> <span class="Constant"> <handle-special-character></span> <span class="Comment"># ignore any other special characters</span> - regular-character?:bool<span class="Special"> <- </span>greater-or-equal c, <span class="Constant">32/space</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + regular-character?:bool <span class="Special"><-</span> greater-or-equal c, <span class="Constant">32/space</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return-unless</span> regular-character? <span class="Comment"># otherwise type it in</span> <span class="Constant"> <insert-character-begin></span> - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, c, screen + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, c, screen <span class="Constant"> <insert-character-end></span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Comment"># special key to modify the text or move the cursor</span> - k:num, is-keycode?:bool<span class="Special"> <- </span>maybe-convert e:event, <span class="Constant">keycode:variant</span> + k:num, is-keycode?:bool <span class="Special"><-</span> maybe-convert e:event, <span class="Constant">keycode:variant</span> assert is-keycode?, <span class="Constant">[event was of unknown type; neither keyboard nor mouse]</span> <span class="Comment"># handlers for each special key will go here</span> <span class="Constant"> <handle-special-key></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> ] <span class="muRecipe">def</span> insert-at-cursor editor:&:editor, c:char, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> insert c, before-cursor - before-cursor<span class="Special"> <- </span>next before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - save-row:num<span class="Special"> <- </span>copy cursor-row - save-column:num<span class="Special"> <- </span>copy cursor-column - screen-width:num<span class="Special"> <- </span>screen-width screen - screen-height:num<span class="Special"> <- </span>screen-height screen + before-cursor <span class="Special"><-</span> next before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + save-row:num <span class="Special"><-</span> copy cursor-row + save-column:num <span class="Special"><-</span> copy cursor-column + screen-width:num <span class="Special"><-</span> screen-width screen + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># occasionally we'll need to mess with the cursor</span> <span class="Constant"> <insert-character-special-case></span> <span class="Comment"># but mostly we'll just move the cursor right</span> - cursor-column<span class="Special"> <- </span>add cursor-column, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + cursor-column <span class="Special"><-</span> add cursor-column,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Delimiter">{</span> <span class="Comment"># at end of all text? no need to scroll? just print the character and leave</span> - at-end?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0/null</span> + at-end?:bool <span class="Special"><-</span> equal next, <span class="Constant">0/null</span> <span class="muControl">break-unless</span> at-end? - bottom:num<span class="Special"> <- </span>subtract screen-height, <span class="Constant">1</span> - at-bottom?:bool<span class="Special"> <- </span>equal save-row, bottom - at-right?:bool<span class="Special"> <- </span>equal save-column, right - overflow?:bool<span class="Special"> <- </span>and at-bottom?, at-right? + bottom:num <span class="Special"><-</span> subtract screen-height,<span class="Constant"> 1</span> + at-bottom?:bool <span class="Special"><-</span> equal save-row, bottom + at-right?:bool <span class="Special"><-</span> equal save-column, right + overflow?:bool <span class="Special"><-</span> and at-bottom?, at-right? <span class="muControl">break-if</span> overflow? move-cursor screen, save-row, save-column print screen, c - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="Comment"># not at right margin? print the character and rest of line</span> <span class="muControl">break-unless</span> next - at-right?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, screen-width + at-right?:bool <span class="Special"><-</span> greater-or-equal cursor-column, screen-width <span class="muControl">break-if</span> at-right? - curr:&:duplex-list:char<span class="Special"> <- </span>copy before-cursor + curr:&:duplex-list:char <span class="Special"><-</span> copy before-cursor move-cursor screen, save-row, save-column - curr-column:num<span class="Special"> <- </span>copy save-column + curr-column:num <span class="Special"><-</span> copy save-column <span class="Delimiter">{</span> <span class="Comment"># hit right margin? give up and let caller render</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - at-right?:bool<span class="Special"> <- </span>greater-than curr-column, right + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + at-right?:bool <span class="Special"><-</span> greater-than curr-column, right <span class="muControl">return-if</span> at-right? <span class="muControl">break-unless</span> curr <span class="Comment"># newline? done.</span> - currc:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal currc, <span class="Constant">10/newline</span> + currc:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal currc, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? print screen, currc - curr-column<span class="Special"> <- </span>add curr-column, <span class="Constant">1</span> - curr<span class="Special"> <- </span>next curr + curr-column <span class="Special"><-</span> add curr-column,<span class="Constant"> 1</span> + curr <span class="Special"><-</span> next curr <span class="muControl">loop</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> ] @@ -305,20 +305,20 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> editor-render screen:&:screen, editor:&:editor<span class="muRecipe"> -> </span>screen:&:screen, editor:&:editor [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - row:num, column:num<span class="Special"> <- </span>render screen, editor + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + row:num, column:num <span class="Special"><-</span> render screen, editor clear-line-until screen, right - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> draw-horizontal screen, row, left, right, <span class="Constant">9480/horizontal-dotted</span> - row<span class="Special"> <- </span>add row, <span class="Constant">1</span> + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> clear-screen-from screen, row, left, left, right ] <span class="muScenario">scenario</span> editor-handles-empty-event-queue [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e assume-console <span class="Constant">[]</span> run [ @@ -335,16 +335,16 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-handles-mouse-clicks [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">1</span> <span class="Comment"># on the 'b'</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 1</span> <span class="Comment"># on the 'b'</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -353,91 +353,91 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor is at row 0..</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># ..and column 1</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor is at row 0..</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># ..and column 1</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># last line, to the right of text</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 7</span> <span class="Comment"># last line, to the right of text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">7</span> <span class="Comment"># interior line, to the right of text</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 7</span> <span class="Comment"># interior line, to the right of text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-text-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">def]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">7</span> <span class="Comment"># below text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 7</span> <span class="Comment"># below text</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-outside-column [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># editor occupies only left half of screen</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on right half of screen</span> - left-click <span class="Constant">3</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 8</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -446,38 +446,38 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> <span class="Comment"># no change to cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># ..or column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> <span class="Comment"># no change to cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># ..or column</span> ] - check-trace-count-for-label <span class="Constant">0</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 0</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-handles-mouse-clicks-in-menu-area [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ <span class="Comment"># click on first, 'menu' row</span> - left-click <span class="Constant">0</span>, <span class="Constant">3</span> + left-click<span class="Constant"> 0</span>,<span class="Constant"> 3</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># no change to cursor</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">1</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 1</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> ] ] <span class="muScenario">scenario</span> editor-inserts-characters-into-empty-editor [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ @@ -492,19 +492,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌ .</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">3</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 3</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> <span class="Comment"># type two letters at different places</span> assume-console [ type <span class="Constant">[0]</span> - left-click <span class="Constant">1</span>, <span class="Constant">2</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 2</span> type <span class="Constant">[d]</span> ] run [ @@ -516,17 +516,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> + check-trace-count-for-label<span class="Constant"> 7</span>, <span class="Constant">[print-character]</span> <span class="Comment"># 4 for first letter, 3 for second</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of last line</span> type <span class="Constant">[d]</span> ] run [ @@ -538,19 +538,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-5 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># right of non-last line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># right of non-last line</span> type <span class="Constant">[e]</span> ] run [ @@ -563,17 +563,17 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-3 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[d]</span> ] run [ @@ -585,19 +585,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-4 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[e]</span> ] run [ @@ -610,19 +610,19 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">1</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 1</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-inserts-characters-at-cursor-6 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">d]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> editor-render screen, e <span class="Constant"> $clear-trace</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">5</span> <span class="Comment"># below all text</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 5</span> <span class="Comment"># below all text</span> type <span class="Constant">[ef]</span> ] run [ @@ -635,13 +635,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> .╌╌╌╌╌╌╌╌╌╌.</span> <span class="Constant"> . .</span> ] - check-trace-count-for-label <span class="Constant">2</span>, <span class="Constant">[print-character]</span> + check-trace-count-for-label<span class="Constant"> 2</span>, <span class="Constant">[print-character]</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-after-inserting-characters [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[ab]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e assume-console [ type <span class="Constant">[01]</span> @@ -662,7 +662,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-line-on-insert [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">5/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type a letter</span> assume-console [ @@ -700,24 +700,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Comment"># create an editor with some text</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abcdefg</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abcdefg</span> <span class="Constant">defg]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> editor-render screen, e <span class="Comment"># type more text at the start</span> assume-console [ - left-click <span class="Constant">3</span>, <span class="Constant">0</span> + left-click<span class="Constant"> 3</span>,<span class="Constant"> 0</span> type <span class="Constant">[abc]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor is not wrapped</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> ] <span class="Comment"># but line is wrapped</span> screen-should-contain [ @@ -735,47 +735,47 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Comment"># if either:</span> <span class="Comment"># a) we're at the end of the line and at the column of the wrap indicator, or</span> <span class="Comment"># b) we're not at end of line and just before the column of the wrap indicator</span> - wrap-column:num<span class="Special"> <- </span>copy right - before-wrap-column:num<span class="Special"> <- </span>subtract wrap-column, <span class="Constant">1</span> - at-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, wrap-column - just-before-wrap?:bool<span class="Special"> <- </span>greater-or-equal cursor-column, before-wrap-column - next:&:duplex-list:char<span class="Special"> <- </span>next before-cursor + wrap-column:num <span class="Special"><-</span> copy right + before-wrap-column:num <span class="Special"><-</span> subtract wrap-column,<span class="Constant"> 1</span> + at-wrap?:bool <span class="Special"><-</span> greater-or-equal cursor-column, wrap-column + just-before-wrap?:bool <span class="Special"><-</span> greater-or-equal cursor-column, before-wrap-column + next:&:duplex-list:char <span class="Special"><-</span> next before-cursor <span class="Comment"># at end of line? next == 0 || next.value == 10/newline</span> - at-end-of-line?:bool<span class="Special"> <- </span>equal next, <span class="Constant">0</span> + at-end-of-line?:bool <span class="Special"><-</span> equal next,<span class="Constant"> 0</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - next-character:char<span class="Special"> <- </span>get *next, <span class="Constant">value:offset</span> - at-end-of-line?<span class="Special"> <- </span>equal next-character, <span class="Constant">10/newline</span> + next-character:char <span class="Special"><-</span> get *next, <span class="Constant">value:offset</span> + at-end-of-line? <span class="Special"><-</span> equal next-character, <span class="Constant">10/newline</span> <span class="Delimiter">}</span> <span class="Comment"># break unless ((eol? and at-wrap?) or (~eol? and just-before-wrap?))</span> - move-cursor-to-next-line?:bool<span class="Special"> <- </span>copy <span class="Constant">0/false</span> + move-cursor-to-next-line?:bool <span class="Special"><-</span> copy <span class="Constant">0/false</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> <- </span>copy just-before-wrap? + move-cursor-to-next-line? <span class="Special"><-</span> copy just-before-wrap? <span class="Comment"># if we're moving the cursor because it's in the middle of a wrapping</span> <span class="Comment"># line, adjust it to left-most column</span> - potential-new-cursor-column:num<span class="Special"> <- </span>copy left + potential-new-cursor-column:num <span class="Special"><-</span> copy left <span class="Delimiter">}</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> at-end-of-line? - move-cursor-to-next-line?<span class="Special"> <- </span>copy at-wrap? + move-cursor-to-next-line? <span class="Special"><-</span> copy at-wrap? <span class="Comment"># if we're moving the cursor because it's at the end of a wrapping line,</span> <span class="Comment"># adjust it to one past the left-most column to make room for the</span> <span class="Comment"># newly-inserted wrap-indicator</span> - potential-new-cursor-column:num<span class="Special"> <- </span>add left, <span class="Constant">1/make-room-for-wrap-indicator</span> + potential-new-cursor-column:num <span class="Special"><-</span> add left, <span class="Constant">1/make-room-for-wrap-indicator</span> <span class="Delimiter">}</span> <span class="muControl">break-unless</span> move-cursor-to-next-line? - cursor-column<span class="Special"> <- </span>copy potential-new-cursor-column - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy potential-new-cursor-column + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Comment"># if we're out of the screen, scroll down</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> <span class="Delimiter">}</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -783,15 +783,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-after-inserting-characters-in-middle-of-line [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">3</span> <span class="Comment"># right before the wrap icon</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 3</span> <span class="Comment"># right before the wrap icon</span> type <span class="Constant">[f]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -801,8 +801,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column</span> ] ] @@ -810,9 +810,9 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> <span class="Comment"># create an editor containing two lines</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[abc</span> + s:text <span class="Special"><-</span> new <span class="Constant">[abc</span> <span class="Constant">xyz]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> screen-should-contain [ <span class="Constant"> . .</span> <span class="Constant"> .abc .</span> @@ -820,7 +820,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">4</span> <span class="Comment"># at end of first line</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 4</span> <span class="Comment"># at end of first line</span> type <span class="Constant">[de]</span> <span class="Comment"># trigger wrap</span> ] run [ @@ -838,15 +838,15 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-wraps-cursor-to-left-margin [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">2/left</span>, <span class="Constant">7/right</span> assume-console [ - left-click <span class="Constant">1</span>, <span class="Constant">5</span> <span class="Comment"># line is full; no wrap icon yet</span> + left-click<span class="Constant"> 1</span>,<span class="Constant"> 5</span> <span class="Comment"># line is full; no wrap icon yet</span> type <span class="Constant">[01]</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] screen-should-contain [ <span class="Constant"> . .</span> @@ -856,8 +856,8 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant"> . .</span> ] memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor column</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor column</span> ] ] @@ -868,13 +868,13 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color ] <span class="muRecipe">after</span> <span class="Constant"><editor-initialization></span> [ - *result<span class="Special"> <- </span>put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + *result <span class="Special"><-</span> put *result, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> ] <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -893,12 +893,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">after</span> <span class="Constant"><handle-special-character></span> [ <span class="Delimiter">{</span> - newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-unless</span> newline? <span class="Constant"> <insert-enter-begin></span> - editor<span class="Special"> <- </span>insert-new-line-and-indent editor, screen + editor <span class="Special"><-</span> insert-new-line-and-indent editor, screen <span class="Constant"> <insert-enter-end></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -906,41 +906,41 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> insert-new-line-and-indent editor:&:editor, screen:&:screen<span class="muRecipe"> -> </span>editor:&:editor, screen:&:screen, go-render?:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - cursor-row:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-row:offset</span> - cursor-column:num<span class="Special"> <- </span>get *editor, <span class="Constant">cursor-column:offset</span> - before-cursor:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">before-cursor:offset</span> - left:num<span class="Special"> <- </span>get *editor, <span class="Constant">left:offset</span> - right:num<span class="Special"> <- </span>get *editor, <span class="Constant">right:offset</span> - screen-height:num<span class="Special"> <- </span>screen-height screen + cursor-row:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-row:offset</span> + cursor-column:num <span class="Special"><-</span> get *editor, <span class="Constant">cursor-column:offset</span> + before-cursor:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">before-cursor:offset</span> + left:num <span class="Special"><-</span> get *editor, <span class="Constant">left:offset</span> + right:num <span class="Special"><-</span> get *editor, <span class="Constant">right:offset</span> + screen-height:num <span class="Special"><-</span> screen-height screen <span class="Comment"># insert newline</span> insert <span class="Constant">10/newline</span>, before-cursor - before-cursor<span class="Special"> <- </span>next before-cursor - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor - cursor-row<span class="Special"> <- </span>add cursor-row, <span class="Constant">1</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row - cursor-column<span class="Special"> <- </span>copy left - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column + before-cursor <span class="Special"><-</span> next before-cursor + *editor <span class="Special"><-</span> put *editor, <span class="Constant">before-cursor:offset</span>, before-cursor + cursor-row <span class="Special"><-</span> add cursor-row,<span class="Constant"> 1</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + cursor-column <span class="Special"><-</span> copy left + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-column:offset</span>, cursor-column <span class="Comment"># maybe scroll</span> <span class="Delimiter">{</span> - below-screen?:bool<span class="Special"> <- </span>greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> + below-screen?:bool <span class="Special"><-</span> greater-or-equal cursor-row, screen-height <span class="Comment"># must be equal, never greater</span> <span class="muControl">break-unless</span> below-screen? <span class="Constant"> <scroll-down></span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> - cursor-row<span class="Special"> <- </span>subtract cursor-row, <span class="Constant">1</span> <span class="Comment"># bring back into screen range</span> - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> + cursor-row <span class="Special"><-</span> subtract cursor-row,<span class="Constant"> 1</span> <span class="Comment"># bring back into screen range</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">cursor-row:offset</span>, cursor-row <span class="Delimiter">}</span> <span class="Comment"># indent if necessary</span> - indent?:bool<span class="Special"> <- </span>get *editor, <span class="Constant">indent?:offset</span> + indent?:bool <span class="Special"><-</span> get *editor, <span class="Constant">indent?:offset</span> <span class="muControl">return-unless</span> indent? - d:&:duplex-list:char<span class="Special"> <- </span>get *editor, <span class="Constant">data:offset</span> - end-of-previous-line:&:duplex-list:char<span class="Special"> <- </span>prev before-cursor - indent:num<span class="Special"> <- </span>line-indent end-of-previous-line, d - i:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + d:&:duplex-list:char <span class="Special"><-</span> get *editor, <span class="Constant">data:offset</span> + end-of-previous-line:&:duplex-list:char <span class="Special"><-</span> prev before-cursor + indent:num <span class="Special"><-</span> line-indent end-of-previous-line, d + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">{</span> - indent-done?:bool<span class="Special"> <- </span>greater-or-equal i, indent + indent-done?:bool <span class="Special"><-</span> greater-or-equal i, indent <span class="muControl">break-if</span> indent-done? - editor, screen, go-render?:bool<span class="Special"> <- </span>insert-at-cursor editor, <span class="Constant">32/space</span>, screen - i<span class="Special"> <- </span>add i, <span class="Constant">1</span> + editor, screen, go-render?:bool <span class="Special"><-</span> insert-at-cursor editor, <span class="Constant">32/space</span>, screen + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] @@ -950,28 +950,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> line-indent curr:&:duplex-list:char, start:&:duplex-list:char<span class="muRecipe"> -> </span>result:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - result:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + result:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="muControl">return-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">return-if</span> at-start? <span class="Delimiter">{</span> - curr<span class="Special"> <- </span>prev curr + curr <span class="Special"><-</span> prev curr <span class="muControl">break-unless</span> curr - at-start?:bool<span class="Special"> <- </span>equal curr, start + at-start?:bool <span class="Special"><-</span> equal curr, start <span class="muControl">break-if</span> at-start? - c:char<span class="Special"> <- </span>get *curr, <span class="Constant">value:offset</span> - at-newline?:bool<span class="Special"> <- </span>equal c, <span class="Constant">10/newline</span> + c:char <span class="Special"><-</span> get *curr, <span class="Constant">value:offset</span> + at-newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> <span class="muControl">break-if</span> at-newline? <span class="Comment"># if c is a space, increment result</span> - is-space?:bool<span class="Special"> <- </span>equal c, <span class="Constant">32/space</span> + is-space?:bool <span class="Special"><-</span> equal c, <span class="Constant">32/space</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> is-space? - result<span class="Special"> <- </span>add result, <span class="Constant">1</span> + result <span class="Special"><-</span> add result,<span class="Constant"> 1</span> <span class="Delimiter">}</span> <span class="Comment"># if c is not a space, reset result</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> is-space? - result<span class="Special"> <- </span>copy <span class="Constant">0</span> + result <span class="Special"><-</span> copy<span class="Constant"> 0</span> <span class="Delimiter">}</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> @@ -980,7 +980,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-moves-cursor-down-after-inserting-newline-2 [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abc]</span>, screen, <span class="Constant">1/left</span>, <span class="Constant">10/right</span> assume-console [ type <span class="Constant">[0</span> <span class="Constant">1]</span> @@ -1000,7 +1000,7 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-clears-previous-line-completely-after-inserting-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">5/height</span> - e:&:editor<span class="Special"> <- </span>new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> + e:&:editor <span class="Special"><-</span> new-editor <span class="Constant">[abcde]</span>, screen, <span class="Constant">0/left</span>, <span class="Constant">5/right</span> assume-console [ press enter ] @@ -1027,70 +1027,70 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muScenario">scenario</span> editor-inserts-indent-after-newline [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline'</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> type [ ] ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">2</span> <span class="Comment"># cursor column (indented)</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 2</span> <span class="Comment"># cursor column (indented)</span> ] ] <span class="muScenario">scenario</span> editor-skips-indent-around-paste [ <span class="Constant">local-scope</span> assume-screen <span class="Constant">10/width</span>, <span class="Constant">10/height</span> - s:text<span class="Special"> <- </span>new <span class="Constant">[ab</span> + s:text <span class="Special"><-</span> new <span class="Constant">[ab</span> <span class="Constant"> cd</span> <span class="Constant">ef]</span> - e:&:editor<span class="Special"> <- </span>new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> + e:&:editor <span class="Special"><-</span> new-editor s, screen, <span class="Constant">0/left</span>, <span class="Constant">10/right</span> <span class="Comment"># position cursor after 'cd' and hit 'newline' surrounded by paste markers</span> assume-console [ - left-click <span class="Constant">2</span>, <span class="Constant">8</span> - press <span class="Constant">65507</span> <span class="Comment"># start paste</span> + left-click<span class="Constant"> 2</span>,<span class="Constant"> 8</span> + press<span class="Constant"> 65507</span> <span class="Comment"># start paste</span> press enter - press <span class="Constant">65506</span> <span class="Comment"># end paste</span> + press<span class="Constant"> 65506</span> <span class="Comment"># end paste</span> ] run [ editor-event-loop screen, console, e - <span class="Constant">3</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-row:offset</span> - <span class="Constant">4</span>:num/<span class="Special">raw <- </span>get *e, <span class="Constant">cursor-column:offset</span> + 3:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-row:offset</span> + 4:num/<span class="Special">raw</span> <span class="Special"><-</span> get *e, <span class="Constant">cursor-column:offset</span> ] <span class="Comment"># cursor should be below start of previous line</span> memory-should-contain [ - <span class="Constant">3</span><span class="Special"> <- </span><span class="Constant">3</span> <span class="Comment"># cursor row</span> - <span class="Constant">4</span><span class="Special"> <- </span><span class="Constant">0</span> <span class="Comment"># cursor column (not indented)</span> + <span class="Constant"> 3</span> <span class="Special"><-</span><span class="Constant"> 3</span> <span class="Comment"># cursor row</span> + <span class="Constant"> 4</span> <span class="Special"><-</span><span class="Constant"> 0</span> <span class="Comment"># cursor column (not indented)</span> ] ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-start?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65507/paste-start</span> + paste-start?:bool <span class="Special"><-</span> equal k, <span class="Constant">65507/paste-start</span> <span class="muControl">break-unless</span> paste-start? - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">0/false</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] <span class="muRecipe">after</span> <span class="Constant"><handle-special-key></span> [ <span class="Delimiter">{</span> - paste-end?:bool<span class="Special"> <- </span>equal k, <span class="Constant">65506/paste-end</span> + paste-end?:bool <span class="Special"><-</span> equal k, <span class="Constant">65506/paste-end</span> <span class="muControl">break-unless</span> paste-end? - *editor<span class="Special"> <- </span>put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> - go-render?<span class="Special"> <- </span>copy <span class="Constant">1/true</span> + *editor <span class="Special"><-</span> put *editor, <span class="Constant">indent?:offset</span>, <span class="Constant">1/true</span> + go-render? <span class="Special"><-</span> copy <span class="Constant">1/true</span> <span class="muControl">return</span> <span class="Delimiter">}</span> ] @@ -1100,28 +1100,28 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> draw-horizontal screen:&:screen, row:num, x:num, right:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - style:char, style-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + style:char, style-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> style-found? - style<span class="Special"> <- </span>copy <span class="Constant">9472/horizontal</span> + style <span class="Special"><-</span> copy <span class="Constant">9472/horizontal</span> <span class="Delimiter">}</span> - color:num, color-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + color:num, color-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="Comment"># default color to white</span> <span class="muControl">break-if</span> color-found? - color<span class="Special"> <- </span>copy <span class="Constant">245/grey</span> + color <span class="Special"><-</span> copy <span class="Constant">245/grey</span> <span class="Delimiter">}</span> - bg-color:num, bg-color-found?:bool<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + bg-color:num, bg-color-found?:bool <span class="Special"><-</span> <span class="Constant">next-ingredient</span> <span class="Delimiter">{</span> <span class="muControl">break-if</span> bg-color-found? - bg-color<span class="Special"> <- </span>copy <span class="Constant">0/black</span> + bg-color <span class="Special"><-</span> copy <span class="Constant">0/black</span> <span class="Delimiter">}</span> - screen<span class="Special"> <- </span>move-cursor screen, row, x + screen <span class="Special"><-</span> move-cursor screen, row, x <span class="Delimiter">{</span> - continue?:bool<span class="Special"> <- </span>lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> + continue?:bool <span class="Special"><-</span> lesser-or-equal x, right <span class="Comment"># right is inclusive, to match editor semantics</span> <span class="muControl">break-unless</span> continue? print screen, style, color, bg-color - x<span class="Special"> <- </span>add x, <span class="Constant">1</span> + x <span class="Special"><-</span> add x,<span class="Constant"> 1</span> <span class="muControl">loop</span> <span class="Delimiter">}</span> ] |