aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-05-11 21:02:48 +0200
committerThomas White <taw@physics.org>2023-05-11 21:02:48 +0200
commitd2138c27ffc90080fe7e0b16a9e7f3109200ee23 (patch)
treee6bfd0ef269da20da7d4150c3515fe001222e2d8
parentefb87ddf5c3c45a7b9ef79b9983f6c530af8680b (diff)
Programmer state should be LTP
-rw-r--r--guile/starlet/engine.scm40
-rw-r--r--guile/starlet/state.scm7
2 files changed, 28 insertions, 19 deletions
diff --git a/guile/starlet/engine.scm b/guile/starlet/engine.scm
index 6c43cf1..ca6f1cf 100644
--- a/guile/starlet/engine.scm
+++ b/guile/starlet/engine.scm
@@ -181,25 +181,27 @@
;; Combine all the active attributes and send it out
(atomic-box-swap! current-values
- (let ((states (atomic-box-ref state-list)))
- (for-each update-state! states)
- (fold
- (lambda (incoming-state combined-state)
- (state-for-each
- (lambda (fix attr val)
- (let ((incoming-val (value->number val))
- (current-val (state-find fix attr combined-state)))
- (unless (eq? incoming-val 'no-value)
- (if (eq? current-val 'no-value)
- (set-in-state! combined-state fix attr incoming-val)
- (set-in-state! combined-state fix attr
- (if (htp-attr? attr)
- (max incoming-val current-val)
- incoming-val))))))
- incoming-state)
- combined-state)
- (make-empty-state)
- (append states (list programmer-state)))))
+ (combine-states
+ (let ((states (atomic-box-ref state-list)))
+ (for-each update-state! states)
+ (fold
+ (lambda (incoming-state combined-state)
+ (state-for-each
+ (lambda (fix attr val)
+ (let ((incoming-val (value->number val))
+ (current-val (state-find fix attr combined-state)))
+ (unless (eq? incoming-val 'no-value)
+ (if (eq? current-val 'no-value)
+ (set-in-state! combined-state fix attr incoming-val)
+ (set-in-state! combined-state fix attr
+ (if (htp-attr? attr)
+ (max incoming-val current-val)
+ incoming-val))))))
+ incoming-state)
+ combined-state)
+ (make-empty-state)
+ states))
+ programmer-state))
(usleep 10000)
diff --git a/guile/starlet/state.scm b/guile/starlet/state.scm
index dbc7e38..5844b3f 100644
--- a/guile/starlet/state.scm
+++ b/guile/starlet/state.scm
@@ -47,6 +47,7 @@
current-state
at
apply-state
+ combine-states
show-state
lighting-state
programmer-state
@@ -329,6 +330,12 @@ pre-existing contents."
(current-state)))))
+(define (combine-states a b)
+ (lighting-state
+ (apply-state a)
+ (apply-state b)))
+
+
(define (print-state a)
(pretty-print (state-source a)))