8e35ed93d731

Expose `clear-layer`, add format args to `set`, fuck with CFFI, clean up box drawing
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 04 Jul 2017 13:24:51 +0000
parents a2fb5d06bfb6
children 5fca83b35760
branches/tags (none)
files docs/03-reference.markdown package.lisp src/high-level/bearlibterminal.lisp src/high-level/boxes.lisp src/low-level/bearlibterminal.lisp src/low-level/bearlibterminal.swig

Changes

--- a/docs/03-reference.markdown	Thu Jun 22 18:37:44 2017 +0000
+++ b/docs/03-reference.markdown	Tue Jul 04 13:24:51 2017 +0000
@@ -14,6 +14,167 @@
 
 This package contains a high-level, lispy interface to bearlibterminal.  It has the nickname `blt` for easy prefixing.
 
+### `BACKGROUND-COLOR` (function)
+
+    (BACKGROUND-COLOR)
+
+### `CELL-BACKGROUND-COLOR` (function)
+
+    (CELL-BACKGROUND-COLOR X Y)
+
+### `CELL-CHAR` (function)
+
+    (CELL-CHAR X Y &OPTIONAL (INDEX 0))
+
+### `CELL-CODE` (function)
+
+    (CELL-CODE X Y &OPTIONAL (INDEX 0))
+
+### `CELL-COLOR` (function)
+
+    (CELL-COLOR X Y &OPTIONAL (INDEX 0))
+
+### `CHARACTER-INPUT` (function)
+
+    (CHARACTER-INPUT)
+
+### `CLEAR` (function)
+
+    (CLEAR)
+
+### `CLEAR-AREA` (function)
+
+    (CLEAR-AREA X Y WIDTH HEIGHT)
+
+### `CLOSE` (function)
+
+    (CLOSE)
+
+### `COLOR`
+
+`#<STANDARD-CLASS DOCPARSER:TYPE-NODE>`
+
+### `COLOR-NAME` (function)
+
+    (COLOR-NAME COLOR-NAME)
+
+### `COLOR-TO-HSVA` (function)
+
+    (COLOR-TO-HSVA COLOR &OPTIONAL FLOAT?)
+
+### `COLOR-TO-RGBA` (function)
+
+    (COLOR-TO-RGBA COLOR &OPTIONAL FLOAT?)
+
+### `COMPOSITION` (function)
+
+    (COMPOSITION)
+
+### `CROP` (function)
+
+    (CROP X Y WIDTH HEIGHT)
+
+### `DRAW-BOX` (function)
+
+    (DRAW-BOX LAYER X Y WIDTH HEIGHT CONTENTS &KEY (BORDER :LIGHT)
+              (BACKGROUND-COLOR (RGBA 0 0 0)) (BORDER-COLOR (RGBA 255 255 255)))
+
+Draw a box.
+
+  Two layers will be used to draw the box: `layer` and `(1+ layer)`, and they
+  will be cleared before drawing it.
+
+  The border of the box will be one cell wide/tall.  `border` specifies the type
+  of border to draw, and can be one of `:light`, `:heavy`, or `:double`, or
+  `nil` for a transparent border.
+
+  `background-color` and `border-color` specify the colors to use.  If `nil` is
+  given they will not be drawn.
+
+  The `width` and `height` measurements include the two border cells.  For
+  example: a `width` of `10` would have `8` cells of content space.
+
+  `contents` will be `print`ed inside the box with the appropriate bounds.
+
+  **EXPERIMENTAL**: This function is experimental and may change or be remove
+  entirely in the future.
+
+  
+
+### `HAS-INPUT-P` (function)
+
+    (HAS-INPUT-P)
+
+### `HEIGHT` (function)
+
+    (HEIGHT)
+
+### `HSVA` (function)
+
+    (HSVA H S V &OPTIONAL (A NIL))
+
+### `KEY-CASE` (macro)
+
+    (KEY-CASE DATA &REST CLAUSES)
+
+### `LAYER` (function)
+
+    (LAYER)
+
+### `MOUSE` (function)
+
+    (MOUSE)
+
+### `MOUSE-X` (function)
+
+    (MOUSE-X)
+
+### `MOUSE-Y` (function)
+
+    (MOUSE-Y)
+
+### `OPEN` (function)
+
+    (OPEN)
+
+### `PEEK` (function)
+
+    (PEEK)
+
+### `PRINT` (function)
+
+    (PRINT X Y STRING &KEY WIDTH HEIGHT (HALIGN :DEFAULT) (VALIGN :DEFAULT))
+
+### `READ` (function)
+
+    (READ)
+
+### `REFRESH` (function)
+
+    (REFRESH)
+
+### `RGBA` (function)
+
+    (RGBA R G B &OPTIONAL (A NIL))
+
+### `SET` (function)
+
+    (SET CONFIGURATION-STRING)
+
+### `SLEEP` (function)
+
+    (SLEEP SECONDS)
+
+### `WIDTH` (function)
+
+    (WIDTH)
+
+### `WITH-TERMINAL` (macro)
+
+    (WITH-TERMINAL
+      &BODY
+      BODY)
+
 ## Package `BEARLIBTERMINAL/LOW-LEVEL`
 
 This package contains the low-level, SWIG-generated wrapper functions for bearlibterminal.
