File tree Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Expand file tree Collapse file tree 3 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ public function clear() : void;
80
80
* Clear the current cursors line
81
81
*/
82
82
public function clearLine () : void ;
83
+
84
+ /**
85
+ * Erase the entire current line
86
+ */
87
+ public function clearEntireLine () : void ;
88
+
89
+ /**
90
+ * Erase screen from the current line down to the bottom of the screen
91
+ */
92
+ public function clearDown () : void ;
83
93
84
94
/**
85
95
* Clean the whole console without jumping the window
Original file line number Diff line number Diff line change @@ -196,6 +196,22 @@ public function clearLine() : void
196
196
$ this ->output ->write (sprintf ("\033[%dD \033[K " , $ this ->getWidth ()));
197
197
}
198
198
199
+ /**
200
+ * Erase the entire current line
201
+ */
202
+ public function clearEntireLine () : void
203
+ {
204
+ $ this ->output ->write ("\033[2K " );
205
+ }
206
+
207
+ /**
208
+ * Erase screen from the current line down to the bottom of the screen
209
+ */
210
+ public function clearDown () : void
211
+ {
212
+ $ this ->output ->write ("\033[J " );
213
+ }
214
+
199
215
public function clean () : void
200
216
{
201
217
foreach (range (0 , $ this ->getHeight ()) as $ rowNum ) {
Original file line number Diff line number Diff line change @@ -155,6 +155,28 @@ public function testClearLine() : void
155
155
self ::assertEquals ("\033[23D \033[K " , $ output ->fetch ());
156
156
}
157
157
158
+ public function testClearEntireLine () : void
159
+ {
160
+ $ input = $ this ->createMock (InputStream::class);
161
+ $ output = new BufferedOutput ;
162
+
163
+ $ terminal = new UnixTerminal ($ input , $ output );
164
+ $ terminal ->clearEntireLine ();
165
+
166
+ self ::assertEquals ("\033[2K " , $ output ->fetch ());
167
+ }
168
+
169
+ public function testClearDown () : void
170
+ {
171
+ $ input = $ this ->createMock (InputStream::class);
172
+ $ output = new BufferedOutput ;
173
+
174
+ $ terminal = new UnixTerminal ($ input , $ output );
175
+ $ terminal ->clearDown ();
176
+
177
+ self ::assertEquals ("\033[J " , $ output ->fetch ());
178
+ }
179
+
158
180
public function testClean () : void
159
181
{
160
182
$ input = $ this ->createMock (InputStream::class);
You can’t perform that action at this time.
0 commit comments