diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-11-29 14:18:52 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-11-29 14:18:52 -0800 |
commit | db1f56c8449d2ea3d158753fe37bac5a750a2566 (patch) | |
tree | 508a24c522c040498dbe7d60036035f3c4ae440a /html/084console.mu.html | |
parent | 3670fb87f6d38c9ba4fcbb1eaa6439b4007a194e (diff) | |
download | mu-db1f56c8449d2ea3d158753fe37bac5a750a2566.tar.gz |
2611
Diffstat (limited to 'html/084console.mu.html')
-rw-r--r-- | html/084console.mu.html | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/html/084console.mu.html b/html/084console.mu.html index c91544f9..b8619762 100644 --- a/html/084console.mu.html +++ b/html/084console.mu.html @@ -58,45 +58,45 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } data:address:array:event ] -<span class="muRecipe">recipe</span> new-fake-console [ +<span class="muRecipe">recipe</span> new-fake-console events:address:array:event<span class="muRecipe"> -> </span>result:address:console [ <span class="Constant">local-scope</span> + <span class="Constant">load-ingredients</span> result:address:console<span class="Special"> <- </span>new <span class="Constant">console:type</span> buf:address:address:array:event<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> - *buf<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + *buf<span class="Special"> <- </span>copy events idx:address:number<span class="Special"> <- </span>get-address *result, <span class="Constant">index:offset</span> *idx<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="muControl">reply</span> result ] -<span class="muRecipe">recipe</span> read-event [ +<span class="muRecipe">recipe</span> read-event console:address:console<span class="muRecipe"> -> </span>result:event, console:address:console, found?:boolean, quit?:boolean [ <span class="Constant">local-scope</span> - x:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> x - idx:address:number<span class="Special"> <- </span>get-address *x, <span class="Constant">index:offset</span> - buf:address:array:event<span class="Special"> <- </span>get *x, <span class="Constant">data:offset</span> + <span class="muControl">break-unless</span> console + idx:address:number<span class="Special"> <- </span>get-address *console, <span class="Constant">index:offset</span> + buf:address:array:event<span class="Special"> <- </span>get *console, <span class="Constant">data:offset</span> <span class="Delimiter">{</span> max:number<span class="Special"> <- </span>length *buf done?:boolean<span class="Special"> <- </span>greater-or-equal *idx, max <span class="muControl">break-unless</span> done? dummy:address:event<span class="Special"> <- </span>new <span class="Constant">event:type</span> - <span class="muControl">reply</span> *dummy, x/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">1/quit</span> + <span class="muControl">reply</span> *dummy, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">1/quit</span> <span class="Delimiter">}</span> - result:event<span class="Special"> <- </span>index *buf, *idx + result<span class="Special"> <- </span>index *buf, *idx *idx<span class="Special"> <- </span>add *idx, <span class="Constant">1</span> - <span class="muControl">reply</span> result, x/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span> + <span class="muControl">reply</span> result, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span> <span class="Delimiter">}</span> switch <span class="Comment"># real event source is infrequent; avoid polling it too much</span> result:event, found?:boolean<span class="Special"> <- </span>check-for-interaction - <span class="muControl">reply</span> result, x/same-as-ingredient:<span class="Constant">0</span>, found?, <span class="Constant">0/quit</span> + <span class="muControl">reply</span> result, console/same-as-ingredient:<span class="Constant">0</span>, found?, <span class="Constant">0/quit</span> ] <span class="Comment"># variant of read-event for just keyboard events. Discards everything that</span> <span class="Comment"># isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get</span> <span class="Comment"># newlines, tabs, ctrl-d..</span> -<span class="muRecipe">recipe</span> read-key [ +<span class="muRecipe">recipe</span> read-key console:address:console<span class="muRecipe"> -> </span>result:character, console:address:console, found?:boolean, quit?:boolean [ <span class="Constant">local-scope</span> - console:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> x:event, console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console <span class="muControl">reply-if</span> quit?, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, found?, quit? <span class="muControl">reply-unless</span> found?, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, found?, quit? @@ -105,44 +105,39 @@ body { font-family: monospace; color: #eeeeee; background-color: #080808; } <span class="muControl">reply</span> *c, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">1/found</span>, <span class="Constant">0/quit</span> ] -<span class="muRecipe">recipe</span> send-keys-to-channel [ +<span class="muRecipe">recipe</span> send-keys-to-channel console:address:console, chan:address:channel, screen:address:screen<span class="muRecipe"> -> </span>console:address:console, chan:address:channel, screen:address:screen [ <span class="Constant">local-scope</span> - console:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - chan:address:channel<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - screen:address:screen<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> c:character, console, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-key console <span class="muControl">loop-unless</span> found? <span class="muControl">break-if</span> quit? assert c, <span class="Constant">[invalid event, expected text]</span> - screen<span class="Special"> <- </span>print-character screen, c + screen<span class="Special"> <- </span>print screen, c chan<span class="Special"> <- </span>write chan, c <span class="muControl">loop</span> <span class="Delimiter">}</span> - <span class="muControl">reply</span> console/same-as-ingredient:<span class="Constant">0</span>, chan/same-as-ingredient:<span class="Constant">1</span>, screen/same-as-ingredient:<span class="Constant">2</span> ] -<span class="muRecipe">recipe</span> wait-for-event [ +<span class="muRecipe">recipe</span> wait-for-event console:address:console<span class="muRecipe"> -> </span>console:address:console [ <span class="Constant">local-scope</span> - console:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> _, console, found?:boolean<span class="Special"> <- </span>read-event console <span class="muControl">loop-unless</span> found? <span class="Delimiter">}</span> - <span class="muControl">reply</span> console/same-as-ingredient:<span class="Constant">0</span> ] <span class="Comment"># use this helper to skip rendering if there's lots of other events queued up</span> -<span class="muRecipe">recipe</span> has-more-events? [ +<span class="muRecipe">recipe</span> has-more-events? console:address:console<span class="muRecipe"> -> </span>result:boolean [ <span class="Constant">local-scope</span> - console:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + <span class="Constant">load-ingredients</span> <span class="Delimiter">{</span> <span class="muControl">break-unless</span> console <span class="Comment"># fake consoles should be plenty fast; never skip</span> <span class="muControl">reply</span> <span class="Constant">0/false</span> <span class="Delimiter">}</span> - result:boolean<span class="Special"> <- </span>interactions-left? - <span class="muControl">reply</span> result + result<span class="Special"> <- </span>interactions-left? ] </pre> </body> |