From f8c0ef3e201883566a788eb03c627f94680ba2c3 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 9 May 2015 10:56:44 -0700 Subject: 1315 - chessboard now working interactively I tried to bring too much into this commit, and paid the price with some debugging effort. Still havent't tried to enable line buffering, but I'll take a snapshot. Some tests are failing because of the huge hack in the scheduler. For a while I thought there was a bug in termbox because I kept seeing segfaults and valgrind complained about out-of-bounds access. But that was just subsidiary threads trying to print to the screen after I'd returned to console mode. Maybe I should add a test for send-keys-to-channel. Or just use a fake keyboard rather than a channel. And *then* there's the fact that the interaction is molasses slow. Slower than the arc version even though the tests run so much faster. And what's with the long pauses in printing strings to screen? --- 074keyboard.mu | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to '074keyboard.mu') diff --git a/074keyboard.mu b/074keyboard.mu index 9cea3d1f..d79d20f6 100644 --- a/074keyboard.mu +++ b/074keyboard.mu @@ -51,3 +51,18 @@ 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 <- read-key keyboard:address + loop-unless c:character + print-character screen:address, c:character + chan:address:channel <- write chan:address:channel, c:character + # todo: eof + loop + } +] -- cgit 1.4.1-2-gfad0