diff options
Diffstat (limited to 'html/074console.mu.html')
-rw-r--r-- | html/074console.mu.html | 144 |
1 files changed, 71 insertions, 73 deletions
diff --git a/html/074console.mu.html b/html/074console.mu.html index 04b12ea8..f2eb5552 100644 --- a/html/074console.mu.html +++ b/html/074console.mu.html @@ -13,12 +13,10 @@ pre { white-space: pre-wrap; font-family: monospace; color: #eeeeee; background-color: #080808; } body { font-family: monospace; color: #eeeeee; background-color: #080808; } * { font-size: 1.05em; } -.muRecipe { color: #ff8700; } -.Comment { color: #9090ff; } -.Constant { color: #00a0a0; } .Special { color: #ff6060; } -.Delimiter { color: #a04060; } -.muControl { color: #c0a020; } +.Comment { color: #9090ff; } +.Underlined { color: #c000c0; text-decoration: underline; } +.Identifier { color: #804000; } --> </style> @@ -42,7 +40,7 @@ exclusive-container event [ ] container touch-event [ - type:number + <span class="Identifier">type</span>:number row:number column:number ] @@ -54,94 +52,94 @@ container resize-event [ container console [ index:number - data:address:array:event + data:address:<span class="Identifier">array</span>:event ] -<span class="muRecipe">recipe</span> new-fake-console [ - <span class="Constant">local-scope</span> - result:address:console<span class="Special"> <- </span>new <span class="Constant">console:type</span> - buf:address:address:array:character<span class="Special"> <- </span>get-address *result, <span class="Constant">data:offset</span> - *buf<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - 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 +recipe <span class="Identifier">new</span>-fake-console [ + <span class="Underlined">local</span>-scope + result:address:console<span class="Special"> <- </span><span class="Identifier">new</span> console:<span class="Identifier">type</span> + buf:address:address:<span class="Identifier">array</span>:character<span class="Special"> <- </span>get-address *result, data:offset + *buf<span class="Special"> <- </span>next-ingredient + idx:address:number<span class="Special"> <- </span>get-address *result, index:offset + *idx<span class="Special"> <- </span><span class="Identifier">copy</span> 0 + reply result ] -<span class="muRecipe">recipe</span> read-event [ - <span class="Constant">local-scope</span> - x:address:console<span class="Special"> <- </span><span class="Constant">next-ingredient</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="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="Delimiter">}</span> +recipe <span class="Identifier">read</span>-event [ + <span class="Underlined">local</span>-scope + x:address:console<span class="Special"> <- </span>next-ingredient + { + break-unless x + idx:address:number<span class="Special"> <- </span>get-address *x, index:offset + buf:address:<span class="Identifier">array</span>:event<span class="Special"> <- </span>get *x, data:offset + { + <span class="Identifier">max</span>:number<span class="Special"> <- </span><span class="Identifier">length</span> *buf + done?:boolean<span class="Special"> <- </span>greater-or-equal *idx, <span class="Identifier">max</span> + break-unless done? + dummy:address:event<span class="Special"> <- </span><span class="Identifier">new</span> event:<span class="Identifier">type</span> + reply *dummy, x/same-as-ingredient:0, 1/found, 1/<span class="Identifier">quit</span> + } result:event<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="Delimiter">}</span> + *idx<span class="Special"> <- </span>add *idx, 1 + reply result, x/same-as-ingredient:0, 1/found, 0/<span class="Identifier">quit</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> + reply result, x/same-as-ingredient:0, found?, 0/<span class="Identifier">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="Constant">local-scope</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</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? - c:address:character<span class="Special"> <- </span>maybe-convert x, <span class="Constant">text:variant</span> - <span class="muControl">reply-unless</span> c, <span class="Constant">0</span>, console/same-as-ingredient:<span class="Constant">0</span>, <span class="Constant">0/found</span>, <span class="Constant">0/quit</span> - <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> +recipe <span class="Identifier">read</span>-key [ + <span class="Underlined">local</span>-scope + console:address<span class="Special"> <- </span>next-ingredient + x:event, console, found?:boolean, <span class="Identifier">quit</span>?:boolean<span class="Special"> <- </span><span class="Identifier">read</span>-event console + reply-if <span class="Identifier">quit</span>?, 0, console/same-as-ingredient:0, found?, <span class="Identifier">quit</span>? + reply-unless found?, 0, console/same-as-ingredient:0, found?, <span class="Identifier">quit</span>? + c:address:character<span class="Special"> <- </span>maybe-convert x, text:variant + reply-unless c, 0, console/same-as-ingredient:0, 0/found, 0/<span class="Identifier">quit</span> + reply *c, console/same-as-ingredient:0, 1/found, 0/<span class="Identifier">quit</span> ] -<span class="muRecipe">recipe</span> send-keys-to-channel [ - <span class="Constant">local-scope</span> - console:address<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<span class="Special"> <- </span><span class="Constant">next-ingredient</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 - 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> +recipe send-keys-to-channel [ + <span class="Underlined">local</span>-scope + console:address<span class="Special"> <- </span>next-ingredient + chan:address:channel<span class="Special"> <- </span>next-ingredient + screen:address<span class="Special"> <- </span>next-ingredient + { + c:character, console, found?:boolean, <span class="Identifier">quit</span>?:boolean<span class="Special"> <- </span><span class="Identifier">read</span>-key console + loop-unless found? + break-if <span class="Identifier">quit</span>? + <span class="Identifier">assert</span> c, [invalid event, expected text] + screen<span class="Special"> <- </span><span class="Identifier">print</span>-character screen, c + chan<span class="Special"> <- </span><span class="Identifier">write</span> chan, c + loop + } + reply console/same-as-ingredient:0, chan/same-as-ingredient:1, screen/same-as-ingredient:2 ] -<span class="muRecipe">recipe</span> wait-for-event [ - <span class="Constant">local-scope</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</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> +recipe wait-for-event [ + <span class="Underlined">local</span>-scope + console:address<span class="Special"> <- </span>next-ingredient + { + _, console, found?:boolean<span class="Special"> <- </span><span class="Identifier">read</span>-event console + loop-unless found? + } + reply console/same-as-ingredient:0 ] <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="Constant">local-scope</span> - console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - <span class="Delimiter">{</span> - <span class="muControl">break-unless</span> console +recipe <span class="Identifier">has</span>-more-events? [ + <span class="Underlined">local</span>-scope + console:address<span class="Special"> <- </span>next-ingredient + { + break-unless 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> + reply 0/false + } result:boolean<span class="Special"> <- </span>interactions-left? - <span class="muControl">reply</span> result + reply result ] </pre> </body> |