00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 final class MetaOutput
00017 {
00018 private $out = null;
00019
00020 public function __construct(TextOutput $out)
00021 {
00022 $this->out = $out;
00023 }
00024
00028 public function getOutput()
00029 {
00030 return $this->out;
00031 }
00032
00036 public function newLine()
00037 {
00038 $this->out->newLine();
00039
00040 return $this;
00041 }
00042
00046 public function log($text, $bold = false)
00047 {
00048 return $this->defaultText($text, ConsoleMode::FG_WHITE, $bold);
00049 }
00050
00054 public function logLine($text, $bold = false)
00055 {
00056 return $this->defaultTextLine($text, ConsoleMode::FG_WHITE, $bold);
00057 }
00058
00062 public function info($text, $bold = false)
00063 {
00064 return $this->defaultText($text, ConsoleMode::FG_GREEN, $bold);
00065 }
00066
00070 public function infoLine($text, $bold = false)
00071 {
00072 return $this->defaultTextLine($text, ConsoleMode::FG_GREEN, $bold);
00073 }
00074
00078 public function warning($text)
00079 {
00080 return $this->defaultText($text, ConsoleMode::FG_BROWN, true);
00081 }
00082
00086 public function warningLine($text)
00087 {
00088 return $this->defaultTextLine($text, ConsoleMode::FG_BROWN, true);
00089 }
00090
00094 public function error($text, $bold = false)
00095 {
00096 return $this->defaultText($text, ConsoleMode::FG_RED, $bold);
00097 }
00098
00102 public function errorLine($text, $bold = false)
00103 {
00104 return $this->defaultTextLine($text, ConsoleMode::FG_RED, $bold);
00105 }
00106
00110 public function remark($text)
00111 {
00112 return $this->defaultText($text, ConsoleMode::FG_BLUE, true);
00113 }
00114
00118 public function remarkLine($text)
00119 {
00120 return $this->defaultTextLine($text, ConsoleMode::FG_BLUE, true);
00121 }
00122
00126 private function defaultText($text, $color, $bold)
00127 {
00128 $this->out->
00129 setMode(
00130 $bold ? ConsoleMode::ATTR_BOLD : ConsoleMode::ATTR_RESET_ALL,
00131 $color,
00132 ConsoleMode::BG_BLACK
00133 )->
00134 write($text);
00135
00136 if ($this->out instanceof ColoredTextOutput)
00137 $this->out->resetAll();
00138
00139 return $this;
00140 }
00141
00145 private function defaultTextLine($text, $color, $bold)
00146 {
00147 $this->out->
00148 setMode(
00149 $bold ? ConsoleMode::ATTR_BOLD : ConsoleMode::ATTR_RESET_ALL,
00150 $color,
00151 ConsoleMode::BG_BLACK
00152 )->
00153 writeLine($text);
00154
00155 if ($this->out instanceof ColoredTextOutput)
00156 $this->out->resetAll();
00157
00158 return $this;
00159 }
00160 }
00161 ?>