blocks ====== SNOBOL4 BLOCKS are 3D strings which facilitate 2D output layout with a 3rd dimension for overstrikes. This package is far from complete but does support Unicode/MS-DOS box-drawing characters. Class block-output-stream Method char-at stream x y => char Method clear-page stream Method line-to stream x y Method line-weight stream { 0 | 1 | 2} Method move-to stream x y Method show-page stream &key output fresh-line full Macro with-output-to-block (stream &key width height) declaration* form* Accessor x-position stream => position Accessor y-position stream => position Box-drawing joins lines as corners, tees and crosses when possible but only at the start character of a line, done by looking at the character under the cursor and by remembering consecutive line-to operations. Perhaps there should be a way to avoid this other than move-to the current position or drawing in the opposite direction. Line ends are conceptually at character centers but for lack of half-wide and half-high line segment characters, individual lines cannot be drawn this way so instead the start character gets a full segment and the final character gets none, just like ordinary text. Therefore it does not work to start a line on a future corner unless the direction is pre-set, which can always be done with a zero weight line to avoid spurious drawing. Example ------- (eval-when (:compile-toplevel :load-toplevel :execute) (require '#:blocks)) (with-output-to-block (b) ;; Leave the first corner initally blank to join all four corners. ;; Draw the last two lines out from the center to join the center cross. (princ "Box: " b) (line-weight b 2) (move-to b 6 0) (line-to b 15 0) (line-to b 15 8) (line-to b 5 8) (line-to b 5 0) (line-to b 6 0) (line-weight b 1) (move-to b 10 1) (line-to b 10 8) (move-to b 10 4) (line-to b 15 4) (move-to b 10 4) (line-to b 5 4) (move-to b 13 4) (princ 1 b) (move-to b 10 6) (princ 2 b) (move-to b 7 4) (princ 4 b) (move-to b 10 2) (princ 8 b)) Box: ╔═════════╗ ║ │ ║ ║ 8 ║ ║ │ ║ ║─4──┼──1─║ ║ │ ║ ║ 2 ║ ║ │ ║ ╚═════════╝ NIL (eval-when (:compile-toplevel :load-toplevel :execute) (require '#:blocks-demo)) (disassemble* #'-) ... COPYING ------- Copyright (c) 2016 Devon Sean McCullough This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.