v0.2.0: Dirty tracking — dirty-mixin, mark-clean, mark-dirty
- dirty-mixin class with dirty slot (initform t) - mark-clean clears dirty flag - mark-dirty sets dirty flag - 3 tests: default-dirty, clean, dirty-cycle - ROADMAP.org: v0.2.0 all tasks DONE - 31 component tests, 100% GREEN
This commit is contained in:
20
src/components/dirty-tests.lisp
Normal file
20
src/components/dirty-tests.lisp
Normal file
@@ -0,0 +1,20 @@
|
||||
;; Dirty tracking tests are in box-tests.lisp (same test suite)
|
||||
(in-package :cl-tui-box-test)
|
||||
|
||||
(test dirty-mixin-default-is-dirty
|
||||
"A dirty-mixin starts as dirty"
|
||||
(let ((c (make-instance 'dirty-mixin)))
|
||||
(is-true (dirty-p c) "new component should be dirty")))
|
||||
|
||||
(test mark-clean-clears-dirty
|
||||
"mark-clean sets dirty to nil"
|
||||
(let ((c (make-instance 'dirty-mixin)))
|
||||
(mark-clean c)
|
||||
(is-false (dirty-p c) "after mark-clean, should not be dirty")))
|
||||
|
||||
(test mark-dirty-sets-dirty
|
||||
"mark-dirty sets dirty to t"
|
||||
(let ((c (make-instance 'dirty-mixin)))
|
||||
(mark-clean c)
|
||||
(mark-dirty c)
|
||||
(is-true (dirty-p c) "after mark-dirty, should be dirty again")))
|
||||
14
src/components/dirty.lisp
Normal file
14
src/components/dirty.lisp
Normal file
@@ -0,0 +1,14 @@
|
||||
(in-package :cl-tui.box)
|
||||
|
||||
;; ── Dirty Tracking ─────────────────────────────────────────────
|
||||
|
||||
(defclass dirty-mixin ()
|
||||
((dirty :initform t :accessor dirty-p)))
|
||||
|
||||
(defgeneric mark-clean (component)
|
||||
(:method ((c dirty-mixin))
|
||||
(setf (dirty-p c) nil)))
|
||||
|
||||
(defgeneric mark-dirty (component)
|
||||
(:method ((c dirty-mixin))
|
||||
(setf (dirty-p c) t)))
|
||||
@@ -17,5 +17,7 @@
|
||||
#:text-fg #:text-bg #:text-wrap-mode
|
||||
#:render-text
|
||||
;; Utilities (for tests)
|
||||
#:word-wrap #:split-string))
|
||||
#:word-wrap #:split-string
|
||||
;; Dirty tracking
|
||||
#:dirty-mixin #:dirty-p #:mark-clean #:mark-dirty))
|
||||
(in-package :cl-tui.box)
|
||||
|
||||
Reference in New Issue
Block a user