From 4c3f5fe65a671381fc0d568d92de3a75e150bca3 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Mon, 18 May 2026 16:50:48 -0400 Subject: [PATCH] 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%. --- cl-tty.asd | 21 +++++++++++---------- org/package.org | 3 --- org/theme.org | 27 ++++++++++++++++++++++++--- run-all-tests.lisp | 1 + 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/cl-tty.asd b/cl-tty.asd index 9e6bc53..21429d8 100644 --- a/cl-tty.asd +++ b/cl-tty.asd @@ -16,18 +16,18 @@ (:module "src/layout" :components ((:file "layout"))) - (:module "src/rendering" - :components - ((:file "framebuffer"))) - (:module "src/components" + (:module "src/rendering" + :components + ((:file "framebuffer"))) + (:module "src/components" :components ((:file "package") (:file "dirty") (:file "box" :depends-on ("package")) - (:file "text" :depends-on ("package" "box")) - (:file "render" :depends-on ("package" "box" "text")) - (:file "theme" :depends-on ("package")) - ;; Input system (v0.5.0) + (:file "text" :depends-on ("package" "box")) + (:file "render" :depends-on ("package" "box" "text")) + (:file "theme" :depends-on ("package")) + ;; Input system (v0.5.0) (:file "input-package" :depends-on ("package")) (:file "input" :depends-on ("input-package" "dirty" "box")) (:file "text-input" :depends-on ("input-package" "input" "box")) @@ -82,8 +82,9 @@ (:cl-tty-input-test "INPUT-SUITE") (:cl-tty-scrollbox-test "SCROLLBOX-SUITE") (:cl-tty-markdown-test) - (:cl-tty-dialog-test "DIALOG-SUITE") - (:cl-tty-slot-test "SLOT-SUITE") + (:cl-tty-dialog-test "DIALOG-SUITE") + (:cl-tty-theme-test "THEME-SUITE") + (:cl-tty-slot-test "SLOT-SUITE") (:cl-tty-layout-test "LAYOUT-SUITE") (:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE") (:cl-tty-framebuffer-test "FRAMEBUFFER-SUITE"))) diff --git a/org/package.org b/org/package.org index 15b98a7..da1ce95 100644 --- a/org/package.org +++ b/org/package.org @@ -173,9 +173,6 @@ theme object is passed in from the application level. This separation means themes can be swapped without touching component instances. #+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) #:scroll-box #:make-scroll-box #:scroll-box-scroll-y #:scroll-box-scroll-x diff --git a/org/theme.org b/org/theme.org index bd2bf5a..f871f0b 100644 --- a/org/theme.org +++ b/org/theme.org @@ -43,6 +43,17 @@ and the backend's ~*theme-colors*~ for SGR resolution. - ~:default~ — gold/accent on dark blue-gray - ~: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 ** Test header @@ -50,8 +61,18 @@ and the backend's ~*theme-colors*~ for SGR resolution. Package declaration and test suite registration. #+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme-tests.lisp -(in-package :cl-tty-box-test) -(in-suite box-suite) +(defpackage :cl-tty-theme-test + (: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 ** 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. #+BEGIN_SRC lisp :tangle ~/.local/share/cl-tty/src/components/theme.lisp -(in-package :cl-tty.box) +(in-package :cl-tty.theme) (defclass theme () ((mode :initform :dark :initarg :mode :accessor theme-mode) diff --git a/run-all-tests.lisp b/run-all-tests.lisp index 21f2c16..16a206e 100644 --- a/run-all-tests.lisp +++ b/run-all-tests.lisp @@ -27,6 +27,7 @@ (:cl-tty-scrollbox-test "SCROLLBOX-SUITE") (:cl-tty-markdown-test :cl-tty-markdown-test) (:cl-tty-dialog-test "DIALOG-SUITE") + (:cl-tty-theme-test "THEME-SUITE") (:cl-tty-slot-test "SLOT-SUITE") (:cl-tty-layout-test "LAYOUT-SUITE") (:cl-tty-modern-backend-test "MODERN-BACKEND-SUITE")