@@ -220,7 +220,7 @@ public function setAutocomplete(AutocompleteInterface $autocomplete = null)
220
220
/**
221
221
* redraw the current input prompt
222
222
*
223
- * Usually, there should be no need to to call this method manually. It will
223
+ * Usually, there should be no need to call this method manually. It will
224
224
* be invoked automatically whenever we detect the readline input needs to
225
225
* be (re)written to the output.
226
226
*
@@ -229,6 +229,7 @@ public function setAutocomplete(AutocompleteInterface $autocomplete = null)
229
229
* input buffer position.
230
230
*
231
231
* @return self
232
+ * @internal
232
233
*/
233
234
public function redraw ()
234
235
{
@@ -254,44 +255,62 @@ public function redraw()
254
255
return $ this ;
255
256
}
256
257
258
+ /**
259
+ * Clears the current input prompt (if any)
260
+ *
261
+ * Usually, there should be no need to call this method manually. It will
262
+ * be invoked automatically whenever we detect that output needs to be
263
+ * written in place of the current prompt. The prompt will be rewritten
264
+ * after clearing the prompt and writing the output.
265
+ *
266
+ * @return self
267
+ * @see Stdio::write() which is responsible for invoking this method
268
+ * @internal
269
+ */
257
270
public function clear ()
258
271
{
259
272
if ($ this ->prompt !== '' || ($ this ->echo !== false && $ this ->linebuffer !== '' )) {
260
273
$ this ->write ("\r\033[K " );
261
274
}
262
- // $output = str_repeat("\x09 \x09", strlen($this->prompt . $this->linebuffer));
263
- // $this->write($output) ;
275
+
276
+ return $ this ;
264
277
}
265
278
279
+ /** @internal */
266
280
public function onChar ($ char )
267
281
{
268
282
$ this ->sequencer ->push ($ char );
269
283
}
270
284
285
+ /** @internal */
271
286
public function onKeyBackspace ()
272
287
{
273
288
// left delete only if not at the beginning
274
289
$ this ->deleteChar ($ this ->linepos - 1 );
275
290
}
276
291
292
+ /** @internal */
277
293
public function onKeyDelete ()
278
294
{
279
295
// right delete only if not at the end
280
296
$ this ->deleteChar ($ this ->linepos );
281
297
}
282
298
299
+ /** @internal */
283
300
public function onKeyInsert ()
284
301
{
285
302
// TODO: toggle insert mode
286
303
}
287
304
305
+ /** @internal */
288
306
public function onKeyTab ()
289
307
{
290
308
if ($ this ->autocomplete !== null ) {
291
309
$ this ->autocomplete ->run ();
292
310
}
293
311
}
294
312
313
+ /** @internal */
295
314
public function onKeyEnter ()
296
315
{
297
316
if ($ this ->echo !== false ) {
@@ -300,35 +319,43 @@ public function onKeyEnter()
300
319
$ this ->processLine ();
301
320
}
302
321
322
+ /** @internal */
303
323
public function onKeyLeft ()
304
324
{
305
325
if ($ this ->move ) {
306
326
$ this ->moveCursorBy (-1 );
307
327
}
308
328
}
309
329
330
+ /** @internal */
310
331
public function onKeyRight ()
311
332
{
312
333
if ($ this ->move ) {
313
334
$ this ->moveCursorBy (1 );
314
335
}
315
336
}
316
337
338
+ /** @internal */
317
339
public function onKeyUp ()
318
340
{
319
341
if ($ this ->history !== null ) {
320
342
$ this ->history ->up ();
321
343
}
322
344
}
323
345
346
+ /** @internal */
324
347
public function onKeyDown ()
325
348
{
326
349
if ($ this ->history !== null ) {
327
350
$ this ->history ->down ();
328
351
}
329
352
}
330
353
331
- // character(s) that could not be processed by the sequencer
354
+ /**
355
+ * Will be invoked for character(s) that could not otherwise be processed by the sequencer
356
+ *
357
+ * @internal
358
+ */
332
359
public function onFallback ($ chars )
333
360
{
334
361
$ pre = $ this ->substr ($ this ->linebuffer , 0 , $ this ->linepos ); // read everything up until before backspace
@@ -354,6 +381,7 @@ public function onFallback($chars)
354
381
* indices out of range (exceeding current input buffer) are simply ignored
355
382
*
356
383
* @param int $n
384
+ * @internal
357
385
*/
358
386
public function deleteChar ($ n )
359
387
{
0 commit comments