fix: draw-text/draw-rect use style-only reset (\e[22-27m) instead of full reset (\e[0m)

Preserves foreground and background colors across draw calls.
Without this, every draw-text resets terminal to default grey
background, causing grey-background artifacts in the TUI.
This commit is contained in:
2026-05-16 08:03:00 -04:00
parent 1df078a235
commit 2785d6913f

View File

@@ -209,7 +209,8 @@ as a fallback when a keyword is not in *named-colors*.")
(defmethod draw-text ((b modern-backend) x y string fg bg
&key bold italic underline reverse dim blink
&allow-other-keys)
(let ((parts (list (cursor-move-escape x y)
(let* ((style-reset (format nil "~C[22;23;24;25;27m" #\Esc))
(parts (list (cursor-move-escape x y)
(sgr-fg fg) (sgr-bg bg)
(when bold (sgr-attr :bold))
(when italic (sgr-attr :italic))
@@ -218,7 +219,7 @@ as a fallback when a keyword is not in *named-colors*.")
(when dim (sgr-attr :dim))
(when blink (sgr-attr :blink))
string
(sgr-attr :reset))))
style-reset)))
(backend-write b (apply #'concatenate 'string parts))))
(defmethod draw-border ((b modern-backend) x y width height
@@ -232,7 +233,7 @@ as a fallback when a keyword is not in *named-colors*.")
(v (border-char s :vertical))
(fg-esc (sgr-fg fg))
(bg-esc (sgr-bg bg))
(reset (sgr-attr :reset))
(reset (format nil "~C[22;23;24;25;27m" #\Esc))
(inner-width (- width 2))
(hc (char h 0))
(top (if (and title (plusp (length title)))
@@ -276,21 +277,22 @@ as a fallback when a keyword is not in *named-colors*.")
(defmethod draw-rect ((b modern-backend) x y width height &key bg)
(let* ((bg-esc (sgr-bg bg))
(reset (sgr-attr :reset))
(style-reset (format nil "~C[22;23;24;25;27m" #\Esc))
(line (concatenate 'string
bg-esc
(make-string width :initial-element #\Space)
reset (string #\Newline))))
style-reset (string #\Newline))))
(loop :for row :from 0 :below height :do
(backend-write b (cursor-move-escape x (+ y row)))
(backend-write b line))))
(defmethod draw-link ((b modern-backend) x y string url
&key fg bg)
(let ((parts (list (cursor-move-escape x y)
(let* ((style-reset (format nil "~C[22;23;24;25;27m" #\Esc))
(parts (list (cursor-move-escape x y)
(sgr-fg fg) (sgr-bg bg)
(osc8-link url string)
(sgr-attr :reset))))
style-reset)))
(backend-write b (apply #'concatenate 'string parts))))
(defmethod draw-ellipsis ((b modern-backend) x y width