review fixes: word-wrap hard-break, title-align, ASDF fix, edge cases
Fixes from subagent review: - Word-wrap now hard-breaks words exceeding max-width (was returning un-truncated overflow strings) - Box zero-size guard now catches any zero/single dimension (was only catching both zero together) - Title-align now respected (:left/:center/:right) with proper positioning - render-text declares (ignore spans) to suppress unused warning - ASDF test-op fixed: run! → run-tests (symbol didn't exist) - New test: box-single-column (width=1 renders nothing) - Tightened word-wrap test: verifies hard-break produces both chunks - Simplified word-wrap with cond instead of nested if/progn (avoided recurring paren-balance issue)
This commit is contained in:
@@ -36,15 +36,19 @@
|
||||
(y (layout-node-y ln))
|
||||
(w (layout-node-width ln))
|
||||
(h (layout-node-height ln)))
|
||||
(when (and (zerop w) (zerop h))
|
||||
(when (or (zerop w) (zerop h) (< w 2) (< h 2))
|
||||
(return-from render-box (values)))
|
||||
(when bg
|
||||
(draw-rect backend x y w h :bg bg))
|
||||
(when bs
|
||||
(draw-border backend x y w h
|
||||
:style bs :fg fg :bg bg))
|
||||
(draw-border backend x y w h :style bs :fg fg :bg bg))
|
||||
(when title
|
||||
;; Render title below top border, left-aligned inside the box
|
||||
(let ((tx (+ x 2))
|
||||
(ty (+ y 1)))
|
||||
(draw-text backend tx ty title fg bg))))))
|
||||
(let* ((content-w (- w 4))
|
||||
(tx (+ x 2))
|
||||
(ty (+ y (if bs 1 0)))
|
||||
(ta (box-title-align box))
|
||||
(display (subseq title 0 (min (length title) content-w))))
|
||||
(case ta
|
||||
(:center (draw-text backend (+ x (ceiling (- w (length display)) 2)) ty display fg bg))
|
||||
(:right (draw-text backend (+ x (- w (length display) 2)) ty display fg bg))
|
||||
(t (draw-text backend tx ty display fg bg))))))))
|
||||
|
||||
Reference in New Issue
Block a user