File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ You can restore this behavior by passing an empty prompt:
117117$readline->setPrompt('');
118118```
119119
120+ The ` getPrompt() ` method can be used to get the current input prompt.
121+ It will return an empty string unless you've set anything else:
122+
123+ ``` php
124+ assert($readline->getPrompt() === '');
125+ ```
126+
120127#### Echo
121128
122129The * echo mode* controls how the actual * user input buffer* will be presented in the * user input line* .
Original file line number Diff line number Diff line change @@ -122,6 +122,17 @@ public function setPrompt($prompt)
122122 return $ this ->redraw ();
123123 }
124124
125+ /**
126+ * returns the prompt to prepend to input line
127+ *
128+ * @return string
129+ * @see self::setPrompt()
130+ */
131+ public function getPrompt ()
132+ {
133+ return $ this ->prompt ;
134+ }
135+
125136 /**
126137 * sets whether/how to echo text input
127138 *
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public function testSettersReturnSelf()
2626
2727 public function testInputStartsEmpty ()
2828 {
29+ $ this ->assertEquals ('' , $ this ->readline ->getPrompt ());
2930 $ this ->assertEquals ('' , $ this ->readline ->getInput ());
3031 $ this ->assertEquals (0 , $ this ->readline ->getCursorPosition ());
3132 $ this ->assertEquals (0 , $ this ->readline ->getCursorCell ());
@@ -39,6 +40,12 @@ public function testGetInputAfterSetting()
3940 $ this ->assertEquals (5 , $ this ->readline ->getCursorCell ());
4041 }
4142
43+ public function testPromptAfterSetting ()
44+ {
45+ $ this ->assertSame ($ this ->readline , $ this ->readline ->setPrompt ('> ' ));
46+ $ this ->assertEquals ('> ' , $ this ->readline ->getPrompt ());
47+ }
48+
4249 public function testSettingInputMovesCursorToEnd ()
4350 {
4451 $ this ->readline ->setInput ('hello ' );
You can’t perform that action at this time.
0 commit comments