Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | color - Modified "Apply" to distinguish calls with explicit empty string (EES) from those with no argument (NA). EES returns the string as is, whereas NA returns the requested low-level colorization instructions. Extended tests. Version bumped to 1.0.2. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
af5f3c47d79386daaafaffd88428de5c |
User & Date: | aku 2015-07-03 05:21:11.380 |
Original Comment: | color - In Apply distinguish calls with explicit empty string (EES) from those with no argument (NA). EES returns string as is, EA returns requested low-level colorization instructions. Extended tests. Version bumped to 1.0.2. |
Context
2015-07-03
| ||
05:26 | color - Updated the documentation. check-in: c82025d2d2 user: aku tags: trunk | |
05:21 | color - Modified "Apply" to distinguish calls with explicit empty string (EES) from those with no argument (NA). EES returns the string as is, whereas NA returns the requested low-level colorization instructions. Extended tests. Version bumped to 1.0.2. check-in: af5f3c47d7 user: aku tags: trunk | |
05:01 | Merge VT test work back to main line. check-in: dd4c6bd2ac user: aku tags: trunk | |
Changes
Changes to color.tcl.
︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 | proc ::cmdr::color::Unknown {cmd codes {text {}}} { debug.cmdr/color {} list [namespace current]::Apply $codes } proc ::cmdr::color::Apply {codes {text {}}} { debug.cmdr/color {} # Check codes first. Even if not active! IOW do not stop catching # the use of bad/unknown codes just because we switched off the # colorization. variable char foreach c $codes { if {![dict exists $char $c]} { | > > > > > > > > | 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | proc ::cmdr::color::Unknown {cmd codes {text {}}} { debug.cmdr/color {} list [namespace current]::Apply $codes } proc ::cmdr::color::Apply {codes {text {}}} { debug.cmdr/color {} # Empty string, user-specified (IOW not the default value). # Return as is, color superfluous (no-op: set, then reset, with # nothing in between) if {($text eq {}) && ([llength [info level 0]] == 3)} { return $text } # Check codes first. Even if not active! IOW do not stop catching # the use of bad/unknown codes just because we switched off the # colorization. variable char foreach c $codes { if {![dict exists $char $c]} { |
︙ | ︙ | |||
233 234 235 236 237 238 239 240 241 242 243 244 245 246 | return $text } # Apply chosen colors. Validation happend already. foreach c $codes { append r [dict get $char $c] } if {$text ne {}} { append r $text append r [dict get $char reset] } debug.cmdr/color {/done} return $r | > > > | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | return $text } # Apply chosen colors. Validation happend already. foreach c $codes { append r [dict get $char $c] } # Empty string here can only be default value => Were called only # with code, no text => No reset, we wanted just the low-level # string for the color code. if {$text ne {}} { append r $text append r [dict get $char reset] } debug.cmdr/color {/done} return $r |
︙ | ︙ | |||
350 351 352 353 354 355 356 | lappend smap $c $o } lappend smap \127 \\127 } ::cmdr::color} # # ## ### ##### ######## ############# ##################### ## Ready | | | 361 362 363 364 365 366 367 368 | lappend smap $c $o } lappend smap \127 \\127 } ::cmdr::color} # # ## ### ##### ######## ############# ##################### ## Ready package provide cmdr::color 1.0.2 |
Changes to tests/color.test.
︙ | ︙ | |||
176 177 178 179 180 181 182 183 184 185 186 187 188 189 | cmdr color activate 1 } -body { cmdr color {bold red} } -cleanup { cmdr color activate $save unset save } -result "\033\[1m\033\[31m" # # ## ### ##### ######## ############# ##################### ## Go through the API commands. ## active, activate, names, get, get-def, define, exists # # ## ### ##### ######## ############# ##################### ## active | > > > > > > > > > > > > > > > > > > > > | 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 | cmdr color activate 1 } -body { cmdr color {bold red} } -cleanup { cmdr color activate $save unset save } -result "\033\[1m\033\[31m" test cmdr-color-2.4 {color, formatting, single code, empty string} -setup { set save [cmdr color active] cmdr color activate 1 } -body { cmdr color red {} } -cleanup { cmdr color activate $save unset save } -result "" test cmdr-color-2.5 {color, formatting, multi-code, empty string} -setup { set save [cmdr color active] cmdr color activate 1 } -body { cmdr color {bold red} {} } -cleanup { cmdr color activate $save unset save } -result "" # # ## ### ##### ######## ############# ##################### ## Go through the API commands. ## active, activate, names, get, get-def, define, exists # # ## ### ##### ######## ############# ##################### ## active |
︙ | ︙ |