Hi,
ich kriegs nicht hin, Textpassagen in der Command Line zu färben.
Wenn ich das richtig verstanden habe, bastelt man Farben mit folgendem Code:
Code:
\[31m
^ESC(ASCII:27)
Warum im Forum PHP? Weil ich ein Command-Line Script in PHP basteln möchte - leider will das nicht. Mein Code:
PHP-Code:
<?php
// control characters
define('CTRL', chr(27)."[01;" );
define('NL', chr(10) );
define('RESET', CTRL.'0'.'m');
define('BOLD', CTRL.'1'.'m');
// colors
define('BLACK', '0');
define('RED', '1');
define('GREEN', '2');
define('YELLOW', '3');
define('BLUE', '4');
define('MAGENTA', '5');
define('CYAN', '6');
define('WHITE', '7');
// colors 2
define('FGN', '3' ); // foreground normal intensity
define('BGN', '4' ); // background normal intensity
define('FGH', '9' ); // foreground high intensity
define('BGH', '10'); // background high intensity
function color($color, $foreground = true, $normal = true) {
$mod = $foreground ? FGN : BGN;
$mod = $foreground && !$normal ? $mod+6 : $mod;
return CTRL.$mod.$color.'m';
}
echo 'Test in '.color(GREEN).'green'.RESET.NL;
echo 'Test in '.color(YELLOW, false).'green'.RESET.NL;
sleep(5);
FloB
Edit: Bei mir wird auf der Commadline folgendes Zeichen für ASCII(27) angezeigt: ←