From 65361948ca7975553757a0e0df4ac7352413044c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 14 May 2015 16:04:45 -0700 Subject: 1376 - update github docs --- html/074keyboard.mu.html | 69 ++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 25 deletions(-) (limited to 'html/074keyboard.mu.html') 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 @@ -Mu - 074keyboard.mu +~/Desktop/s/mu/074keyboard.mu @@ -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; } # Wrappers around keyboard primitives that take a 'keyboard' object and are thus # easier to test. -container keyboard [ # can't think of another word like screen/display, so real and fake keyboards use the same name - index:integer - data:address:array:character -] +container keyboard [ # can't think of another word like screen/display, so real and fake keyboards use the same name + index:number + data:address:array:character +] -recipe init-fake-keyboard [ - default-space:address:array:location <- new location:type, 30:literal +recipe init-fake-keyboard [ + default-space:address:array:location <- new location:type, 30:literal result:address:keyboard <- new keyboard:type - buf:address:address:array:character <- get-address result:address:keyboard/deref data:offset + buf:address:address:array:character <- get-address result:address:keyboard/deref, data:offset #? $start-tracing #? 1 buf:address:address:array:character/deref <- next-ingredient #? $stop-tracing #? 1 - idx:address:integer <- get-address result:address:keyboard/deref index:offset - idx:address:integer/deref <- copy 0:literal + idx:address:number <- get-address result:address:keyboard/deref, index:offset + idx:address:number/deref <- copy 0:literal reply result:address:keyboard -] +] -recipe read-key [ - default-space:address:array:location <- new location:type, 30:literal +recipe read-key [ + default-space:address:array:location <- new location:type, 30:literal x:address:keyboard <- next-ingredient { break-unless x:address:keyboard - idx:address:integer <- get-address x:address:keyboard/deref, index:offset + idx:address:number <- get-address x:address:keyboard/deref, index:offset buf:address:array:character <- get x:address:keyboard/deref, data:offset - max:integer <- length buf:address:array:character/deref + max:number <- length buf:address:array:character/deref { - done?:boolean <- greater-or-equal idx:address:integer/deref, max:integer + done?:boolean <- greater-or-equal idx:address:number/deref, max:number break-unless done?:boolean - reply 0:literal, 0:literal/done, x:address:keyboard/same-as-ingredient:0 + reply 0:literal/eof, 1:literal/found, x:address:keyboard/same-as-ingredient:0 } - c:character <- index buf:address:array:character/deref, idx:address:integer/deref - idx:address:integer/deref <- add idx:address:integer/deref, 1:literal - reply c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0 + c:character <- index buf:address:array:character/deref, idx:address:number/deref + idx:address:number/deref <- add idx:address:number/deref, 1:literal + reply c:character, 1:literal/found, x:address:keyboard/same-as-ingredient:0 } + # real keyboard input is infrequent; avoid polling it too much + switch c:character, found?:boolean <- read-key-from-keyboard reply c:character, found?:boolean, x:address:keyboard/same-as-ingredient:0 -] +] -recipe wait-for-key [ - default-space:address:array:location <- new location:type, 30:literal +recipe wait-for-key [ + default-space:address:array:location <- new location:type, 30:literal x:address:keyboard <- next-ingredient { break-unless x:address:keyboard @@ -81,7 +84,23 @@ recipe wait-for-key [ } c:character <- wait-for-key-from-keyboard reply c:character, x:address:keyboard/same-as-ingredient:0 -] +] + +recipe send-keys-to-channel [ + default-space:address:array:location <- new location:type, 30:literal + keyboard:address <- next-ingredient + chan:address:channel <- next-ingredient + screen:address <- next-ingredient + { + c:character, found?:boolean <- read-key keyboard:address + loop-unless found?:boolean +#? print-integer screen:address, c:character #? 1 + print-character screen:address, c:character + chan:address:channel <- write chan:address:channel, c:character + # todo: eof + loop + } +] -- cgit 1.4.1-2-gfad0