about summary refs log tree commit diff stats
path: root/baremetal/shell
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-02-21 12:20:31 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-02-21 12:32:57 -0800
commit995dc380c87304a1f66c6e883aea21e5c7f82bc3 (patch)
tree673d44870c98b85fc1803640250ff7ed8614d1ee /baremetal/shell
parente78f801e72b1dfb0c505ebadf4d48cbaa0fff683 (diff)
downloadmu-995dc380c87304a1f66c6e883aea21e5c7f82bc3.tar.gz
7767 - baremetal/shell: skeleton repl
Prints a fixed value for now, regardless of what is typed.
Diffstat (limited to 'baremetal/shell')
-rw-r--r--baremetal/shell/sandbox.mu19
1 files changed, 18 insertions, 1 deletions
diff --git a/baremetal/shell/sandbox.mu b/baremetal/shell/sandbox.mu
index 4ca1082c..8ee04f0a 100644
--- a/baremetal/shell/sandbox.mu
+++ b/baremetal/shell/sandbox.mu
@@ -1,5 +1,6 @@
 type sandbox {
   data: (handle gap-buffer)
+  value: (handle stream byte)
 }
 
 fn initialize-sandbox _self: (addr sandbox) {
@@ -8,6 +9,8 @@ fn initialize-sandbox _self: (addr sandbox) {
   allocate data-ah
   var data/eax: (addr gap-buffer) <- lookup *data-ah
   initialize-gap-buffer data, 0x1000/4KB
+  var value-ah/eax: (addr handle stream byte) <- get self, value
+  populate-stream value-ah, 0x1000/4KB
 }
 
 ## some helpers for tests
@@ -47,9 +50,14 @@ fn render-sandbox screen: (addr screen), _self: (addr sandbox), x: int, y: int {
   var data-ah/eax: (addr handle gap-buffer) <- get self, data
   var data/eax: (addr gap-buffer) <- lookup *data-ah
   var dummy/eax: int <- render-gap-buffer screen, data, x, y, 1/true
+  increment y
+  var value-ah/eax: (addr handle stream byte) <- get self, value
+  var value/eax: (addr stream byte) <- lookup *value-ah
+  var dummy/eax: int <- draw-stream-rightward screen, value, x, 0x30/xmax, y, 7/fg=grey, 0/bg
 }
 
-fn edit-sandbox self: (addr sandbox), key: byte {
+fn edit-sandbox _self: (addr sandbox), key: byte {
+  var self/esi: (addr sandbox) <- copy _self
   var g/edx: grapheme <- copy key
   {
     compare g, 8/backspace
@@ -57,5 +65,14 @@ fn edit-sandbox self: (addr sandbox), key: byte {
     delete-grapheme-before-cursor self
     return
   }
+  {
+    compare g, 0x13/ctrl-s
+    break-if-!=
+    # ctrl-s: run sandbox(es)
+    var value-ah/eax: (addr handle stream byte) <- get self, value
+    var value/eax: (addr stream byte) <- lookup *value-ah
+    write value, "=> LISP"
+    return
+  }
   add-grapheme-to-sandbox self, g
 }