about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-04-10 20:49:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-10 20:49:20 -0700
commita509279aea989b4c0f47d1e11965ed297a4d6587 (patch)
tree5e3fb59b00bc6fa7f586dd9fd1cffbbfbe8caf16 /shell
parent400574f956f8428785ecefe5536ebf5512f23408 (diff)
downloadmu-a509279aea989b4c0f47d1e11965ed297a4d6587.tar.gz
shell: start on support for fake keyboard
Diffstat (limited to 'shell')
-rw-r--r--shell/cell.mu12
-rw-r--r--shell/sandbox.mu7
2 files changed, 17 insertions, 2 deletions
diff --git a/shell/cell.mu b/shell/cell.mu
index 9dfe298b..6ca1fcb3 100644
--- a/shell/cell.mu
+++ b/shell/cell.mu
@@ -12,6 +12,8 @@ type cell {
   index-data: int
   # type 5: screen
   screen-data: (handle screen)
+  # type 6: keyboard
+  keyboard-data: (handle stream byte)
   # TODO: array, (associative) table, stream
 }
 
@@ -148,3 +150,13 @@ fn clear-screen-cell _self-ah: (addr handle cell) {
   var screen/eax: (addr screen) <- lookup *screen-ah
   clear-screen screen
 }
+
+fn allocate-keyboard _out: (addr handle cell), capacity: int {
+  var out/eax: (addr handle cell) <- copy _out
+  allocate out
+  var out-addr/eax: (addr cell) <- lookup *out
+  var dest-ah/ecx: (addr handle stream byte) <- get out-addr, keyboard-data
+  populate-stream dest-ah, capacity
+  var type/ecx: (addr int) <- get out-addr, type
+  copy-to *type, 6/keyboard
+}
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index f39c9d24..e40f4ab6 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -2,11 +2,12 @@ type sandbox {
   data: (handle gap-buffer)
   value: (handle stream byte)
   screen-var: (handle cell)
+  keyboard-var: (handle cell)
   trace: (handle trace)
   cursor-in-trace?: boolean
 }
 
-fn initialize-sandbox _self: (addr sandbox), screen?: boolean {
+fn initialize-sandbox _self: (addr sandbox), screen-and-keyboard?: boolean {
   var self/esi: (addr sandbox) <- copy _self
   var data-ah/eax: (addr handle gap-buffer) <- get self, data
   allocate data-ah
@@ -17,10 +18,12 @@ fn initialize-sandbox _self: (addr sandbox), screen?: boolean {
   populate-stream value-ah, 0x1000/4KB
   #
   {
-    compare screen?, 0/false
+    compare screen-and-keyboard?, 0/false
     break-if-=
     var screen-ah/eax: (addr handle cell) <- get self, screen-var
     new-screen screen-ah, 5/width, 4/height
+    var keyboard-ah/eax: (addr handle cell) <- get self, keyboard-var
+    allocate-keyboard keyboard-ah, 5/capacity
   }
   #
   var trace-ah/eax: (addr handle trace) <- get self, trace