0b1557603235

Add block box drawing border

I'm still not happy with the box-drawing UI.  I'm not sure what to do in the
case where there's no border.  Should the background expand to the full width?
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 05 Jul 2017 22:55:00 +0000
parents 712aef6ff9cb
children 6a6d09e57b9b
branches/tags (none)
files src/high-level/boxes.lisp

Changes

diff -r 712aef6ff9cb -r 0b1557603235 src/high-level/boxes.lisp
--- a/src/high-level/boxes.lisp	Tue Jul 04 17:49:09 2017 +0000
+++ b/src/high-level/boxes.lisp	Wed Jul 05 22:55:00 2017 +0000
@@ -23,18 +23,19 @@
                   :do (setf (blt:cell-char bx by) #\full_block))))
 
 
-(defun draw-box-background (x y w h color)
+(defun draw-box-background (x y w h color outline?)
   (setf (blt:color) color)
   (draw-box-fill (1+ x) (1+ y) (- w 2) (- h 2))
-  (draw-box-outline x y w h
-                    #\lower_half_block
-                    #\upper_half_block
-                    #\right_half_block
-                    #\left_half_block
-                    #\quadrant_lower_right
-                    #\quadrant_lower_left
-                    #\quadrant_upper_right
-                    #\quadrant_upper_left))
+  (when outline?
+    (draw-box-outline x y w h
+                      #\lower_half_block
+                      #\upper_half_block
+                      #\right_half_block
+                      #\left_half_block
+                      #\quadrant_lower_right
+                      #\quadrant_lower_left
+                      #\quadrant_upper_right
+                      #\quadrant_upper_left)))
 
 
 (defun draw-box-border-light (x y w h color)
@@ -73,6 +74,18 @@
                     #\box_drawings_double_up_and_right
                     #\box_drawings_double_up_and_left))
 
+(defun draw-box-border-block (x y w h color)
+  (setf (blt:color) color)
+  (draw-box-outline x y w h
+                    #\full_block
+                    #\full_block
+                    #\full_block
+                    #\full_block
+                    #\full_block
+                    #\full_block
+                    #\full_block
+                    #\full_block))
+
 
 (defun draw-box-contents (x y w h contents)
   (blt:print (1+ x) (1+ y) contents
@@ -114,12 +127,14 @@
 
     (save-value blt:color
       (when background-color
-        (draw-box-background x y width height background-color))
+        (draw-box-background x y width height background-color
+                             (and border border-color)))
       (when (and border border-color)
         (funcall (ecase border
                    (:light #'draw-box-border-light)
                    (:heavy #'draw-box-border-heavy)
-                   (:double #'draw-box-border-double))
+                   (:double #'draw-box-border-double)
+                   (:block #'draw-box-border-block))
                  x y width height border-color)))
 
     (draw-box-contents x y width height contents)))