about summary refs log tree commit diff stats
path: root/shell/sandbox.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-05-01 15:56:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-05-01 16:12:49 -0700
commitd0e2d093f789fac54056a2f19f2339d230a69420 (patch)
tree9b0e090df4f4bd4a6cc3120a7108552798413f17 /shell/sandbox.mu
parent719b6acf3d668f839e772e9e6ed6369d804a1e42 (diff)
downloadmu-d0e2d093f789fac54056a2f19f2339d230a69420.tar.gz
cleaner rendering of fake screens and keyboards
I don't understand why a second line in the keyboard is visible now where
it wasn't before. That whole aspect has unclear desires. What exactly do
I want to happen on newlines?
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu125
1 files changed, 9 insertions, 116 deletions
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 40490e13..4d5286b0 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -214,23 +214,6 @@ fn maybe-render-screen screen: (addr screen), _self: (addr sandbox), xmin: int,
 fn render-empty-screen screen: (addr screen), _target-screen: (addr screen), xmin: int, ymin: int -> _/ecx: int {
   var target-screen/esi: (addr screen) <- copy _target-screen
   var screen-y/edi: int <- copy ymin
-  # top border
-  {
-    set-cursor-position screen, xmin, screen-y
-    var width/edx: (addr int) <- get target-screen, width
-    var limit/edx: int <- copy *width
-    limit <- add 2/screen-border
-    var x/ebx: int <- copy 0
-    {
-      compare x, limit
-      break-if->=
-      draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    screen-y <- increment
-  }
   # screen
   var height/edx: (addr int) <- get target-screen, height
   var y/ecx: int <- copy 0
@@ -238,63 +221,26 @@ fn render-empty-screen screen: (addr screen), _target-screen: (addr screen), xmi
     compare y, *height
     break-if->=
     set-cursor-position screen, xmin, screen-y
-    draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
-    move-cursor-right screen
     var width/edx: (addr int) <- get target-screen, width
     var x/ebx: int <- copy 0
     {
       compare x, *width
       break-if->=
-      draw-code-point-at-cursor screen, 0x20/space, 0x18/fg, 0xc5/bg=blue-bg
+      draw-code-point-at-cursor screen, 0x20/space, 0x18/fg, 0/bg
       move-cursor-right screen
       x <- increment
       loop
     }
-    draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
     y <- increment
     screen-y <- increment
     loop
   }
-  # bottom border
-  {
-    set-cursor-position screen, xmin, screen-y
-    var width/edx: (addr int) <- get target-screen, width
-    var limit/edx: int <- copy *width
-    limit <- add 2/screen-border
-    var x/ebx: int <- copy 0
-    {
-      compare x, limit
-      break-if->=
-      draw-code-point-at-cursor screen, 0x20/space, 0x20/space, 0xdc/bg=green-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    screen-y <- increment
-  }
   return screen-y
 }
 
 fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int, ymin: int -> _/ecx: int {
   var target-screen/esi: (addr screen) <- copy _target-screen
   var screen-y/edi: int <- copy ymin
-  # top border
-  {
-    set-cursor-position screen, xmin, screen-y
-    var width/edx: (addr int) <- get target-screen, width
-    var limit/edx: int <- copy *width
-    limit <- add 2/screen-border
-    var x/ebx: int <- copy 0
-    {
-      compare x, limit
-      break-if->=
-      draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    screen-y <- increment
-  }
   # text data
   {
     var height/edx: (addr int) <- get target-screen, height
@@ -303,8 +249,6 @@ fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int
       compare y, *height
       break-if->=
       set-cursor-position screen, xmin, screen-y
-      draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
-      move-cursor-right screen
       var width/edx: (addr int) <- get target-screen, width
       var x/ebx: int <- copy 0
       {
@@ -315,7 +259,6 @@ fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int
         x <- increment
         loop
       }
-      draw-code-point-at-cursor screen, 0x20/space, 0/fg, 0xdc/bg=green-bg
       y <- increment
       screen-y <- increment
       loop
@@ -325,12 +268,10 @@ fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int
   {
     # screen top left pixels x y width height
     var tmp/eax: int <- copy xmin
-    tmp <- add 1/margin-left
     tmp <- shift-left 3/log2-font-width
     var left: int
     copy-to left, tmp
     tmp <- copy ymin
-    tmp <- add 1/margin-top
     tmp <- shift-left 4/log2-font-height
     var top: int
     copy-to top, tmp
@@ -373,23 +314,6 @@ fn render-screen screen: (addr screen), _target-screen: (addr screen), xmin: int
       loop
     }
   }
-  # bottom border
-  {
-    set-cursor-position screen, xmin, screen-y
-    var width/edx: (addr int) <- get target-screen, width
-    var limit/edx: int <- copy *width
-    limit <- add 2/screen-border
-    var x/ebx: int <- copy 0
-    {
-      compare x, limit
-      break-if->=
-      draw-code-point-at-cursor screen, 0x20/space, 0x20/space, 0xdc/bg=green-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    screen-y <- increment
-  }
   return screen-y
 }
 
@@ -437,59 +361,28 @@ fn maybe-render-keyboard screen: (addr screen), _self: (addr sandbox), xmin: int
   var keyboard-obj-ah/eax: (addr handle gap-buffer) <- get keyboard-obj-cell, keyboard-data
   var _keyboard-obj/eax: (addr gap-buffer) <- lookup *keyboard-obj-ah
   var keyboard-obj/edx: (addr gap-buffer) <- copy _keyboard-obj
-  var x/eax: int <- draw-text-rightward screen, "keyboard: ", xmin, 0x99/xmax, ymin, 7/fg, 0xc5/bg=blue-bg
   var y/ecx: int <- copy ymin
+  y <- increment  # padding
+  var x/eax: int <- draw-text-rightward screen, "keyboard: ", xmin, 0x99/xmax, y, 7/fg, 0xc5/bg=blue-bg
   var cursor-in-keyboard?/esi: (addr boolean) <- get self, cursor-in-keyboard?
   y <- render-keyboard screen, keyboard-obj, x, y, *cursor-in-keyboard?
   y <- increment  # padding
   return y
 }
 
-# draw an evocative shape
 fn render-keyboard screen: (addr screen), _keyboard: (addr gap-buffer), xmin: int, ymin: int, render-cursor?: boolean -> _/ecx: int {
   var keyboard/esi: (addr gap-buffer) <- copy _keyboard
   var width/edx: int <- copy 0x10/keyboard-capacity
   var y/edi: int <- copy ymin
-  # top border
-  {
-    set-cursor-position screen, xmin, y
-    move-cursor-right screen
-    var x/ebx: int <- copy 0
-    {
-      compare x, width
-      break-if->=
-      draw-code-point-at-cursor screen, 0x2d/horizontal-bar, 0x18/fg, 0xc5/bg=blue-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    y <- increment
-  }
   # keyboard
   var x/eax: int <- copy xmin
-  draw-code-point screen, 0x7c/vertical-bar, x, y, 0x18/fg, 0xc5/bg=blue-bg
-  x <- increment
-  x <- render-gap-buffer screen, keyboard, x, y, render-cursor?, 3/fg, 0xc5/bg=blue-bg
-  x <- copy xmin
-  x <- add 1  # for left bar
-  x <- add 0x10/keyboard-capacity
-  draw-code-point screen, 0x7c/vertical-bar, x, y, 0x18/fg, 0xc5/bg=blue-bg
+  var xmax/ecx: int <- copy x
+  xmax <- add 0x10
+  var ymax/edx: int <- copy ymin
+  ymax <- add 1
+  clear-rect screen, x, y, xmax, ymax, 0/bg
+  x <- render-gap-buffer screen, keyboard, x, y, render-cursor?, 3/fg, 0/bg
   y <- increment
-  # bottom border
-  {
-    set-cursor-position screen, xmin, y
-    move-cursor-right screen
-    var x/ebx: int <- copy 0
-    {
-      compare x, width
-      break-if->=
-      draw-code-point-at-cursor screen, 0x2d/horizontal-bar, 0x18/fg, 0xc5/bg=blue-bg
-      move-cursor-right screen
-      x <- increment
-      loop
-    }
-    y <- increment
-  }
   return y
 }