about summary refs log tree commit diff stats
path: root/stdin.mu
blob: b5362f5b174a9469ff4be4b800a3a0c94baf9cf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(function main [
  (default-space:space-address <- new space:literal 30:literal)
  (cursor-mode)
  (clear-screen)
  ; hook up stdin
  (stdin:channel-address <- init-channel 1:literal)
;?   (print-primitive (("main: stdin is " literal)))
;?   (print-primitive stdin:channel-address)
;?   (print-primitive (("\n" literal)))
  (fork-helper send-keys-to-stdin:fn nil:literal/globals nil:literal/limit stdin:channel-address)
  ; now read characters from stdin until a 'q' is typed
  (print-primitive (("? " literal)))
  { begin
    (x:tagged-value stdin:channel-address/deref <- read stdin:channel-address)
    (c:character <- maybe-coerce x:tagged-value character:literal)
;?     (print-primitive (("main: stdin is " literal)))
;?     (print-primitive stdin:channel-address)
;?     (print-primitive (("\n" literal)))
;?     (print-primitive (("check: " literal)))
;?     (print-primitive c:character)
    (done?:boolean <- equal c:character ((#\q literal)))
    (break-if done?:boolean)
    (print-primitive c:character)
    (loop)
  }
])