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
|
|
|
* Restore the terminals original configuration |
66
|
|
|
*/ |
67
|
|
|
public function restoreOriginalConfiguration() : void; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Test whether terminal supports colour output |
71
|
|
|
*/ |
72
|
|
|
public function supportsColour() : bool; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Clear the terminal window |
76
|
|
|
*/ |
77
|
|
|
public function clear() : void; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Clear the current cursors line |
81
|
|
|
*/ |
82
|
|
|
public function clearLine() : void; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Clean the whole console without jumping the window |
86
|
|
|
*/ |
87
|
|
|
public function clean() : void; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Enable cursor display |
91
|
|
|
*/ |
92
|
|
|
public function enableCursor() : void; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Disable cursor display |
96
|
|
|
*/ |
97
|
|
|
public function disableCursor() : void; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Move the cursor to the top left of the window |
101
|
|
|
*/ |
102
|
|
|
public function moveCursorToTop() : void; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Move the cursor to the start of a specific row |
106
|
|
|
*/ |
107
|
|
|
public function moveCursorToRow(int $rowNumber) : void; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Move the cursor to a specific column |
111
|
|
|
*/ |
112
|
|
|
public function moveCursorToColumn(int $columnNumber) : void; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Read from the input stream |
116
|
|
|
*/ |
117
|
|
|
public function read(int $bytes) : string; |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Write to the output stream |
121
|
|
|
*/ |
122
|
|
|
public function write(string $buffer) : void; |
123
|
|
|
} |
124
|
|
|
|