From 3ca6648593c9990e0aba7c28475410bc598ec612 Mon Sep 17 00:00:00 2001 From: "O'Keefe, Colin B" Date: Mon, 1 Apr 2024 11:11:18 -0700 Subject: [PATCH] re-exports from unicode-diagram into cl-quil.tools printing correction --- src/tools/package.lisp | 11 +++++++++-- src/tools/unicode-diagram.lisp | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/tools/package.lisp b/src/tools/package.lisp index 1f7c9866..e5157b59 100644 --- a/src/tools/package.lisp +++ b/src/tools/package.lisp @@ -11,7 +11,11 @@ (defpackage #:cl-quil.tools (:nicknames #:tools) (:use #:cl) - (:import-from #:cl-quil.tools.unicode-diagram #:print-program-diagram) + (:import-from #:cl-quil.tools.unicode-diagram + #:print-program-diagram + #:make-charmap + #:+ascii-charmap+ + #:+box-drawings-charmap+) #+(or sbcl ecl ccl) (:local-nicknames (:a :alexandria)) @@ -26,4 +30,7 @@ ;; unicode-digram.lisp (:export - #:print-program-diagram)) + #:print-program-diagram + #:make-charmap + #:+ascii-charmap+ + #:+box-drawings-charmap+)) diff --git a/src/tools/unicode-diagram.lisp b/src/tools/unicode-diagram.lisp index b13e47cb..eeb27aae 100644 --- a/src/tools/unicode-diagram.lisp +++ b/src/tools/unicode-diagram.lisp @@ -444,14 +444,16 @@ instances." (loop :with centers := (loop :for col :in columns :collect (column-middle col)) :for figure :across row + :for namewidth := (length (figure-name figure)) :when (figure-boxed? figure) :do (multiple-value-bind (left right) (box-bounds figure columns gap) (clear-line line :from left :below right) (setf (elt line left) (vertical) (elt line right) (vertical)) (replace line (figure-name figure) - :start1 (- (+ left (floor (- right left) 2)) - (floor (length (figure-name figure)) 2)))))) + :start1 (- (+ left (mod (1+ namewidth) 2) ; even namewidths need an offset + (floor (- right left) 2)) + (floor namewidth 2)))))) (defun write-row-content (columns row line) "The row content line is drawn."