|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PhpSchool\Terminal; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @author Michael Woodward <[email protected]> |
|
7
|
|
|
* @author Aydin Hassan <[email protected]> |
|
8
|
|
|
*/ |
|
9
|
|
|
interface Terminal |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* Get the available width of the terminal |
|
13
|
|
|
*/ |
|
14
|
|
|
public function getWidth() : int; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Get the available height of the terminal |
|
18
|
|
|
*/ |
|
19
|
|
|
public function getHeight() : int; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Disables echoing every character back to the terminal. This means |
|
23
|
|
|
* we do not have to clear the line when reading. |
|
24
|
|
|
*/ |
|
25
|
|
|
public function disableEchoBack() : void; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Enable echoing back every character input to the terminal. |
|
29
|
|
|
*/ |
|
30
|
|
|
public function enableEchoBack() : void; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Is echo back mode enabled |
|
34
|
|
|
*/ |
|
35
|
|
|
public function isEchoBack() : bool; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Disable canonical input (allow each key press for reading, rather than the whole line) |
|
39
|
|
|
* |
|
40
|
|
|
* @see https://www.gnu.org/software/libc/manual/html_node/Canonical-or-Not.html |
|
41
|
|
|
*/ |
|
42
|
|
|
public function disableCanonicalMode() : void; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Enable canonical input - read input by line |
|
46
|
|
|
* |
|
47
|
|
|
* @see https://www.gnu.org/software/libc/manual/html_node/Canonical-or-Not.html |
|
48
|
|
|
*/ |
|
49
|
|
|
public function enableCanonicalMode() : void; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Is canonical mode enabled or not |
|
53
|
|
|
*/ |
|
54
|
|
|
public function isCanonicalMode() : bool; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Check if the Input & Output streams are interactive. Eg - they are |
|
58
|
|
|
* connected to a terminal. |
|
59
|
|
|
* |
|
60
|
|
|
* @return bool |
|
61
|
|
|
*/ |
|
62
|
|
|
public function isInteractive() : bool; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Test whether terminal supports colour output |
|
66
|
|
|
*/ |
|
67
|
|
|
public function supportsColour() : bool; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Clear the terminal window |
|
71
|
|
|
*/ |
|
72
|
|
|
public function clear() : void; |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Clear the current cursors line |
|
76
|
|
|
*/ |
|
77
|
|
|
public function clearLine() : void; |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Clean the whole console without jumping the window |
|
81
|
|
|
*/ |
|
82
|
|
|
public function clean() : void; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Enable cursor display |
|
86
|
|
|
*/ |
|
87
|
|
|
public function enableCursor() : void; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Disable cursor display |
|
91
|
|
|
*/ |
|
92
|
|
|
public function disableCursor() : void; |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Move the cursor to the top left of the window |
|
96
|
|
|
*/ |
|
97
|
|
|
public function moveCursorToTop() : void; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Move the cursor to the start of a specific row |
|
101
|
|
|
*/ |
|
102
|
|
|
public function moveCursorToRow(int $rowNumber) : void; |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Move the cursor to a specific column |
|
106
|
|
|
*/ |
|
107
|
|
|
public function moveCursorToColumn(int $columnNumber) : void; |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Read from the input stream |
|
111
|
|
|
*/ |
|
112
|
|
|
public function read(int $bytes) : string; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Write to the output stream |
|
116
|
|
|
*/ |
|
117
|
|
|
public function write(string $buffer) : void; |
|
118
|
|
|
} |
|
119
|
|
|
|