about summary refs log tree commit diff stats
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
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.
-rw-r--r--084console.mu24
-rw-r--r--085scenario_console.cc8
-rw-r--r--086scenario_console_test.mu8
-rw-r--r--edit/002-typing.mu2
-rw-r--r--edit/004-programming-environment.mu2
-rw-r--r--sandbox/002-typing.mu2
-rw-r--r--sandbox/004-programming-environment.mu2
7 files changed, 24 insertions, 24 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?
   }
 ]
diff --git a/085scenario_console.cc b/085scenario_console.cc
index 18ca6607..f781a8ca 100644
--- a/085scenario_console.cc
+++ b/085scenario_console.cc
@@ -15,10 +15,10 @@ scenario keyboard-in-scenario [
     type [abc]
   ]
   run [
-    1:char, console, 2:bool <- read-key console
-    3:char, console, 4:bool <- read-key console
-    5:char, console, 6:bool <- read-key console
-    7:char, console, 8:bool, 9:bool <- read-key console
+    1:char, 2:bool <- read-key console
+    3:char, 4:bool <- read-key console
+    5:char, 6:bool <- read-key console
+    7:char, 8:bool, 9:bool <- read-key console
   ]
   memory-should-contain [
     1 <- 97  # 'a'
diff --git a/086scenario_console_test.mu b/086scenario_console_test.mu
index 1d647600..f5aa1438 100644
--- a/086scenario_console_test.mu
+++ b/086scenario_console_test.mu
@@ -7,10 +7,10 @@ scenario read-key-in-mu [
     type [abc]
   ]
   run [
-    1:char, console, 2:bool <- read-key console
-    3:char, console, 4:bool <- read-key console
-    5:char, console, 6:bool <- read-key console
-    7:char, console, 8:bool <- read-key console
+    1:char, 2:bool <- read-key console
+    3:char, 4:bool <- read-key console
+    5:char, 6:bool <- read-key console
+    7:char, 8:bool <- read-key console
   ]
   memory-should-contain [
     1 <- 97  # 'a'
diff --git a/edit/002-typing.mu b/edit/002-typing.mu
index 12448e18..906422f5 100644
--- a/edit/002-typing.mu
+++ b/edit/002-typing.mu
@@ -20,7 +20,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> scr
     cursor-row:num <- get *editor, cursor-row:offset
     cursor-column:num <- get *editor, cursor-column:offset
     screen <- move-cursor screen, cursor-row, cursor-column
-    e:event, console, found?:bool, quit?:bool <- read-event console
+    e:event, found?:bool, quit?:bool, console <- read-event console
     loop-unless found?
     break-if quit?  # only in tests
     trace 10, [app], [next-event]
diff --git a/edit/004-programming-environment.mu b/edit/004-programming-environment.mu
index d7107b35..13969cf3 100644
--- a/edit/004-programming-environment.mu
+++ b/edit/004-programming-environment.mu
@@ -61,7 +61,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
   {
     # looping over each (keyboard or touch) event as it occurs
     +next-event
-    e:event, console, found?:bool, quit?:bool <- read-event console
+    e:event, found?:bool, quit?:bool, console <- read-event console
     loop-unless found?
     break-if quit?  # only in tests
     trace 10, [app], [next-event]
diff --git a/sandbox/002-typing.mu b/sandbox/002-typing.mu
index 12448e18..906422f5 100644
--- a/sandbox/002-typing.mu
+++ b/sandbox/002-typing.mu
@@ -20,7 +20,7 @@ def editor-event-loop screen:&:screen, console:&:console, editor:&:editor -> scr
     cursor-row:num <- get *editor, cursor-row:offset
     cursor-column:num <- get *editor, cursor-column:offset
     screen <- move-cursor screen, cursor-row, cursor-column
-    e:event, console, found?:bool, quit?:bool <- read-event console
+    e:event, found?:bool, quit?:bool, console <- read-event console
     loop-unless found?
     break-if quit?  # only in tests
     trace 10, [app], [next-event]
diff --git a/sandbox/004-programming-environment.mu b/sandbox/004-programming-environment.mu
index 76938021..57eff09f 100644
--- a/sandbox/004-programming-environment.mu
+++ b/sandbox/004-programming-environment.mu
@@ -49,7 +49,7 @@ def event-loop screen:&:screen, console:&:console, env:&:environment -> screen:&
   {
     # looping over each (keyboard or touch) event as it occurs
     +next-event
-    e:event, console, found?:bool, quit?:bool <- read-event console
+    e:event, found?:bool, quit?:bool, console <- read-event console
     loop-unless found?
     break-if quit?  # only in tests
     trace 10, [app], [next-event]