diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 23:15:12 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-10-23 23:15:12 -0700 |
commit | 2e4f0bbd12231a51ae08df4fe0f8847111fde405 (patch) | |
tree | 581166406a4749ac2dcd87c8555cc95dbb1bbd52 /html/081print.mu.html | |
parent | 2225b945ad5ba9310081b371bf32a9f575646e1b (diff) | |
download | mu-2e4f0bbd12231a51ae08df4fe0f8847111fde405.tar.gz |
3578
Diffstat (limited to 'html/081print.mu.html')
-rw-r--r-- | html/081print.mu.html | 363 |
1 files changed, 165 insertions, 198 deletions
diff --git a/html/081print.mu.html b/html/081print.mu.html index 4955c3b1..241cf857 100644 --- a/html/081print.mu.html +++ b/html/081print.mu.html @@ -62,44 +62,40 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> clear-screen screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="Comment"># clear fake screen</span> - buf:&:@:screen-cell <span class="Special"><-</span> get *screen, <span class="Constant">data:offset</span> - max:num <span class="Special"><-</span> length *buf - i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> - <span class="Delimiter">{</span> - done?:bool <span class="Special"><-</span> greater-or-equal i, max - <span class="muControl">break-if</span> done? - curr:screen-cell <span class="Special"><-</span> merge <span class="Constant">0/empty</span>, <span class="Constant">7/white</span> - *buf <span class="Special"><-</span> put-index *buf, i, curr - i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="Comment"># reset cursor</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 0</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>,<span class="Constant"> 0</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + clear-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - clear-display + <span class="Comment"># fake screen</span> + buf:&:@:screen-cell <span class="Special"><-</span> get *screen, <span class="Constant">data:offset</span> + max:num <span class="Special"><-</span> length *buf + i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> + <span class="Delimiter">{</span> + done?:bool <span class="Special"><-</span> greater-or-equal i, max + <span class="muControl">break-if</span> done? + curr:screen-cell <span class="Special"><-</span> merge <span class="Constant">0/empty</span>, <span class="Constant">7/white</span> + *buf <span class="Special"><-</span> put-index *buf, i, curr + i <span class="Special"><-</span> add i,<span class="Constant"> 1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="Comment"># reset cursor</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>,<span class="Constant"> 0</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>,<span class="Constant"> 0</span> ] <span class="muRecipe">def</span> sync-screen screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Delimiter">{</span> - <span class="muControl">break-if</span> screen - sync-display - <span class="Delimiter">}</span> - <span class="Comment"># do nothing for fake screens</span> + <span class="muControl">return-if</span> screen <span class="Comment"># do nothing for fake screens</span> + sync-display ] <span class="muRecipe">def</span> fake-screen-is-empty? screen:&:screen<span class="muRecipe"> -> </span>result:bool [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="muControl">return-unless</span> screen, <span class="Constant">1/true</span> + <span class="muControl">return-unless</span> screen, <span class="Constant">1/true</span> <span class="Comment"># do nothing for real screens</span> buf:&:@:screen-cell <span class="Special"><-</span> get *screen, <span class="Constant">data:offset</span> i:num <span class="Special"><-</span> copy<span class="Constant"> 0</span> len:num <span class="Special"><-</span> length *buf @@ -134,76 +130,76 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color c2:num <span class="Special"><-</span> character-to-code c trace<span class="Constant"> 90</span>, <span class="Constant">[print-character]</span>, c2 <span class="Delimiter">{</span> - <span class="Comment"># if x exists</span> - <span class="Comment"># (handle special cases exactly like in the real screen)</span> - <span class="muControl">break-unless</span> screen - width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> - height:num <span class="Special"><-</span> get *screen, <span class="Constant">num-rows:offset</span> - <span class="Comment"># if cursor is out of bounds, silently exit</span> - row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> - legal?:bool <span class="Special"><-</span> greater-or-equal row,<span class="Constant"> 0</span> - <span class="muControl">return-unless</span> legal? - legal? <span class="Special"><-</span> lesser-than row, height - <span class="muControl">return-unless</span> legal? - column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> - legal? <span class="Special"><-</span> greater-or-equal column,<span class="Constant"> 0</span> - <span class="muControl">return-unless</span> legal? - legal? <span class="Special"><-</span> lesser-than column, width - <span class="muControl">return-unless</span> legal? + <span class="Comment"># real screen</span> + <span class="muControl">break-if</span> screen + print-character-to-display c, color, bg-color + <span class="muControl">return</span> + <span class="Delimiter">}</span> + <span class="Comment"># fake screen</span> + <span class="Comment"># (handle special cases exactly like in the real screen)</span> + width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> + height:num <span class="Special"><-</span> get *screen, <span class="Constant">num-rows:offset</span> + <span class="Comment"># if cursor is out of bounds, silently exit</span> + row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> + legal?:bool <span class="Special"><-</span> greater-or-equal row,<span class="Constant"> 0</span> + <span class="muControl">return-unless</span> legal? + legal? <span class="Special"><-</span> lesser-than row, height + <span class="muControl">return-unless</span> legal? + column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> + legal? <span class="Special"><-</span> greater-or-equal column,<span class="Constant"> 0</span> + <span class="muControl">return-unless</span> legal? + legal? <span class="Special"><-</span> lesser-than column, width + <span class="muControl">return-unless</span> legal? <span class="CommentedCode">#? $print [print-character (], row, [, ], column, [): ], c, 10/newline</span> - <span class="Comment"># special-case: newline</span> - <span class="Delimiter">{</span> - newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> - <span class="muControl">break-unless</span> newline? - <span class="Delimiter">{</span> - <span class="Comment"># unless cursor is already at bottom</span> - bottom:num <span class="Special"><-</span> subtract height,<span class="Constant"> 1</span> - at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, bottom - <span class="muControl">break-if</span> at-bottom? - <span class="Comment"># move it to the next row</span> - column <span class="Special"><-</span> copy<span class="Constant"> 0</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column - row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row - <span class="Delimiter">}</span> - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># save character in fake screen</span> - index:num <span class="Special"><-</span> multiply row, width - index <span class="Special"><-</span> add index, column - buf:&:@:screen-cell <span class="Special"><-</span> get *screen, <span class="Constant">data:offset</span> - len:num <span class="Special"><-</span> length *buf - <span class="Comment"># special-case: backspace</span> + <span class="Comment"># special-case: newline</span> + <span class="Delimiter">{</span> + newline?:bool <span class="Special"><-</span> equal c, <span class="Constant">10/newline</span> + <span class="muControl">break-unless</span> newline? <span class="Delimiter">{</span> - backspace?:bool <span class="Special"><-</span> equal c,<span class="Constant"> 8</span> - <span class="muControl">break-unless</span> backspace? - <span class="Delimiter">{</span> - <span class="Comment"># unless cursor is already at left margin</span> - at-left?:bool <span class="Special"><-</span> lesser-or-equal column,<span class="Constant"> 0</span> - <span class="muControl">break-if</span> at-left? - <span class="Comment"># clear previous location</span> - column <span class="Special"><-</span> subtract column,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column - index <span class="Special"><-</span> subtract index,<span class="Constant"> 1</span> - cursor:screen-cell <span class="Special"><-</span> merge <span class="Constant">32/space</span>, <span class="Constant">7/white</span> - *buf <span class="Special"><-</span> put-index *buf, index, cursor - <span class="Delimiter">}</span> - <span class="muControl">return</span> + <span class="Comment"># unless cursor is already at bottom</span> + bottom:num <span class="Special"><-</span> subtract height,<span class="Constant"> 1</span> + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, bottom + <span class="muControl">break-if</span> at-bottom? + <span class="Comment"># move it to the next row</span> + column <span class="Special"><-</span> copy<span class="Constant"> 0</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row <span class="Delimiter">}</span> - cursor:screen-cell <span class="Special"><-</span> merge c, color - *buf <span class="Special"><-</span> put-index *buf, index, cursor - <span class="Comment"># increment column unless it's already all the way to the right</span> + <span class="muControl">return</span> + <span class="Delimiter">}</span> + <span class="Comment"># save character in fake screen</span> + index:num <span class="Special"><-</span> multiply row, width + index <span class="Special"><-</span> add index, column + buf:&:@:screen-cell <span class="Special"><-</span> get *screen, <span class="Constant">data:offset</span> + len:num <span class="Special"><-</span> length *buf + <span class="Comment"># special-case: backspace</span> + <span class="Delimiter">{</span> + backspace?:bool <span class="Special"><-</span> equal c,<span class="Constant"> 8</span> + <span class="muControl">break-unless</span> backspace? <span class="Delimiter">{</span> - right:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> - at-right?:bool <span class="Special"><-</span> greater-or-equal column, right - <span class="muControl">break-if</span> at-right? - column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + <span class="Comment"># unless cursor is already at left margin</span> + at-left?:bool <span class="Special"><-</span> lesser-or-equal column,<span class="Constant"> 0</span> + <span class="muControl">break-if</span> at-left? + <span class="Comment"># clear previous location</span> + column <span class="Special"><-</span> subtract column,<span class="Constant"> 1</span> *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column + index <span class="Special"><-</span> subtract index,<span class="Constant"> 1</span> + cursor:screen-cell <span class="Special"><-</span> merge <span class="Constant">32/space</span>, <span class="Constant">7/white</span> + *buf <span class="Special"><-</span> put-index *buf, index, cursor <span class="Delimiter">}</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - print-character-to-display c, color, bg-color + cursor:screen-cell <span class="Special"><-</span> merge c, color + *buf <span class="Special"><-</span> put-index *buf, index, cursor + <span class="Comment"># increment column unless it's already all the way to the right</span> + <span class="Delimiter">{</span> + right:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> + at-right?:bool <span class="Special"><-</span> greater-or-equal column, right + <span class="muControl">break-if</span> at-right? + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column + <span class="Delimiter">}</span> ] <span class="muScenario">scenario</span> print-character-at-top-left [ @@ -400,27 +396,27 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> space:char <span class="Special"><-</span> copy <span class="Constant">0/nul</span> - <span class="Comment"># if x exists, clear line in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> - column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> - original-column:num <span class="Special"><-</span> copy column - <span class="Comment"># space over the entire line</span> - <span class="Delimiter">{</span> - right:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> - done?:bool <span class="Special"><-</span> greater-or-equal column, right - <span class="muControl">break-if</span> done? - print screen, space - column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> - <span class="muControl">loop</span> - <span class="Delimiter">}</span> - <span class="Comment"># now back to where the cursor was</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, original-column + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + clear-line-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - clear-line-on-display + <span class="Comment"># fake screen</span> + width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> + column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> + original-column:num <span class="Special"><-</span> copy column + <span class="Comment"># space over the entire line</span> + <span class="Delimiter">{</span> + right:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> + done?:bool <span class="Special"><-</span> greater-or-equal column, right + <span class="muControl">break-if</span> done? + print screen, space + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + <span class="muControl">loop</span> + <span class="Delimiter">}</span> + <span class="Comment"># now back to where the cursor was</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, original-column ] <span class="muRecipe">def</span> clear-line-until screen:&:screen, right:num/inclusive<span class="muRecipe"> -> </span>screen:&:screen [ @@ -446,28 +442,29 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> cursor-position screen:&:screen<span class="muRecipe"> -> </span>row:num, column:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, lookup cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> - column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + row, column <span class="Special"><-</span> cursor-position-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - row, column <span class="Special"><-</span> cursor-position-on-display + <span class="Comment"># fake screen</span> + row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> + column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> ] <span class="muRecipe">def</span> move-cursor screen:&:screen, new-row:num, new-column:num<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, new-row - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, new-column + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + move-cursor-on-display new-row, new-column <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - move-cursor-on-display new-row, new-column + <span class="Comment"># fake screen</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, new-row + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, new-column ] <span class="muScenario">scenario</span> clear-line-erases-printed-characters [ @@ -504,85 +501,73 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> cursor-down screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="Delimiter">{</span> - <span class="Comment"># increment row unless it's already all the way down</span> - height:num <span class="Special"><-</span> get *screen, <span class="Constant">num-rows:offset</span> - row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> - max:num <span class="Special"><-</span> subtract height,<span class="Constant"> 1</span> - at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, max - <span class="muControl">break-if</span> at-bottom? - row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row - <span class="Delimiter">}</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + move-cursor-down-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - move-cursor-down-on-display + <span class="Comment"># fake screen</span> + height:num <span class="Special"><-</span> get *screen, <span class="Constant">num-rows:offset</span> + row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> + max:num <span class="Special"><-</span> subtract height,<span class="Constant"> 1</span> + at-bottom?:bool <span class="Special"><-</span> greater-or-equal row, max + <span class="muControl">return-if</span> at-bottom? + row <span class="Special"><-</span> add row,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row ] <span class="muRecipe">def</span> cursor-up screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="Delimiter">{</span> - <span class="Comment"># decrement row unless it's already all the way up</span> - row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> - at-top?:bool <span class="Special"><-</span> lesser-or-equal row,<span class="Constant"> 0</span> - <span class="muControl">break-if</span> at-top? - row <span class="Special"><-</span> subtract row,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row - <span class="Delimiter">}</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + move-cursor-up-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - move-cursor-up-on-display + <span class="Comment"># fake screen</span> + row:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-row:offset</span> + at-top?:bool <span class="Special"><-</span> lesser-or-equal row,<span class="Constant"> 0</span> + <span class="muControl">return-if</span> at-top? + row <span class="Special"><-</span> subtract row,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-row:offset</span>, row ] <span class="muRecipe">def</span> cursor-right screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="Delimiter">{</span> - <span class="Comment"># increment column unless it's already all the way to the right</span> - width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> - column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> - max:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> - at-bottom?:bool <span class="Special"><-</span> greater-or-equal column, max - <span class="muControl">break-if</span> at-bottom? - column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column - <span class="Delimiter">}</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + move-cursor-right-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - move-cursor-right-on-display + <span class="Comment"># fake screen</span> + width:num <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> + column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> + max:num <span class="Special"><-</span> subtract width,<span class="Constant"> 1</span> + at-bottom?:bool <span class="Special"><-</span> greater-or-equal column, max + <span class="muControl">return-if</span> at-bottom? + column <span class="Special"><-</span> add column,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column ] <span class="muRecipe">def</span> cursor-left screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="Delimiter">{</span> - <span class="Comment"># decrement column unless it's already all the way to the left</span> - column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> - at-top?:bool <span class="Special"><-</span> lesser-or-equal column,<span class="Constant"> 0</span> - <span class="muControl">break-if</span> at-top? - column <span class="Special"><-</span> subtract column,<span class="Constant"> 1</span> - *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column - <span class="Delimiter">}</span> + <span class="muControl">break-if</span> screen + <span class="Comment"># real screen</span> + move-cursor-left-on-display <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> - move-cursor-left-on-display + <span class="Comment"># fake screen</span> + column:num <span class="Special"><-</span> get *screen, <span class="Constant">cursor-column:offset</span> + at-top?:bool <span class="Special"><-</span> lesser-or-equal column,<span class="Constant"> 0</span> + <span class="muControl">return-if</span> at-top? + column <span class="Special"><-</span> subtract column,<span class="Constant"> 1</span> + *screen <span class="Special"><-</span> put *screen, <span class="Constant">cursor-column:offset</span>, column ] <span class="muRecipe">def</span> cursor-to-start-of-line screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ @@ -610,76 +595,58 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="muRecipe">def</span> screen-width screen:&:screen<span class="muRecipe"> -> </span>width:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> screen + <span class="Comment"># fake screen</span> width <span class="Special"><-</span> get *screen, <span class="Constant">num-columns:offset</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="Comment"># real screen</span> width <span class="Special"><-</span> display-width ] <span class="muRecipe">def</span> screen-height screen:&:screen<span class="muRecipe"> -> </span>height:num [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists, move cursor in fake screen</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> screen + <span class="Comment"># fake screen</span> height <span class="Special"><-</span> get *screen, <span class="Constant">num-rows:offset</span> <span class="muControl">return</span> <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="Comment"># real screen</span> height <span class="Special"><-</span> display-height ] <span class="muRecipe">def</span> hide-cursor screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists (not real display), do nothing</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="muControl">reply-if</span> screen <span class="Comment"># fake screen; do nothing</span> + <span class="Comment"># real screen</span> hide-cursor-on-display ] <span class="muRecipe">def</span> show-cursor screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists (not real display), do nothing</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="muControl">reply-if</span> screen <span class="Comment"># fake screen; do nothing</span> + <span class="Comment"># real screen</span> show-cursor-on-display ] <span class="muRecipe">def</span> hide-screen screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists (not real display), do nothing</span> - <span class="Comment"># todo: help test this</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="muControl">reply-if</span> screen <span class="Comment"># fake screen; do nothing</span> + <span class="Comment"># real screen</span> hide-display ] <span class="muRecipe">def</span> show-screen screen:&:screen<span class="muRecipe"> -> </span>screen:&:screen [ <span class="Constant">local-scope</span> <span class="Constant">load-ingredients</span> - <span class="Comment"># if x exists (not real display), do nothing</span> - <span class="Comment"># todo: help test this</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> screen - <span class="muControl">return</span> - <span class="Delimiter">}</span> - <span class="Comment"># otherwise, real screen</span> + <span class="muControl">reply-if</span> screen <span class="Comment"># fake screen; do nothing</span> + <span class="Comment"># real screen</span> show-display ] |