File: FvwmScript-Colorset

package info (click to toggle)
fvwm 1%3A2.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,968 kB
  • sloc: ansic: 145,836; xml: 17,096; perl: 7,237; sh: 5,100; makefile: 1,101; yacc: 688; lex: 187; sed: 11
file content (324 lines) | stat: -rw-r--r-- 6,178 bytes parent folder | download | duplicates (14)
1
2
3
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# An FvwmScript GUI to change colorsets
# I can't believe how big this is
# I haven't got the energy to implement a Save button
# Just goes to show that command lines are better
# Don't switch on Dynamic update unless using ReadWriteColors
WindowTitle	{Colorset Editor}
WindowSize	380 290
Colorset 0

Init
 Begin
  # This is the colorset being worked on
  Set $Cset = 0
  Set $OldCset = 0
  Set $Color = (GetBack 1)
  Do {Colorset } $Cset { Pixmap, Background #} $Color {, Foreground Contrast}
  # Sliders are initially hidden
  HideWidget 1
  HideWidget 2
  HideWidget 3
  HideWidget 21
  HideWidget 22
  HideWidget 23
 End

# radio buttons to pick the colorset aspect to change
Widget 13
Property
 Position	120 10
 Type		RadioButton
 Title		{Background}
Main
 Case message of
 SingleClic :
 Begin
  Set $Color = (GetBack 1)
  ChangeValue 1 (HexToNum (StrCopy $Color 1 2))
  ChangeValue 2 (HexToNum (StrCopy $Color 3 4))
  ChangeValue 3 (HexToNum (StrCopy $Color 5 6))
  ChangeValue 10 0
  ChangeValue 11 0
  ChangeValue 12 0
  ShowWidget 1
  ShowWidget 2
  ShowWidget 3
  ShowWidget 21
  ShowWidget 22
  ShowWidget 23
 End
End

Widget 10
Property
 Position	220 10
 Type		RadioButton
 Title		{Foreground}
Main
 Case message of
 SingleClic :
 Begin
  Set $Color = (GetFore 1)
  ChangeValue 1 (HexToNum (StrCopy $Color 1 2))
  ChangeValue 2 (HexToNum (StrCopy $Color 3 4))
  ChangeValue 3 (HexToNum (StrCopy $Color 5 6))
  ChangeValue 11 0
  ChangeValue 12 0
  ChangeValue 13 0
  ShowWidget 1
  ShowWidget 2
  ShowWidget 3
  ShowWidget 21
  ShowWidget 22
  ShowWidget 23
 End
End

Widget 11
Property
 Position	120 30
 Type		RadioButton
 Title		{Hilite}
Main
 Case message of
 SingleClic :
 Begin
  Set $Color = (GetHilight 1)
  ChangeValue 1 (HexToNum (StrCopy $Color 1 2))
  ChangeValue 2 (HexToNum (StrCopy $Color 3 4))
  ChangeValue 3 (HexToNum (StrCopy $Color 5 6))
  ChangeValue 10 0
  ChangeValue 12 0
  ChangeValue 13 0
  ShowWidget 1
  ShowWidget 2
  ShowWidget 3
  ShowWidget 21
  ShowWidget 22
  ShowWidget 23
 End
End

Widget 12
Property
 Position	220 30
 Type		RadioButton
 Title		{Shadow}
Main
 Case message of
 SingleClic :
 Begin
  Set $Color = (GetShadow 1)
  ChangeValue 1 (HexToNum (StrCopy $Color 1 2))
  ChangeValue 2 (HexToNum (StrCopy $Color 3 4))
  ChangeValue 3 (HexToNum (StrCopy $Color 5 6))
  ChangeValue 10 0
  ChangeValue 11 0
  ChangeValue 13 0
  ShowWidget 1
  ShowWidget 2
  ShowWidget 3
  ShowWidget 21
  ShowWidget 22
  ShowWidget 23
 End
End

# colorset selector
# miniscrolls clic on button press and release hence the (div x 2)
# and they roll over which is bad for defining colorsets
Widget 4
Property
 Position       10 10
 Type           MiniScroll
 Value		0
 MinValue	0
 MaxValue	101
Main
 Case message of
 SingleClic :
 Begin
  # hold at max value
  If (GetValue 4) == 100 Then
   ChangeValue 4 99
  # hold at min value
  If (GetValue 4) > 100 Then
   ChangeValue 4 0
  Set $OldCset = $Cset
  Set $Cset = (Div (GetValue 4) 2)
  Set $CsetName = {Colorset } $Cset
  ChangeTitle 5 $CsetName
  # redisplay in new colorset
  ChangeColorset 0 $Cset
  ChangeColorset 1 $Cset
  ChangeColorset 2 $Cset
  ChangeColorset 3 $Cset
  ChangeColorset 4 $Cset
  ChangeColorset 5 $Cset
  ChangeColorset 6 $Cset
  ChangeColorset 7 $Cset
  ChangeColorset 10 $Cset
  ChangeColorset 11 $Cset
  ChangeColorset 12 $Cset
  ChangeColorset 13 $Cset
  ChangeColorset 21 $Cset
  ChangeColorset 22 $Cset
  ChangeColorset 23 $Cset
  ChangeColorset 0 $Cset
  # unselect all radio buttons
  ChangeValue 10 0
  ChangeValue 11 0
  ChangeValue 12 0
  ChangeValue 13 0
  # hide the sliders
  HideWidget 1
  HideWidget 2
  HideWidget 3
  HideWidget 21
  HideWidget 22
  HideWidget 23
  # change current colorset to be just plain
  If $OldCset == $Cset Then
   Begin
   End
  Else
   Begin
    # I think there might be a bug in Colorset that resets a colorset to a copy of 0
    # if {pixmap} is used to select a plain background
    Set $Color = (GetBack 1)
    Do {Colorset } $Cset { Pixmap, Background #} $Color {, Foreground Contrast}
    Set $OldCset = $Cset
   End
 End
End

# Example
Widget 5
Property
 Size           80 34
 Position       29 10
 Type           ItemDraw
 Title		{Colorset 0}
End

# auto apply selector
# handles signals from color selectors and passes them on to the apply
# button if enabled
Widget 6
Property
 Position       120 250
 Type           CheckBox
 Title		{Auto Apply}
Main
 Case message of
 1 :
 Begin
  If (GetValue 6) == 1 Then
   SendSignal 7 1
 End
End

# apply button (does the main processing)
# sends a signal to itself when clicked
# sets the colorset when it receives a signal
Widget 7
Property
 Position       10 250
 Type           PushButton
 Title		{Apply}
Main
 Case message of
 SingleClic :
 Begin
  SendSignal 7 1
 End
 1 :
 Begin
  # calculate the current color in RGB hex terms
  Set $Color = {rgb:} (NumToHex (GetValue 1) 2)
  Set $Color = $Color {/} (NumToHex (GetValue 2) 2)
  Set $Color = $Color {/} (NumToHex (GetValue 3) 2)
  # pick the current colorset
  Set $Command = {Colorset } $Cset
  # pick the type to set
  If (GetValue 10) == 1 Then
   Set $Command = $Command { Foreground } $Color
  If (GetValue 11) == 1 Then
   Set $Command = $Command { Hilite } $Color
  If (GetValue 12) == 1 Then
   Set $Command = $Command { Shadow } $Color
  If (GetValue 13) == 1 Then
   Set $Command = $Command { Background } $Color {, Foreground Contrast}
  Do $Command
 End
End

# RGB sliders
Widget 1
Property
 Size		320 0
 Position	50 60
 Type		HScrollBar
 MinValue	0
 MaxValue	255
Main
 Case message of
 SingleClic :
 Begin
  SendSignal 6 1
 End
End

Widget 21
Property
 Size		10 0
 Position	10 80
 Type		ItemDraw
 Title		{Red}
End

Widget 2
Property
 Size		320 0
 Position	50 120
 Type		HScrollBar
 MinValue	0
 MaxValue	255
Main
 Case message of
 SingleClic :
 Begin
  SendSignal 6 1
 End
End

Widget 22
Property
 Size		10 0
 Position	10 140
 Type		ItemDraw
 Title		{Green}
End

Widget 3
Property
 Size		320 0
 Position	50 180
 Type		HScrollBar
 MinValue	0
 MaxValue	255
Main
 Case message of
 SingleClic :
 Begin
  SendSignal 6 1
 End
End

Widget 23
Property
 Size		10 0
 Position	10 200
 Type		ItemDraw
 Title		{Blue}
End