@@ -15,8 +15,10 @@ class Readline extends EventEmitter
1515 const ESC_RIGHT = "C " ;
1616 const ESC_UP = "A " ;
1717 const ESC_DOWN = "B " ;
18- const ESC_DEL = "3 ~ " ;
18+ const ESC_HOME = "1 ~ " ;
1919 const ESC_INS = "2~ " ;
20+ const ESC_DEL = "3~ " ;
21+ const ESC_END = "4~ " ;
2022
2123 const ESC_F10 = "20~ " ;
2224
@@ -45,8 +47,10 @@ public function __construct($output)
4547 $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_RIGHT , array ($ this , 'onKeyRight ' ));
4648 $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_UP , array ($ this , 'onKeyUp ' ));
4749 $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_DOWN , array ($ this , 'onKeyDown ' ));
48- $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_DEL , array ($ this , 'onKeyDelete ' ));
50+ $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_HOME , array ($ this , 'onKeyHome ' ));
4951 $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_INS , array ($ this , 'onKeyInsert ' ));
52+ $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_DEL , array ($ this , 'onKeyDelete ' ));
53+ $ this ->sequencer ->addSequence (self ::ESC_SEQUENCE . self ::ESC_END , array ($ this , 'onKeyEnd ' ));
5054
5155 $ expect = 0 ;
5256 $ char = '' ;
@@ -417,6 +421,18 @@ public function onKeyInsert()
417421 // TODO: toggle insert mode
418422 }
419423
424+ /** @internal */
425+ public function onKeyHome ()
426+ {
427+ $ this ->moveCursorTo (0 );
428+ }
429+
430+ /** @internal */
431+ public function onKeyEnd ()
432+ {
433+ $ this ->moveCursorTo ($ this ->strlen ($ this ->linebuffer ));
434+ }
435+
420436 /** @internal */
421437 public function onKeyTab ()
422438 {
0 commit comments