1 | <?php |
||
11 | class UnixTerminal implements TerminalInterface |
||
12 | { |
||
13 | /** |
||
14 | * @var bool |
||
15 | */ |
||
16 | private $isTTY; |
||
17 | |||
18 | /** |
||
19 | * @var bool |
||
20 | */ |
||
21 | private $isCanonical = false; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | private $width; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $height; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $details; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | */ |
||
41 | private $originalConfiguration; |
||
42 | |||
43 | /** |
||
44 | * Initialise the terminal from resource |
||
45 | * |
||
46 | */ |
||
47 | public function __construct() |
||
51 | |||
52 | /** |
||
53 | * Get the available width of the terminal |
||
54 | * |
||
55 | * @return int |
||
56 | */ |
||
57 | public function getWidth() |
||
61 | |||
62 | /** |
||
63 | * Get the available height of the terminal |
||
64 | * |
||
65 | * @return int |
||
66 | */ |
||
67 | public function getHeight() |
||
71 | |||
72 | /** |
||
73 | * Get terminal details |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | public function getDetails() |
||
87 | |||
88 | /** |
||
89 | * Get the original terminal configuration / mode |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | private function getOriginalConfiguration() |
||
97 | |||
98 | /** |
||
99 | * Toggle canonical mode on TTY |
||
100 | * |
||
101 | * @param bool $useCanonicalMode |
||
102 | */ |
||
103 | public function setCanonicalMode($useCanonicalMode = true) |
||
113 | |||
114 | /** |
||
115 | * Check if TTY is in canonical mode |
||
116 | * Assumes the terminal was never in canonical mode |
||
117 | * |
||
118 | * @return bool |
||
119 | */ |
||
120 | public function isCanonical() |
||
124 | |||
125 | /** |
||
126 | * Test whether terminal is valid TTY |
||
127 | * |
||
128 | * @return bool |
||
129 | */ |
||
130 | public function isTTY() |
||
134 | |||
135 | /** |
||
136 | * Test whether terminal supports colour output |
||
137 | * |
||
138 | * @return bool |
||
139 | * |
||
140 | * @link https://github.com/symfony/Console/blob/master/Output/StreamOutput.php#L95-L102 |
||
141 | */ |
||
142 | public function supportsColour() |
||
150 | |||
151 | /** |
||
152 | * @param array $map |
||
153 | * @return string |
||
154 | */ |
||
155 | public function getKeyedInput(array $map = []) |
||
182 | |||
183 | /** |
||
184 | * Clear the terminal window |
||
185 | */ |
||
186 | public function clear() |
||
190 | |||
191 | /** |
||
192 | * Enable cursor |
||
193 | */ |
||
194 | public function enableCursor() |
||
198 | |||
199 | /** |
||
200 | * Disable cursor |
||
201 | */ |
||
202 | public function disableCursor() |
||
206 | |||
207 | /** |
||
208 | * Move the cursor to the top left of the window |
||
209 | * |
||
210 | * @return void |
||
211 | */ |
||
212 | public function moveCursorToTop() |
||
216 | |||
217 | /** |
||
218 | * Move the cursor to the start of a specific row |
||
219 | * |
||
220 | * @param int $rowNumber |
||
221 | */ |
||
222 | public function moveCursorToRow($rowNumber) |
||
226 | |||
227 | /** |
||
228 | * Move the cursor to the start of a specific column |
||
229 | * |
||
230 | * @param int $column |
||
231 | */ |
||
232 | public function moveCursorToColumn($column) |
||
236 | |||
237 | /** |
||
238 | * Clear the current cursors line |
||
239 | * |
||
240 | * @return void |
||
241 | */ |
||
242 | public function clearLine() |
||
246 | |||
247 | /** |
||
248 | * Clean the whole console without jumping the window |
||
249 | */ |
||
250 | public function clean() |
||
257 | } |
||
258 |