diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-05-14 16:04:45 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-05-14 16:04:45 -0700 |
commit | 65361948ca7975553757a0e0df4ac7352413044c (patch) | |
tree | 22063c089f67cb0d82623f2edc2c16b7e4389d41 /html/074keyboard.mu.html | |
parent | 64586540eccbc0880341782d329b419ab9d002de (diff) | |
download | mu-65361948ca7975553757a0e0df4ac7352413044c.tar.gz |
1376 - update github docs
Diffstat (limited to 'html/074keyboard.mu.html')
-rw-r--r-- | html/074keyboard.mu.html | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/html/074keyboard.mu.html b/html/074keyboard.mu.html index 13460315..e2b055a3 100644 --- a/html/074keyboard.mu.html +++ b/html/074keyboard.mu.html @@ -2,7 +2,7 @@ <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> -<title>Mu - 074keyboard.mu</title> +<title>~/Desktop/s/mu/074keyboard.mu</title> <meta name="Generator" content="Vim/7.4"> <meta name="plugin-version" content="vim7.4_v1"> <meta name="syntax" content="none"> @@ -14,8 +14,9 @@ pre { white-space: pre-wrap; font-family: monospace; color: #d0d0d0; background- body { font-family: monospace; color: #d0d0d0; background-color: #000000; } * { font-size: 1em; } .Identifier { color: #008080; } -.Comment { color: #8080ff; } .Delimiter { color: #c000c0; } +.Comment { color: #8080ff; } +.Constant { color: #008080; } .Special { color: #ff6060; } .CommentedCode { color: #6c6c6c; } --> @@ -32,46 +33,48 @@ body { font-family: monospace; color: #d0d0d0; background-color: #000000; } <span class="Comment"># Wrappers around keyboard primitives that take a 'keyboard' object and are thus</span> <span class="Comment"># easier to test.</span> -container keyboard <span class="Delimiter">[</span> <span class="Comment"># can't think of another word like screen/display, so real and fake keyboards use the same name</span> - index:integer - data:address:array:character -<span class="Delimiter">]</span> +container keyboard <span class="Constant">[ # can't think of another word like screen/display, so real and fake keyboards use the same name</span> +<span class="Constant"> index:number</span> +<span class="Constant"> data:address:array:character</span> +<span class="Constant">]</span> -recipe init-fake-keyboard <span class="Delimiter">[</span> - default-space:address:array:location<span class="Special"> <- </span>new location:type, 30:literal +recipe init-fake-keyboard [ + default-space:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> result:address:keyboard<span class="Special"> <- </span>new keyboard:type - buf:address:address:array:character<span class="Special"> <- </span>get-address result:address:keyboard/deref data:offset + buf:address:address:array:character<span class="Special"> <- </span>get-address result:address:keyboard/deref, data:offset <span class="CommentedCode">#? $start-tracing #? 1</span> buf:address:address:array:character/deref<span class="Special"> <- </span>next-ingredient <span class="CommentedCode">#? $stop-tracing #? 1</span> - idx:address:integer<span class="Special"> <- </span>get-address result:address:keyboard/deref index:offset - idx:address:integer/deref<span class="Special"> <- </span>copy 0:literal + idx:address:number<span class="Special"> <- </span>get-address result:address:keyboard/deref, index:offset + idx:address:number/deref<span class="Special"> <- </span>copy <span class="Constant">0:literal</span> <span class="Identifier">reply</span> result:address:keyboard -<span class="Delimiter">]</span> +] -recipe read-key <span class="Delimiter">[</span> - default-space:address:array:location<span class="Special"> <- </span>new location:type, 30:literal +recipe read-key [ + default-space:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> x:address:keyboard<span class="Special"> <- </span>next-ingredient <span class="Delimiter">{</span> <span class="Identifier">break-unless</span> x:address:keyboard - idx:address:integer<span class="Special"> <- </span>get-address x:address:keyboard/deref, index:offset + idx:address:number<span class="Special"> <- </span>get-address x:address:keyboard/deref, index:offset buf:address:array:character<span class="Special"> <- </span>get x:address:keyboard/deref, data:offset - max:integer<span class="Special"> <- </span>length buf:address:array:character/deref + max:number<span class="Special"> <- </span>length buf:address:array:character/deref <span class="Delimiter">{</span> - done?:boolean<span class="Special"> <- </span>greater-or-equal idx:address:integer/deref, max:integer + done?:boolean<span class="Special"> <- </span>greater-or-equal idx:address:number/deref, max:number <span class="Identifier">break-unless</span> done?:boolean - <span class="Identifier">reply</span> 0:literal, 0:literal/done, x:address:keyboard/same-as-ingredient:0 + <span class="Identifier">reply</span> <span class="Constant">0:literal/eof</span>, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 <span class="Delimiter">}</span> - c:character<span class="Special"> <- </span>index buf:address:array:character/deref, idx:address:integer/deref - idx:address:integer/deref<span class="Special"> <- </span>add idx:address:integer/deref, 1:literal - <span class="Identifier">reply</span> c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0 + c:character<span class="Special"> <- </span>index buf:address:array:character/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="Identifier">reply</span> c:character, <span class="Constant">1:literal/found</span>, x:address:keyboard/same-as-ingredient:0 <span class="Delimiter">}</span> + <span class="Comment"># real keyboard input is infrequent; avoid polling it too much</span> + switch c:character, found?:boolean<span class="Special"> <- </span>read-key-from-keyboard <span class="Identifier">reply</span> c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0 -<span class="Delimiter">]</span> +] -recipe wait-for-key <span class="Delimiter">[</span> - default-space:address:array:location<span class="Special"> <- </span>new location:type, 30:literal +recipe wait-for-key [ + default-space:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> x:address:keyboard<span class="Special"> <- </span>next-ingredient <span class="Delimiter">{</span> <span class="Identifier">break-unless</span> x:address:keyboard @@ -81,7 +84,23 @@ recipe wait-for-key <span class="Delimiter">[</span> <span class="Delimiter">}</span> c:character<span class="Special"> <- </span>wait-for-key-from-keyboard <span class="Identifier">reply</span> c:character, x:address:keyboard/same-as-ingredient:0 -<span class="Delimiter">]</span> +] + +recipe send-keys-to-channel [ + default-space:address:array:location<span class="Special"> <- </span>new location:type, <span class="Constant">30:literal</span> + keyboard:address<span class="Special"> <- </span>next-ingredient + chan:address:channel<span class="Special"> <- </span>next-ingredient + screen:address<span class="Special"> <- </span>next-ingredient + <span class="Delimiter">{</span> + c:character, found?:boolean<span class="Special"> <- </span>read-key keyboard:address + <span class="Identifier">loop-unless</span> found?:boolean +<span class="CommentedCode">#? print-integer screen:address, c:character #? 1</span> + print-character screen:address, c:character + chan:address:channel<span class="Special"> <- </span>write chan:address:channel, c:character + <span class="Comment"># todo: eof</span> + <span class="Identifier">loop</span> + <span class="Delimiter">}</span> +] </pre> </body> </html> |