Test: colorstr moved to util.tcl.
This commit is contained in:
parent
a1dca2efab
commit
34c404e069
@ -61,36 +61,6 @@ proc wait_for_condition {maxtries delay e _else_ elsescript} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test if TERM looks like to support colors
|
|
||||||
proc color_term {} {
|
|
||||||
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
|
|
||||||
}
|
|
||||||
|
|
||||||
proc colorstr {color str} {
|
|
||||||
if {[color_term]} {
|
|
||||||
set b 0
|
|
||||||
if {[string range $color 0 4] eq {bold-}} {
|
|
||||||
set b 1
|
|
||||||
set color [string range $color 5 end]
|
|
||||||
}
|
|
||||||
switch $color {
|
|
||||||
red {set colorcode {31}}
|
|
||||||
green {set colorcode {32}}
|
|
||||||
yellow {set colorcode {33}}
|
|
||||||
blue {set colorcode {34}}
|
|
||||||
magenta {set colorcode {35}}
|
|
||||||
cyan {set colorcode {36}}
|
|
||||||
white {set colorcode {37}}
|
|
||||||
default {set colorcode {37}}
|
|
||||||
}
|
|
||||||
if {$colorcode ne {}} {
|
|
||||||
return "\033\[$b;${colorcode};40m$str\033\[0m"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return $str
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
proc test {name code {okpattern undefined}} {
|
proc test {name code {okpattern undefined}} {
|
||||||
# abort if tagged with a tag to deny
|
# abort if tagged with a tag to deny
|
||||||
foreach tag $::denytags {
|
foreach tag $::denytags {
|
||||||
|
@ -327,3 +327,33 @@ proc find_available_port start {
|
|||||||
error "Can't find a non busy port in the $start-[expr {$start+1023}] range."
|
error "Can't find a non busy port in the $start-[expr {$start+1023}] range."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Test if TERM looks like to support colors
|
||||||
|
proc color_term {} {
|
||||||
|
expr {[info exists ::env(TERM)] && [string match *xterm* $::env(TERM)]}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc colorstr {color str} {
|
||||||
|
if {[color_term]} {
|
||||||
|
set b 0
|
||||||
|
if {[string range $color 0 4] eq {bold-}} {
|
||||||
|
set b 1
|
||||||
|
set color [string range $color 5 end]
|
||||||
|
}
|
||||||
|
switch $color {
|
||||||
|
red {set colorcode {31}}
|
||||||
|
green {set colorcode {32}}
|
||||||
|
yellow {set colorcode {33}}
|
||||||
|
blue {set colorcode {34}}
|
||||||
|
magenta {set colorcode {35}}
|
||||||
|
cyan {set colorcode {36}}
|
||||||
|
white {set colorcode {37}}
|
||||||
|
default {set colorcode {37}}
|
||||||
|
}
|
||||||
|
if {$colorcode ne {}} {
|
||||||
|
return "\033\[$b;${colorcode};40m$str\033\[0m"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user