--- a/package.lisp	Thu Jun 22 18:37:44 2017 +0000
+++ b/package.lisp	Tue Jul 04 13:24:51 2017 +0000
@@ -9,6 +9,7 @@
 (defpackage :bearlibterminal/high-level
   (:use :cl :bearlibterminal.quickutils)
   (:export
+    :bearlibterminal
 
     :background-color
     :cell-background-color
@@ -18,6 +19,7 @@
     :character-input
     :clear
     :clear-area
+    :clear-layer
     :close
     :color
     :color-name
--- a/src/high-level/bearlibterminal.lisp	Thu Jun 22 18:37:44 2017 +0000
+++ b/src/high-level/bearlibterminal.lisp	Tue Jul 04 13:24:51 2017 +0000
@@ -328,8 +328,9 @@
 (defun close ()
   (blt/ll:terminal-close))
 
-(defun set (configuration-string)
-  (check (blt/ll:terminal-set-8 configuration-string)))
+(defun set (configuration-string &rest format-arguments)
+  (check (blt/ll:terminal-set-8
+           (apply #'format nil configuration-string format-arguments))))
 
 
 (defun layer ()
--- a/src/high-level/boxes.lisp	Thu Jun 22 18:37:44 2017 +0000
+++ b/src/high-level/boxes.lisp	Tue Jul 04 13:24:51 2017 +0000
@@ -86,8 +86,8 @@
                  (border-color (blt:rgba 255 255 255)))
   "Draw a box.
 
-  Two layers will be used to draw the box: `layer` and `(1+ layer)`, and they
-  will be cleared before drawing it.
+  The box will be draw on `layer`, and the necessary area will be cleared before
+  doing so.
 
   The border of the box will be one cell wide/tall.  `border` specifies the type
   of border to draw, and can be one of `:light`, `:heavy`, or `:double`, or
@@ -99,19 +99,19 @@
   The `width` and `height` measurements include the two border cells.  For
   example: a `width` of `10` would have `8` cells of content space.
 
-  `contents` will be `print`ed inside the box with the appropriate bounds.
+  `contents` will be `print`ed inside the box with the appropriate bounds.  The
+  color, font, etc will all be whatever they are currently set to.
 
   **EXPERIMENTAL**: This function is experimental and may change or be remove
   entirely in the future.
 
   "
   (save-values (blt:composition blt:layer)
-    (clear-layer layer)
-    (clear-layer (1+ layer))
-
     (setf (blt:layer) layer
           (blt:composition) t)
 
+    (clear-area x y width height)
+
     (save-value blt:color
       (when background-color
         (draw-box-background x y width height background-color))
@@ -121,7 +121,5 @@
           (:heavy (draw-box-border-heavy x y width height border-color))
           (:double (draw-box-border-double x y width height border-color)))))
 
-    (setf (blt:layer) (1+ layer)
-          (blt:composition) nil)
     (draw-box-contents x y width height contents)))
 
--- a/src/low-level/bearlibterminal.lisp	Thu Jun 22 18:37:44 2017 +0000
+++ b/src/low-level/bearlibterminal.lisp	Tue Jul 04 13:24:51 2017 +0000
@@ -8,10 +8,11 @@
 
 (cffi:defctype color :uint)
 
-(cffi:define-foreign-library bearlibterminal
-  (:darwin "lib/libBearLibTerminal.dylib"))
+(cffi:define-foreign-library blt:bearlibterminal
+  (:darwin (:or "Contents/Frameworks/libBearLibTerminal.dylib"
+                "lib/libBearLibTerminal.dylib")))
 
-(cffi:use-foreign-library bearlibterminal)
+(cffi:use-foreign-library blt:bearlibterminal)
 
 
 
--- a/src/low-level/bearlibterminal.swig	Thu Jun 22 18:37:44 2017 +0000
+++ b/src/low-level/bearlibterminal.swig	Tue Jul 04 13:24:51 2017 +0000
@@ -5,10 +5,11 @@
 
 (cffi:defctype color :uint)
 
-(cffi:define-foreign-library bearlibterminal
-  (:darwin "lib/libBearLibTerminal.dylib"))
+(cffi:define-foreign-library blt:bearlibterminal
+  (:darwin (:or "Contents/Frameworks/libBearLibTerminal.dylib"
+                "lib/libBearLibTerminal.dylib")))
 
-(cffi:use-foreign-library bearlibterminal)
+(cffi:use-foreign-library blt:bearlibterminal)
 %}
 
 %feature("intern_function","1");