function shellColours::getColouredOutput

Returns coloured string.

3 calls to shellColours::getColouredOutput()
ctools_drush_export in drush/ctools.drush.inc
Drush callback: export.
ctools_drush_export_info in drush/ctools.drush.inc
Drush callback: Export info.
_ctools_drush_export_view in drush/ctools.drush.inc
View a single object.

File

drush/ctools.drush.inc, line 1004

Class

shellColours
Class to deal with wrapping output strings with colour formatting for the shell.

Code

public static function getColouredOutput($string, $foreground_colour = NULL, $background_colour = NULL) {
    $coloured_string = "";
    // Check if given foreground colour found.
    if ($foreground_colour) {
        $coloured_string .= "\x1b[" . self::$foreground_colours[$foreground_colour] . "m";
    }
    // Check if given background colour found.
    if ($background_colour) {
        $coloured_string .= "\x1b[" . self::$background_colours[$background_colour] . "m";
    }
    // Add string and end colouring.
    $coloured_string .= $string . "\x1b[0m";
    return $coloured_string;
}