-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.tcl
More file actions
173 lines (148 loc) · 4.9 KB
/
Copy pathformat.tcl
File metadata and controls
173 lines (148 loc) · 4.9 KB
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
# Copyright (c) 2025 Nicolas ROBERT.
# Distributed under MIT license. Please see LICENSE for details.
namespace eval zesty {}
proc zesty::validValue {type key validvalue value} {
# Check if value is valid.
#
# type - type
# key - key
# validvalue - valid value
# value - value
#
# Returns nothing or an error message if invalid.
variable boxstyles
variable titleAnchor
variable tablestyles
if {$validvalue eq "" || $type eq "none"} {
return {}
}
switch -exact -- $validvalue {
formatVKVP -
formatStyle {
zesty::validateKeyValuePairs $key $value
}
formatHSets {
zesty::validateKeyValuePairs $key $value
foreach {skey svalue} $value {
zesty::validateKeyValuePairs $skey $svalue
}
}
formatAlign {
if {$value ni {"left" "right" "center"}} {
error "zesty(error): value '$value' should be\
'left', 'right', or 'center' for\
this key '$key'."
}
}
formatIBMode {
if {$value ni {"determinate" "indeterminate"}} {
error "zesty(error): '$key' must be 'determinate'\
or 'indeterminate'"
}
}
formatIBStyle {
if {$value ni {"bounce" "pulse" "wave"}} {
error "zesty(error): value '$value' should be\
'bounce', 'pulse', or 'wave' for\
this key '$key'."
}
}
formatVertical {
if {$value ni {"top" "bottom" "middle"}} {
error "zesty(error): value '$value' should be\
'top', 'bottom', or 'middle' for\
this key '$key'."
}
}
formatTitleAnchor {
if {$value ni $titleAnchor} {
set keyType [format {%s or %s.} \
[join [lrange $titleAnchor 0 end-1] ", "] \
[lindex $titleAnchor end] \
]
error "zesty(error): '$value' must be one of: $keyType\
for this key '$key'."
}
}
formatTypeTable {
set keys [dict keys $tablestyles]
if {$value ni $keys} {
set keyType [format {%s or %s.} \
[join [lrange $keys 0 end-1] ", "] \
[lindex $keys end] \
]
error "zesty(error): '$value' must be one of: $keyType\
for this key '$key'."
}
}
formatTypeBox {
set keys [dict keys $boxstyles]
if {$value ni $keys} {
set keyType [format {%s or %s.} \
[join [lrange $keys 0 end-1] ", "] \
[lindex $keys end] \
]
error "zesty(error): '$value' must be one of: $keyType\
for this key '$key'."
}
}
formatTTask -
formatCTask -
formatMVL -
formatPad {
zesty::isPositiveIntegerValue $key $value
}
formatIBSpeed {
if {$value == 0} {
error "zesty(error): '$key' should not be equal to '0'"
}
}
formatColums {
foreach col $value {
if {([zesty::typeOf $col] ne "num") || (($col != -1) && ($col < 1))} {
error "zesty(error): Column widths must be positive integers or\
-1 for auto width."
}
}
}
formatAlignements {
foreach align $value {
if {$align ni {"left" "right" "center"}} {
error "zesty(error): Align column table must be one of\
: left, right, center"
}
}
}
formatStyles {
foreach style $value {
zesty::validateKeyValuePairs "style" $style
}
}
formatSizeBox {
if {[llength $value] != 2} {
error "zesty(error): '$key' must be a list of two\
integers {width height}"
}
lassign $value width height
zesty::isPositiveIntegerValue $key $width
zesty::isPositiveIntegerValue $key $height
}
formatSFreq -
formatMCWidth {
zesty::isPositiveIntegerValue $key $value 1
}
formatMBWidth {
zesty::isPositiveIntegerValue $key $value 5
}
formatLChar {
if {[zesty::strLength $value] != 1} {
error "zesty(error): This 'key' should be one character."
}
}
formatVBool {
if {![string is boolean -strict $value]} {
error "zesty(error): '$key' must be a boolean value."
}
}
}
}