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-04-20 19:47:57 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-04-20 19:47:57 -0700
commitfb34909b4eb744811f6da2354667179c108870cb (patch)
tree8b5f4c662b9868965645968ef188c5e7ec3b3d10 /shell/sandbox.mu
parentfb3967876c8b97ebf8a7ad5570623a8a4c6dead6 (diff)
downloadmu-fb34909b4eb744811f6da2354667179c108870cb.tar.gz
get bresenham line drawing working with a trace
    (brline . (fn () (screen x0 y0 x1 y1 color)
                 ((fn (dx dy sx sy)
                    ((fn (err)
                       (brline1 screen x0 y0 x1 y1 dx dy sx sy err color))
                     (+ dx dy)))
                  (abs (- x1 x0))
                  (- 0 (abs (- y1 y0)))
                  (sgn (- x1 x0))
                  (sgn (- y1 y0)))))
    (brline1 . (fn () (screen x y xmax ymax dx dy sx sy err color)
                 (pixel screen x y color)
                 (if (andf (= x xmax) (= y ymax))
                   ()
                   ((fn (e2)
                      (brline1 screen
                        (if (>= e2 dy)
                          (+ x sx)
                          x)
                        (if (<= e2 dx)
                          (+ y sy)
                          y)
                        xmax
                        ymax
                        dx
                        dy
                        sx
                        sy
                        (+ err
                           (+
                             (if (>= e2 dy)
                               dy
                               0)
                             (if (<= e2 dx)
                               dx
                               0)))
                        color))
                    (* err 2)))))

sandbox: (brline screen 1 1 5 5 12)

There are two ideas stemming from this commit:
  - I need an extremely compact on-screen trace to underlie the trace UX
  - perhaps we should start truncating trace lines
Diffstat (limited to 'shell/sandbox.mu')
-rw-r--r--shell/sandbox.mu3
1 files changed, 3 insertions, 0 deletions
diff --git a/shell/sandbox.mu b/shell/sandbox.mu
index 7f3c13e2..793ab12a 100644
--- a/shell/sandbox.mu
+++ b/shell/sandbox.mu
@@ -558,6 +558,7 @@ fn edit-sandbox _self: (addr sandbox), key: byte, globals: (addr global-table),
     clear-screen-cell screen-cell
     var keyboard-cell/esi: (addr handle cell) <- get self, keyboard-var
     rewind-keyboard-cell keyboard-cell  # don't clear keys from before
+    set-cursor-position 0, 0, 0
     run data, value, globals, trace, screen-cell, keyboard-cell
     return
   }
@@ -680,7 +681,9 @@ fn run in: (addr gap-buffer), out: (addr stream byte), globals: (addr global-tab
   allocate-pair nil-ah
   var eval-result-storage: (handle cell)
   var eval-result/edi: (addr handle cell) <- address eval-result-storage
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "O", 4/fg, 0/bg
   evaluate read-result, eval-result, *nil-ah, globals, trace, screen-cell, keyboard-cell
+  draw-text-wrapping-right-then-down-from-cursor-over-full-screen 0/screen, "P", 4/fg, 0/bg
   var error?/eax: boolean <- has-errors? trace
   {
     compare error?, 0/false