summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-11-22 19:49:39 -0500
committerScott Ullrich <sullrich@pfsense.org>2009-11-22 19:49:39 -0500
commitb927a013e99565425678ddb35117c72f24543915 (patch)
tree618f60509d20e52ab9d3089b2ec18a8fccde90bf /etc/inc/util.inc
parent385a3a31aff98cf339c3d3ca0f7c6315306e92db (diff)
downloadpfsense-b927a013e99565425678ddb35117c72f24543915.zip
pfsense-b927a013e99565425678ddb35117c72f24543915.tar.gz
Allow specifying colors by their name
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc25
1 files changed, 23 insertions, 2 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 315f273..a2e52ac 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1066,15 +1066,36 @@ function color($color = "0m") {
46m set background color to cyan
47m set background color to white
49m set background color to default (black)
- */
+ */
// Allow caching of TERM to
// speedup subequence requests.
global $TERM;
if(!$TERM)
$TERM=`/usr/bin/env | grep color`;
$ESCAPE=chr(27);
- if($TERM)
+ if($TERM) {
+ switch ($color) {
+ case "black":
+ return "{$ESCAPE}[30m";
+ case "red":
+ return "{$ESCAPE}[31m";
+ case "green":
+ return "{$ESCAPE}[32m";
+ case "yellow":
+ return "{$ESCAPE}[33m";
+ case "blue":
+ return "{$ESCAPE}[34m";
+ case "magenta":
+ return "{$ESCAPE}[35m";
+ case "cyan":
+ return "{$ESCAPE}[36m";
+ case "white":
+ return "{$ESCAPE}[37m";
+ case "default":
+ return "{$ESCAPE}[39m";
+ }
return "{$ESCAPE}[{$color}";
+ }
}
?> \ No newline at end of file
OpenPOWER on IntegriCloud