about summary refs log tree commit diff stats
path: root/shell/sandbox.mu
diff options
context:
space:
mode:
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu106
1 files changed, 54 insertions, 52 deletions
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 0bc856bf..9af1637f 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -80,6 +80,8 @@ fn write-sandbox out: (addr stream byte), _self: (addr sandbox) {
 
 fn render-sandbox screen: (addr screen), _self: (addr sandbox), xmin: int, ymin: int, xmax: int, ymax: int {
   clear-rect screen, xmin, ymin, xmax, ymax, 0/bg=black
+  add-to xmin, 1/padding-left
+  subtract-from xmax, 1/padding-right
   var self/esi: (addr sandbox) <- copy _self
   # data
   var data-ah/eax: (addr handle gap-buffer) <- get self, data
@@ -90,7 +92,7 @@ fn render-sandbox screen: (addr screen), _self: (addr sandbox), xmin: int, ymin:
   y <- maybe-render-empty-screen screen, self, xmin, y
   y <- maybe-render-keyboard screen, self, xmin, y
   var cursor-in-sandbox?/ebx: (addr boolean) <- get self, cursor-in-data?
-  x, y <- render-gap-buffer-wrapping-right-then-down screen, data, x, y, xmax, ymax, *cursor-in-sandbox?
+  x, y <- render-gap-buffer-wrapping-right-then-down screen, data, x, y, xmax, ymax, *cursor-in-sandbox?, 3/fg, 0/bg
   y <- increment
   # trace
   var trace-ah/eax: (addr handle trace) <- get self, trace
@@ -149,7 +151,7 @@ fn clear-sandbox-output screen: (addr screen), _self: (addr sandbox), xmin: int,
   y <- maybe-render-empty-screen screen, self, xmin, y
   y <- maybe-render-keyboard screen, self, xmin, y
   var cursor-in-sandbox?/ebx: (addr boolean) <- get self, cursor-in-data?
-  x, y <- render-gap-buffer-wrapping-right-then-down screen, data, x, y, xmax, ymax, *cursor-in-sandbox?
+  x, y <- render-gap-buffer-wrapping-right-then-down screen, data, x, y, xmax, ymax, *cursor-in-sandbox?, 3/fg, 0/bg
   y <- increment
   clear-rect screen, xmin, y, xmax, ymax, 0/bg=black
 }
@@ -462,7 +464,7 @@ fn render-keyboard screen: (addr screen), _keyboard: (addr gap-buffer), xmin: in
   var x/eax: int <- copy xmin
   draw-code-point screen, 0x7c/vertical-bar, x, y, 0x18/fg, 0/bg
   x <- increment
-  x <- render-gap-buffer screen, keyboard, x, y, render-cursor?
+  x <- render-gap-buffer screen, keyboard, x, y, render-cursor?, 3/fg, 0/bg
   x <- copy xmin
   x <- add 1  # for left bar
   x <- add 0x10/keyboard-capacity
@@ -759,9 +761,9 @@ fn test-run-integer {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "1    ", "F - test-run-integer/0"
-  check-screen-row screen, 1/y, "...  ", "F - test-run-integer/1"
-  check-screen-row screen, 2/y, "=> 1 ", "F - test-run-integer/2"
+  check-screen-row screen, 0/y, " 1    ", "F - test-run-integer/0"
+  check-screen-row screen, 1/y, " ...  ", "F - test-run-integer/1"
+  check-screen-row screen, 2/y, " => 1 ", "F - test-run-integer/2"
 }
 
 fn test-run-error-invalid-integer {
@@ -776,9 +778,9 @@ fn test-run-error-invalid-integer {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "1a             ", "F - test-run-error-invalid-integer/0"
-  check-screen-row screen, 1/y, "...            ", "F - test-run-error-invalid-integer/0"
-  check-screen-row screen, 2/y, "invalid number ", "F - test-run-error-invalid-integer/2"
+  check-screen-row screen, 0/y, " 1a             ", "F - test-run-error-invalid-integer/0"
+  check-screen-row screen, 1/y, " ...            ", "F - test-run-error-invalid-integer/0"
+  check-screen-row screen, 2/y, " invalid number ", "F - test-run-error-invalid-integer/2"
 }
 
 fn test-run-with-spaces {
@@ -793,10 +795,10 @@ fn test-run-with-spaces {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, " 1   ", "F - test-run-with-spaces/0"
-  check-screen-row screen, 1/y, "     ", "F - test-run-with-spaces/1"
-  check-screen-row screen, 2/y, "...  ", "F - test-run-with-spaces/2"
-  check-screen-row screen, 3/y, "=> 1 ", "F - test-run-with-spaces/3"
+  check-screen-row screen, 0/y, "  1   ", "F - test-run-with-spaces/0"
+  check-screen-row screen, 1/y, "      ", "F - test-run-with-spaces/1"
+  check-screen-row screen, 2/y, " ...  ", "F - test-run-with-spaces/2"
+  check-screen-row screen, 3/y, " => 1 ", "F - test-run-with-spaces/3"
 }
 
 fn test-run-quote {
@@ -811,9 +813,9 @@ fn test-run-quote {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'a   ", "F - test-run-quote/0"
-  check-screen-row screen, 1/y, "...  ", "F - test-run-quote/1"
-  check-screen-row screen, 2/y, "=> a ", "F - test-run-quote/2"
+  check-screen-row screen, 0/y, " 'a   ", "F - test-run-quote/0"
+  check-screen-row screen, 1/y, " ...  ", "F - test-run-quote/1"
+  check-screen-row screen, 2/y, " => a ", "F - test-run-quote/2"
 }
 
 fn test-run-dotted-list {
@@ -828,9 +830,9 @@ fn test-run-dotted-list {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'(a . b)   ", "F - test-run-dotted-list/0"
-  check-screen-row screen, 1/y, "...        ", "F - test-run-dotted-list/1"
-  check-screen-row screen, 2/y, "=> (a . b) ", "F - test-run-dotted-list/2"
+  check-screen-row screen, 0/y, " '(a . b)   ", "F - test-run-dotted-list/0"
+  check-screen-row screen, 1/y, " ...        ", "F - test-run-dotted-list/1"
+  check-screen-row screen, 2/y, " => (a . b) ", "F - test-run-dotted-list/2"
 }
 
 fn test-run-dot-and-list {
@@ -845,9 +847,9 @@ fn test-run-dot-and-list {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'(a . (b)) ", "F - test-run-dot-and-list/0"
-  check-screen-row screen, 1/y, "...        ", "F - test-run-dot-and-list/1"
-  check-screen-row screen, 2/y, "=> (a b)   ", "F - test-run-dot-and-list/2"
+  check-screen-row screen, 0/y, " '(a . (b)) ", "F - test-run-dot-and-list/0"
+  check-screen-row screen, 1/y, " ...        ", "F - test-run-dot-and-list/1"
+  check-screen-row screen, 2/y, " => (a b)   ", "F - test-run-dot-and-list/2"
 }
 
 fn test-run-final-dot {
@@ -862,9 +864,9 @@ fn test-run-final-dot {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'(a .)               ", "F - test-run-final-dot/0"
-  check-screen-row screen, 1/y, "...                  ", "F - test-run-final-dot/1"
-  check-screen-row screen, 2/y, "'. )' makes no sense ", "F - test-run-final-dot/2"
+  check-screen-row screen, 0/y, " '(a .)               ", "F - test-run-final-dot/0"
+  check-screen-row screen, 1/y, " ...                  ", "F - test-run-final-dot/1"
+  check-screen-row screen, 2/y, " '. )' makes no sense ", "F - test-run-final-dot/2"
   # further errors may occur
 }
 
@@ -880,9 +882,9 @@ fn test-run-double-dot {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'(a . .)             ", "F - test-run-double-dot/0"
-  check-screen-row screen, 1/y, "...                  ", "F - test-run-double-dot/1"
-  check-screen-row screen, 2/y, "'. .' makes no sense ", "F - test-run-double-dot/2"
+  check-screen-row screen, 0/y, " '(a . .)             ", "F - test-run-double-dot/0"
+  check-screen-row screen, 1/y, " ...                  ", "F - test-run-double-dot/1"
+  check-screen-row screen, 2/y, " '. .' makes no sense ", "F - test-run-double-dot/2"
   # further errors may occur
 }
 
@@ -898,9 +900,9 @@ fn test-run-multiple-expressions-after-dot {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "'(a . b c)                                           ", "F - test-run-multiple-expressions-after-dot/0"
-  check-screen-row screen, 1/y, "...                                                  ", "F - test-run-multiple-expressions-after-dot/1"
-  check-screen-row screen, 2/y, "cannot have multiple expressions between '.' and ')' ", "F - test-run-multiple-expressions-after-dot/2"
+  check-screen-row screen, 0/y, " '(a . b c)                                           ", "F - test-run-multiple-expressions-after-dot/0"
+  check-screen-row screen, 1/y, " ...                                                  ", "F - test-run-multiple-expressions-after-dot/1"
+  check-screen-row screen, 2/y, " cannot have multiple expressions between '.' and ')' ", "F - test-run-multiple-expressions-after-dot/2"
   # further errors may occur
 }
 
@@ -916,9 +918,9 @@ fn test-run-stream {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen, 0/y, "[a b]    ", "F - test-run-stream/0"
-  check-screen-row screen, 1/y, "...      ", "F - test-run-stream/1"
-  check-screen-row screen, 2/y, "=> [a b] ", "F - test-run-stream/2"
+  check-screen-row screen, 0/y, " [a b]    ", "F - test-run-stream/0"
+  check-screen-row screen, 1/y, " ...      ", "F - test-run-stream/1"
+  check-screen-row screen, 2/y, " => [a b] ", "F - test-run-stream/2"
 }
 
 fn test-run-move-cursor-into-trace {
@@ -933,32 +935,32 @@ fn test-run-move-cursor-into-trace {
   initialize-screen screen, 0x80/width, 0x10/height, 0/no-pixel-graphics
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen,                                  0/y, "12    ", "F - test-run-move-cursor-into-trace/pre-0"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "  |   ", "F - test-run-move-cursor-into-trace/pre-0/cursor"
-  check-screen-row screen,                                  1/y, "...   ", "F - test-run-move-cursor-into-trace/pre-1"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "      ", "F - test-run-move-cursor-into-trace/pre-1/cursor"
-  check-screen-row screen,                                  2/y, "=> 12 ", "F - test-run-move-cursor-into-trace/pre-2"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-run-move-cursor-into-trace/pre-2/cursor"
+  check-screen-row screen,                                  0/y, " 12    ", "F - test-run-move-cursor-into-trace/pre-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "   |   ", "F - test-run-move-cursor-into-trace/pre-0/cursor"
+  check-screen-row screen,                                  1/y, " ...   ", "F - test-run-move-cursor-into-trace/pre-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "       ", "F - test-run-move-cursor-into-trace/pre-1/cursor"
+  check-screen-row screen,                                  2/y, " => 12 ", "F - test-run-move-cursor-into-trace/pre-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "       ", "F - test-run-move-cursor-into-trace/pre-2/cursor"
   # move cursor into trace
   edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen,                                  0/y, "12    ", "F - test-run-move-cursor-into-trace/trace-0"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "      ", "F - test-run-move-cursor-into-trace/trace-0/cursor"
-  check-screen-row screen,                                  1/y, "...   ", "F - test-run-move-cursor-into-trace/trace-1"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "|||   ", "F - test-run-move-cursor-into-trace/trace-1/cursor"
-  check-screen-row screen,                                  2/y, "=> 12 ", "F - test-run-move-cursor-into-trace/trace-2"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-run-move-cursor-into-trace/trace-2/cursor"
+  check-screen-row screen,                                  0/y, " 12    ", "F - test-run-move-cursor-into-trace/trace-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "       ", "F - test-run-move-cursor-into-trace/trace-0/cursor"
+  check-screen-row screen,                                  1/y, " ...   ", "F - test-run-move-cursor-into-trace/trace-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, " |||   ", "F - test-run-move-cursor-into-trace/trace-1/cursor"
+  check-screen-row screen,                                  2/y, " => 12 ", "F - test-run-move-cursor-into-trace/trace-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "       ", "F - test-run-move-cursor-into-trace/trace-2/cursor"
   # move cursor into input
   edit-sandbox sandbox, 0xd/ctrl-m, 0/no-globals, 0/no-disk, 0/no-screen, 0/no-tweak-screen
   #
   render-sandbox screen, sandbox, 0/x, 0/y, 0x80/width, 0x10/height
-  check-screen-row screen,                                  0/y, "12    ", "F - test-run-move-cursor-into-trace/input-0"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "  |   ", "F - test-run-move-cursor-into-trace/input-0/cursor"
-  check-screen-row screen,                                  1/y, "...   ", "F - test-run-move-cursor-into-trace/input-1"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "      ", "F - test-run-move-cursor-into-trace/input-1/cursor"
-  check-screen-row screen,                                  2/y, "=> 12 ", "F - test-run-move-cursor-into-trace/input-2"
-  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "      ", "F - test-run-move-cursor-into-trace/input-2/cursor"
+  check-screen-row screen,                                  0/y, " 12    ", "F - test-run-move-cursor-into-trace/input-0"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 0/y, "   |   ", "F - test-run-move-cursor-into-trace/input-0/cursor"
+  check-screen-row screen,                                  1/y, " ...   ", "F - test-run-move-cursor-into-trace/input-1"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 1/y, "       ", "F - test-run-move-cursor-into-trace/input-1/cursor"
+  check-screen-row screen,                                  2/y, " => 12 ", "F - test-run-move-cursor-into-trace/input-2"
+  check-background-color-in-screen-row screen, 7/bg=cursor, 2/y, "       ", "F - test-run-move-cursor-into-trace/input-2/cursor"
 }
 
 fn has-trace? _self: (addr sandbox) -> _/eax: boolean {