1 | <?php |
||
18 | class Console |
||
19 | { |
||
20 | |||
21 | const black = "\e[0;30m"; |
||
22 | const b_black = "\e[30;1m"; |
||
23 | |||
24 | const red = "\e[0;31m"; |
||
25 | const b_red = "\e[1;31m"; |
||
26 | |||
27 | const green = "\e[0;32m"; |
||
28 | const b_green = "\e[1;32m"; |
||
29 | |||
30 | const yellow = "\e[0;33m"; |
||
31 | const b_yellow = "\e[1;33m"; |
||
32 | |||
33 | const blue = "\e[0;34m"; |
||
34 | const b_blue = "\e[1;34m"; |
||
35 | |||
36 | const magenta = "\e[0;35m"; |
||
37 | const b_magenta = "\e[1;35m"; |
||
38 | |||
39 | const cyan = "\e[0;36m"; |
||
40 | const b_cyan = "\e[1;36m"; |
||
41 | |||
42 | const white = "\e[0;37m"; |
||
43 | const b_white = "\e[1;37m"; |
||
44 | |||
45 | // define aliases for colors |
||
46 | const error = "\e[37;1m\e[41m"; |
||
47 | const success = self::b_green; |
||
48 | const normal = "\e[0m"; |
||
49 | const bold = self::b_white; |
||
50 | |||
51 | |||
52 | /** @var OutputInterface */ |
||
53 | protected $consoleOutput; |
||
54 | |||
55 | /** @var SymfonyStyle */ |
||
56 | protected $sfStyleOutput; |
||
57 | |||
58 | /** @var boolean Color console enabled */ |
||
59 | protected $colorEnabled; |
||
60 | /** |
||
61 | * @var Dispatcher |
||
62 | */ |
||
63 | private $dispatcher; |
||
64 | |||
65 | /** |
||
66 | * Console constructor. |
||
67 | * |
||
68 | * @param bool $colorEnabled |
||
69 | */ |
||
70 | 52 | public function __construct($colorEnabled) |
|
71 | { |
||
72 | 52 | $this->colorEnabled = $colorEnabled; |
|
73 | 52 | } |
|
74 | |||
75 | |||
76 | /** |
||
77 | * Initialize service with the console output. |
||
78 | * |
||
79 | * @param OutputInterface $consoleOutput |
||
80 | * @param $dispatcher |
||
81 | */ |
||
82 | public function init(OutputInterface $consoleOutput, $dispatcher) |
||
89 | |||
90 | /** |
||
91 | * @inheritdoc |
||
92 | */ |
||
93 | public function writeln($string) |
||
97 | |||
98 | /** |
||
99 | * @inheritdoc |
||
100 | */ |
||
101 | public function write($string, $newline = false) |
||
136 | |||
137 | /** |
||
138 | * Outoyt brute text. |
||
139 | * |
||
140 | * @param string $msg |
||
141 | * @param boolean $newline |
||
142 | * |
||
143 | */ |
||
144 | protected function ansiOut($msg, $newline) |
||
152 | |||
153 | /** |
||
154 | * Strip styles from a string. |
||
155 | * |
||
156 | * @param $string |
||
157 | * |
||
158 | * @return mixed |
||
159 | */ |
||
160 | protected function stripStyles($string) |
||
164 | |||
165 | |||
166 | protected function doHslConvert($r, $g, $b) |
||
221 | |||
222 | /** |
||
223 | * Get symphony console. |
||
224 | * |
||
225 | * @return OutputInterface |
||
226 | */ |
||
227 | public function getConsoleOutput() |
||
235 | |||
236 | /** |
||
237 | * Get symfony style output. |
||
238 | * |
||
239 | * @return SymfonyStyle |
||
240 | */ |
||
241 | public function getSfStyleOutput(): SymfonyStyle |
||
248 | } |
||
249 |