about summary refs log tree commit diff stats
path: root/084console.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-23 15:50:27 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-23 15:50:57 -0700
commitd803b68769947a419ef176d5c80446fcba5e9ee3 (patch)
tree37e48143eadbd6297d835819e01176e46c7fd939 /084console.mu
parent300a1d6e8033f1766d5203b15ff3ea8570e4b79b (diff)
downloadmu-d803b68769947a419ef176d5c80446fcba5e9ee3.tar.gz
3565
Cleaning up the console interfaces before we start changing the socket
interfaces to look like them. Reading from sockets need to be
non-blocking just like reading from the console.
Diffstat (limited to '084console.mu')
-rw-r--r--084console.mu24
1 files changed, 12 insertions, 12 deletions
diff --git a/084console.mu b/084console.mu
index 0ae0f610..3677b84c 100644
--- a/084console.mu
+++ b/084console.mu
@@ -32,7 +32,7 @@ def new-fake-console events:&:@:event -> result:&:console [
   *result <- put *result, events:offset, events
 ]
 
-def read-event console:&:console -> result:event, console:&:console, found?:bool, quit?:bool [
+def read-event console:&:console -> result:event, found?:bool, quit?:bool, console:&:console [
   local-scope
   load-ingredients
   {
@@ -44,37 +44,37 @@ def read-event console:&:console -> result:event, console:&:console, found?:bool
       done?:bool <- greater-or-equal current-event-index, max
       break-unless done?
       dummy:&:event <- new event:type
-      return *dummy, console/same-as-ingredient:0, 1/found, 1/quit
+      return *dummy, 1/found, 1/quit
     }
     result <- index *buf, current-event-index
     current-event-index <- add current-event-index, 1
     *console <- put *console, current-event-index:offset, current-event-index
-    return result, console/same-as-ingredient:0, 1/found, 0/quit
+    return result, 1/found, 0/quit
   }
   switch  # real event source is infrequent; avoid polling it too much
   result:event, found?:bool <- check-for-interaction
-  return result, console/same-as-ingredient:0, found?, 0/quit
+  return result, found?, 0/quit
 ]
 
 # variant of read-event for just keyboard events. Discards everything that
 # isn't unicode, so no arrow keys, page-up/page-down, etc. But you still get
 # newlines, tabs, ctrl-d..
-def read-key console:&:console -> result:char, console:&:console, found?:bool, quit?:bool [
+def read-key console:&:console -> result:char, found?:bool, quit?:bool, console:&:console [
   local-scope
   load-ingredients
-  x:event, console, found?:bool, quit?:bool <- read-event console
-  return-if quit?, 0, console/same-as-ingredient:0, found?, quit?
-  return-unless found?, 0, console/same-as-ingredient:0, found?, quit?
+  x:event, found?:bool, quit?:bool, console <- read-event console
+  return-if quit?, 0, found?, quit?
+  return-unless found?, 0, found?, quit?
   c:char, converted?:bool <- maybe-convert x, text:variant
-  return-unless converted?, 0, console/same-as-ingredient:0, 0/found, 0/quit
-  return c, console/same-as-ingredient:0, 1/found, 0/quit
+  return-unless converted?, 0, 0/found, 0/quit
+  return c, 1/found, 0/quit
 ]
 
 def send-keys-to-channel console:&:console, chan:&:sink:char, screen:&:screen -> console:&:console, chan:&:sink:char, screen:&:screen [
   local-scope
   load-ingredients
   {
-    c:char, console, found?:bool, quit?:bool <- read-key console
+    c:char, found?:bool, quit?:bool, console <- read-key console
     loop-unless found?
     break-if quit?
     assert c, [invalid event, expected text]
@@ -89,7 +89,7 @@ def wait-for-event console:&:console -> console:&:console [
   local-scope
   load-ingredients
   {
-    _, console, found?:bool <- read-event console
+    _, found?:bool <- read-event console
     loop-unless found?
   }
 ]