v1.0.0: extract theme from cl-tty.box to own cl-tty.theme package

The theme system (theme class, define-preset, load-preset, theme-color)
was part of the bloated cl-tty.box package even though it had nothing
to do with boxes, spans, or component rendering. It only used cl-tty.backend
for the *theme-colors* hash table.

Changes:
- added defpackage :cl-tty.theme as the first block in theme.lisp
  (inline defpackage avoids ASDF dependency ordering issues with
   separate package files)
- removed theme exports from cl-tty.box defpackage
- theme tests now run in their own THEME-SUITE (16 tests) instead of
  part of BOX-SUITE
- box suite drops from 64 to 48 tests (16 moved to theme suite)
- updated ASDF, run-all-tests.lisp

All 15 test suites pass at 100%.
This commit is contained in:
2026-05-18 16:50:48 -04:00
parent ef613927e6
commit 4c3f5fe65a
4 changed files with 36 additions and 16 deletions

View File

@@ -83,6 +83,7 @@
(:cl-tty-scrollbox-test "SCROLLBOX-SUITE") (:cl-tty-scrollbox-test "SCROLLBOX-SUITE")
(:cl-tty-markdown-test) (:cl-tty-markdown-test)
(:cl-tty-dialog-test "DIALOG-SUITE") (:cl-tty-dialog-test "DIALOG-SUITE")
(:cl-tty-theme-test "THEME-SUITE")
(:cl-tty-slot-test "SLOT-SUITE") (:cl-tty-slot-test "SLOT-SUITE")
(:cl-tty-layout-test "LAYOUT-SUITE") (:cl-tty-layout-test "LAYOUT-SUITE")
(:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE") (:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE")

View File

@@ -173,9 +173,6 @@ theme object is passed in from the application level. This separation
means themes can be swapped without touching component instances. means themes can be swapped without touching component instances.
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/package.lisp #+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/package.lisp
;; Theme engine
#:theme #:make-theme #:theme-mode
#:theme-color #:load-preset #:define-preset
;; Container components (merged from cl-tty.container) ;; Container components (merged from cl-tty.container)
#:scroll-box #:make-scroll-box #:scroll-box #:make-scroll-box
#:scroll-box-scroll-y #:scroll-box-scroll-x #:scroll-box-scroll-y #:scroll-box-scroll-x

View File

@@ -43,6 +43,17 @@ and the backend's ~*theme-colors*~ for SGR resolution.
- ~:default~ — gold/accent on dark blue-gray - ~:default~ — gold/accent on dark blue-gray
- ~:nord~ — cool blue nord palette - ~:nord~ — cool blue nord palette
* Package definition
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme.lisp
(defpackage :cl-tty.theme
(:use :cl :cl-tty.backend)
(:export
#:theme #:make-theme #:theme-mode
#:theme-color #:load-preset #:define-preset))
(in-package :cl-tty.theme)
#+END_SRC
* Tests * Tests
** Test header ** Test header
@@ -50,8 +61,18 @@ and the backend's ~*theme-colors*~ for SGR resolution.
Package declaration and test suite registration. Package declaration and test suite registration.
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme-tests.lisp #+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme-tests.lisp
(in-package :cl-tty-box-test) (defpackage :cl-tty-theme-test
(in-suite box-suite) (:use :cl :cl-tty.theme :fiveam)
(:export #:run-tests))
(in-package :cl-tty-theme-test)
(def-suite theme-suite :description "Theme engine tests")
(in-suite theme-suite)
(defun run-tests ()
(let ((result (run 'theme-suite)))
(fiveam:explain! result)
(uiop:quit 0)))
#+END_SRC #+END_SRC
** Test: theme-create-default ** Test: theme-create-default
@@ -201,7 +222,7 @@ hash table). Using ~make-hash-table~ as the ~:initform~ ensures each
instance gets its own table instead of sharing one. instance gets its own table instead of sharing one.
#+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme.lisp #+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme.lisp
(in-package :cl-tty.box) (in-package :cl-tty.theme)
(defclass theme () (defclass theme ()
((mode :initform :dark :initarg :mode :accessor theme-mode) ((mode :initform :dark :initarg :mode :accessor theme-mode)

View File

@@ -27,6 +27,7 @@
(:cl-tty-scrollbox-test "SCROLLBOX-SUITE") (:cl-tty-scrollbox-test "SCROLLBOX-SUITE")
(:cl-tty-markdown-test :cl-tty-markdown-test) (:cl-tty-markdown-test :cl-tty-markdown-test)
(:cl-tty-dialog-test "DIALOG-SUITE") (:cl-tty-dialog-test "DIALOG-SUITE")
(:cl-tty-theme-test "THEME-SUITE")
(:cl-tty-slot-test "SLOT-SUITE") (:cl-tty-slot-test "SLOT-SUITE")
(:cl-tty-layout-test "LAYOUT-SUITE") (:cl-tty-layout-test "LAYOUT-SUITE")
(:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE") (:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE")