1
2
3 dmn
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 ( use-modules ( srfi srfi-1 ) )
36 ( use-modules ( lepton color-map ) )
37 ( use-modules ( lepton object ) )
38 ( use-modules ( lepton page ) )
39 ( use-modules ( schematic window ) )
40 ( use-modules ( schematic undo ) )
41
42
43
44
45
46 ( define ( mk-color-boxes cmap pt )
47 ( let
48 (
49 ( color_nam )
50 ( color_ndx )
51 ( color_hex )
52 ( x ( car pt ) )
53 ( y ( cdr pt ) )
54 ( box1 #f )
55 ( box2 #f )
56 ( txt1 #f )
57 ( txt2 #f )
58 ( color_ndx_attr ( color-map-name-to-index 'attribute ) )
59 )
60
61 ( for-each
62 ( lambda( entry )
63 ( set! color_nam ( first entry ) )
64 ( set! color_hex ( second entry ) ) NOTE
65 ( set! color_ndx ( color-map-name-to-index color_nam ) )
66
67 ( set! box1 ( make-box (cons x y) (cons (+ x ) (- y )) color_ndx ) )
68 ( set-object-fill! box1 'solid )
69
70 ( set! box2 ( make-box (cons x y) (cons (+ x ) (- y )) color_ndx_attr ) )
71
72 ( set! txt1
73 ( make-text
74 ( cons (+ x ) ( - y ) )
75 'middle-left
76
77 ( format #f "~a=~d: ~a = ~a" color_nam color_ndx color_nam color_hex )
78
79 #t
80 'value
81 color_ndx_attr
82 )
83 )
84
85 ( set! txt2
86 ( make-text
87 ( cons (+ x ) (- y ) )
88 'middle-left
89
90 ( format #f "~a=~d: ~a = ~a" color_nam color_ndx color_nam color_hex )
91
92 #t
93 'value
94 color_ndx
95 )
96 )
97
98 ( page-append! (active-page) box1 )
99 ( page-append! (active-page) box2 )
100 ( page-append! (active-page) txt1 )
101 ( page-append! (active-page) txt2 )
102
103 ( set! y ( - y ) )
104
105 )
106
107 cmap
108
109 )
110
111 )
112 )
113
114
115
116
117
118
119 ( define ( cstst-mk )
120 ( when ( pointer-position )
121 ( undo-save-state )
122 ( mk-color-boxes
123 ( display-color-map )
124 ( snap-point (pointer-position) )
125 )
126 )
127 )
128
129
130
131
132
133
134 ( define ( cstst-up )
135 ( let*
136 (
137 ( page ( active-page ) )
138 ( cont ( page-contents page ) )
139 ( attrs ( filter attribute? cont ) )
140 ( cmap ( display-color-map ) )
141 ( sym #f )
142 ( txt #f )
143 )
144
145 ( define ( color-valid? sym )
146 ( assoc-ref cmap sym )
147 )
148
149 ( define ( color-val sym )
150 ( list-ref (assoc-ref cmap sym) )
151 )
152
153 ( define ( color-sym cname )
154 ( eval-string (format #f "'~a" cname) )
155 )
156
157 ( define ( color-ndx sym )
158 ( color-map-name-to-index sym )
159 )
160
161 ( define ( mk-str name ndx val )
162 ( format #f "~a=~d: ~a = ~a" name ndx name val )
163 )
164
165
166 ( undo-save-state )
167
168 ( for-each
169 ( lambda ( attr )
170 ( set! sym ( color-sym (attrib-name attr) ) )
171 ( when ( and (color-valid? sym) (not (attrib-attachment attr)) )
172
173 ( set! txt ( mk-str sym (color-ndx sym) (color-val sym) ) )
174 ( set-text-string! attr txt )
175 )
176 )
177 attrs
178 )
179
180 )
181 )
182