Use new colors in terminal

This commit is contained in:
Shoghi Cervantes 2015-03-15 18:32:36 +01:00
parent d5601b0c9f
commit f9361aa931
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
3 changed files with 20 additions and 27 deletions

View File

@ -177,13 +177,13 @@ class MainLogger extends \AttachableThreadedLogger{
protected function send($message, $level = -1){
$now = time();
$message = TextFormat::toANSI(TextFormat::AQUA . date("H:i:s", $now) . TextFormat::RESET . " " . $message . TextFormat::RESET . PHP_EOL);
$message = TextFormat::toANSI(TextFormat::AQUA . date("H:i:s", $now) . TextFormat::RESET . " " . $message . TextFormat::RESET);
$cleanMessage = TextFormat::clean($message);
if(!Terminal::hasFormattingCodes()){
echo $cleanMessage;
echo $cleanMessage . PHP_EOL;
}else{
echo Terminal::$START_LINE . $message . Terminal::$END_LINE;
echo $message . PHP_EOL;
}
if($this->attachment instanceof \ThreadedLoggerAttachment){

View File

@ -22,10 +22,6 @@
namespace pocketmine\utils;
abstract class Terminal{
public static $START_LINE = "";
public static $END_LINE = "";
public static $FORMAT_BOLD = "";
public static $FORMAT_OBFUSCATED = "";
public static $FORMAT_ITALIC = "";
@ -67,7 +63,7 @@ abstract class Terminal{
protected static function getEscapeCodes(){
self::$FORMAT_BOLD = `tput bold`;
self::$FORMAT_OBFUSCATED = `tput invis`;
self::$FORMAT_OBFUSCATED = `tput smacs`;
self::$FORMAT_ITALIC = `tput sitm`;
self::$FORMAT_UNDERLINE = `tput smul`;
self::$FORMAT_STRIKETHROUGH = "\x1b[9m"; //`tput `;
@ -102,9 +98,6 @@ abstract class Terminal{
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = `tput setaf 6`;
self::$COLOR_GRAY = self::$COLOR_WHITE = `tput setaf 7`;
}
self::$START_LINE = `tput sc` . "\n" . `tput cuu1` . "\r";
self::$END_LINE = `tput rc`;
}
public static function init(){

View File

@ -411,52 +411,52 @@ abstract class TextFormat{
//Colors
case TextFormat::BLACK:
$newString .= "\x1b[38;2;0;0;0m";
$newString .= Terminal::$COLOR_BLACK;
break;
case TextFormat::DARK_BLUE:
$newString .= "\x1b[38;2;0;0;170m";
$newString .= Terminal::$COLOR_DARK_BLUE;
break;
case TextFormat::DARK_GREEN:
$newString .= "\x1b[38;2;0;170;0m";
$newString .= Terminal::$COLOR_DARK_GREEN;
break;
case TextFormat::DARK_AQUA:
$newString .= "\x1b[38;2;0;170;170m";
$newString .= Terminal::$COLOR_DARK_AQUA;
break;
case TextFormat::DARK_RED:
$newString .= "\x1b[38;2;170;0;0m";
$newString .= Terminal::$COLOR_DARK_RED;
break;
case TextFormat::DARK_PURPLE:
$newString .= "\x1b[38;2;170;0;170m";
$newString .= Terminal::$COLOR_PURPLE;
break;
case TextFormat::GOLD:
$newString .= "\x1b[38;2;255;170;0m";
$newString .= Terminal::$COLOR_GOLD;
break;
case TextFormat::GRAY:
$newString .= "\x1b[38;2;170;170;170m";
$newString .= Terminal::$COLOR_GRAY;
break;
case TextFormat::DARK_GRAY:
$newString .= "\x1b[38;2;85;85;85m";
$newString .= Terminal::$COLOR_DARK_GRAY;
break;
case TextFormat::BLUE:
$newString .= "\x1b[38;2;85;85;255m";
$newString .= Terminal::$COLOR_BLUE;
break;
case TextFormat::GREEN:
$newString .= "\x1b[38;2;85;255;85m";
$newString .= Terminal::$COLOR_GREEN;
break;
case TextFormat::AQUA:
$newString .= "\x1b[38;2;85;255;255m";
$newString .= Terminal::$COLOR_AQUA;
break;
case TextFormat::RED:
$newString .= "\x1b[38;2;255;85;85m";
$newString .= Terminal::$COLOR_RED;
break;
case TextFormat::LIGHT_PURPLE:
$newString .= "\x1b[38;2;255;85;255m";
$newString .= Terminal::$COLOR_LIGHT_PURPLE;
break;
case TextFormat::YELLOW:
$newString .= "\x1b[38;2;255;255;85m";
$newString .= Terminal::$COLOR_YELLOW;
break;
case TextFormat::WHITE:
$newString .= "\x1b[38;2;255;255;255m";
$newString .= Terminal::$COLOR_WHITE;
break;
default:
$newString .= $token;