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){ protected function send($message, $level = -1){
$now = time(); $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); $cleanMessage = TextFormat::clean($message);
if(!Terminal::hasFormattingCodes()){ if(!Terminal::hasFormattingCodes()){
echo $cleanMessage; echo $cleanMessage . PHP_EOL;
}else{ }else{
echo Terminal::$START_LINE . $message . Terminal::$END_LINE; echo $message . PHP_EOL;
} }
if($this->attachment instanceof \ThreadedLoggerAttachment){ if($this->attachment instanceof \ThreadedLoggerAttachment){

View File

@ -22,10 +22,6 @@
namespace pocketmine\utils; namespace pocketmine\utils;
abstract class Terminal{ abstract class Terminal{
public static $START_LINE = "";
public static $END_LINE = "";
public static $FORMAT_BOLD = ""; public static $FORMAT_BOLD = "";
public static $FORMAT_OBFUSCATED = ""; public static $FORMAT_OBFUSCATED = "";
public static $FORMAT_ITALIC = ""; public static $FORMAT_ITALIC = "";
@ -67,7 +63,7 @@ abstract class Terminal{
protected static function getEscapeCodes(){ protected static function getEscapeCodes(){
self::$FORMAT_BOLD = `tput bold`; self::$FORMAT_BOLD = `tput bold`;
self::$FORMAT_OBFUSCATED = `tput invis`; self::$FORMAT_OBFUSCATED = `tput smacs`;
self::$FORMAT_ITALIC = `tput sitm`; self::$FORMAT_ITALIC = `tput sitm`;
self::$FORMAT_UNDERLINE = `tput smul`; self::$FORMAT_UNDERLINE = `tput smul`;
self::$FORMAT_STRIKETHROUGH = "\x1b[9m"; //`tput `; 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_AQUA = self::$COLOR_DARK_AQUA = `tput setaf 6`;
self::$COLOR_GRAY = self::$COLOR_WHITE = `tput setaf 7`; 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(){ public static function init(){

View File

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