fix: dialog draw-border arg, markdown/slot nil guards, +integration test suite
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
(dotimes (row h)
|
||||
(draw-rect screen 0 row w 1 :bg :bright-black))
|
||||
;; Dialog panel
|
||||
(draw-border screen x y dw dh :single :title (dialog-title dialog))
|
||||
(draw-border screen x y dw dh :style :single :title (dialog-title dialog))
|
||||
(when (dialog-content dialog)
|
||||
;; Content rendering delegated to component system
|
||||
(draw-text screen (1+ x) (1+ y)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
;; ─── Block-level parser ───────────────────────────────────────────────────────
|
||||
|
||||
(defun split-string-into-lines (string)
|
||||
(unless string (return-from split-string-into-lines (coerce nil 'vector)))
|
||||
(let ((result nil) (start 0))
|
||||
(flet ((add-line (end) (push (subseq string start end) result)))
|
||||
(loop for i from 0 below (length string)
|
||||
@@ -212,6 +213,7 @@
|
||||
i))))
|
||||
|
||||
(defun parse-blocks (text)
|
||||
(unless text (return-from parse-blocks nil))
|
||||
(let ((lines (split-string-into-lines text)) (nodes nil) (i 0))
|
||||
(loop while (< i (length lines))
|
||||
do (let* ((line (string-trim (list #\return) (aref lines i)))
|
||||
@@ -502,6 +504,7 @@
|
||||
(nreverse tokens)))
|
||||
|
||||
(defun highlight-code (code language)
|
||||
(unless code (return-from highlight-code nil))
|
||||
(let ((highlighter (get-highlighter (and language (string-downcase language)))))
|
||||
(unless highlighter (return-from highlight-code (list (cons code :plain))))
|
||||
(let ((tokens nil))
|
||||
@@ -672,6 +675,7 @@
|
||||
lines))
|
||||
|
||||
(defun render-markdown (text)
|
||||
(unless text (return-from render-markdown ""))
|
||||
(let ((nodes (parse-blocks text)) (parts nil))
|
||||
(dolist (line (render-md nodes)) (push line parts))
|
||||
(with-output-to-string (s)
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
(defun slot-render (slot-name &rest args)
|
||||
(let ((entries (gethash (string slot-name) *slots*)))
|
||||
(when entries
|
||||
(mapcar (lambda (entry) (apply (cdr entry) args)) entries))))
|
||||
(mapcar (lambda (entry)
|
||||
(let ((fn (cdr entry)))
|
||||
(when fn (apply fn args))))
|
||||
entries))))
|
||||
|
||||
(defun slot-p (slot-name)
|
||||
(nth-value 1 (gethash (string slot-name) *slots*)))
|
||||
|
||||
Reference in New Issue
Block a user