diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-07-29 15:55:05 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-07-29 15:55:05 -0700 |
commit | 9570363aec35e187e2395b1760a4b94e71580ac9 (patch) | |
tree | 5b0d9cf65b5d5a403ab29e88535ba158efb276fe /html/074console.mu.html | |
parent | b318b7fb127a2bdf3e394b315a45d339dc738447 (diff) | |
download | mu-9570363aec35e187e2395b1760a4b94e71580ac9.tar.gz |
1885
Diffstat (limited to 'html/074console.mu.html')
-rw-r--r-- | html/074console.mu.html | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/html/074console.mu.html b/html/074console.mu.html index 104ac569..53c01cfe 100644 --- a/html/074console.mu.html +++ b/html/074console.mu.html @@ -13,13 +13,12 @@ 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; } .Delimiter { color: #a04060; } -.CommentedCode { color: #6c6c6c; } .Comment { color: #9090ff; } .Constant { color: #00a0a0; } .Special { color: #ff6060; } .muControl { color: #c0a020; } -.muRecipe { color: #ff8700; } --> </style> @@ -55,37 +54,35 @@ container console [ <span class="muRecipe">recipe</span> new-fake-console [ <span class="Constant">local-scope</span> result:address:console<span class="Special"> <- </span>new console:type - buf:address:address:array:character<span class="Special"> <- </span>get-address result:address:console/deref, data:offset -<span class="CommentedCode">#? $start-tracing #? 1</span> - buf:address:address:array:character/deref<span class="Special"> <- </span><span class="Constant">next-ingredient</span> -<span class="CommentedCode">#? $stop-tracing #? 1</span> - idx:address:number<span class="Special"> <- </span>get-address result:address:console/deref, index:offset - idx:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> - <span class="muControl">reply</span> result:address:console + buf:address:address:array:character<span class="Special"> <- </span>get-address *result, data:offset + *buf<span class="Special"> <- </span><span class="Constant">next-ingredient</span> + idx:address:number<span class="Special"> <- </span>get-address *result, index:offset + *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="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:address:console - idx:address:number<span class="Special"> <- </span>get-address x:address:console/deref, index:offset - buf:address:array:event<span class="Special"> <- </span>get x:address:console/deref, data:offset + <span class="muControl">break-unless</span> x + idx:address:number<span class="Special"> <- </span>get-address *x, index:offset + buf:address:array:event<span class="Special"> <- </span>get *x, data:offset <span class="Delimiter">{</span> - max:number<span class="Special"> <- </span>length buf:address:array:event/deref - done?:boolean<span class="Special"> <- </span>greater-or-equal idx:address:number/deref, max:number - <span class="muControl">break-unless</span> done?:boolean + 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 event:type - <span class="muControl">reply</span> dummy:address:event/deref, x:address:console/same-as-ingredient:0, <span class="Constant">1:literal/found</span>, <span class="Constant">1:literal/quit</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> - result:event<span class="Special"> <- </span>index buf:address:array:event/deref, idx:address:number/deref - idx:address:number/deref<span class="Special"> <- </span>add idx:address:number/deref, <span class="Constant">1:literal</span> - <span class="muControl">reply</span> result:event, x:address:console/same-as-ingredient:0, <span class="Constant">1:literal/found</span>, <span class="Constant">0:literal/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> <span class="Comment"># real event source is infrequent; avoid polling it too much</span> switch result:event, found?:boolean<span class="Special"> <- </span>check-for-interaction - <span class="muControl">reply</span> result:event, x:address:console/same-as-ingredient:0, found?:boolean, <span class="Constant">0:literal/quit</span> + <span class="muControl">reply</span> result, x/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> @@ -93,20 +90,13 @@ container console [ <span class="Comment"># newlines, tabs, ctrl-d..</span> <span class="muRecipe">recipe</span> read-key [ <span class="Constant">local-scope</span> -<span class="CommentedCode">#? $print default-space:address:array:location #? 1</span> -<span class="CommentedCode">#? $exit #? 1</span> -<span class="CommentedCode">#? $start-tracing #? 1</span> console:address<span class="Special"> <- </span><span class="Constant">next-ingredient</span> - x:event, console:address, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-event console:address -<span class="CommentedCode">#? $print [aaa 1] #? 1</span> - <span class="muControl">reply-if</span> quit?:boolean, <span class="Constant">0:literal</span>, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean -<span class="CommentedCode">#? $print [aaa 2] #? 1</span> - <span class="muControl">reply-unless</span> found?:boolean, <span class="Constant">0:literal</span>, console:address/same-as-ingredient:0, found?:boolean, quit?:boolean -<span class="CommentedCode">#? $print [aaa 3] #? 1</span> - c:address:character<span class="Special"> <- </span>maybe-convert x:event, text:variant - <span class="muControl">reply-unless</span> c:address:character, <span class="Constant">0:literal</span>, console:address/same-as-ingredient:0, <span class="Constant">0:literal/found</span>, <span class="Constant">0:literal/quit</span> -<span class="CommentedCode">#? $print [aaa 4] #? 1</span> - <span class="muControl">reply</span> c:address:character/deref, console:address/same-as-ingredient:0, <span class="Constant">1:literal/found</span>, <span class="Constant">0:literal/quit</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, text:variant + <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> ] <span class="muRecipe">recipe</span> send-keys-to-channel [ @@ -115,23 +105,25 @@ container console [ 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:address, found?:boolean, quit?:boolean<span class="Special"> <- </span>read-key console:address - <span class="muControl">loop-unless</span> found?:boolean - <span class="muControl">break-if</span> quit?:boolean - assert c:character, <span class="Constant">[invalid event, expected text]</span> - print-character screen:address, c:character - chan:address:channel<span class="Special"> <- </span>write chan:address:channel, c:character + 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> ] <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:address, found?:boolean<span class="Special"> <- </span>read-event console:address - <span class="muControl">loop-unless</span> found?:boolean + _, 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> @@ -139,12 +131,12 @@ container console [ <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:address + <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:literal/false</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:boolean + <span class="muControl">reply</span> result ] </pre> </body> |