File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,35 @@ public function setMove($move)
110
110
return $ this ;
111
111
}
112
112
113
+ /**
114
+ * set current text input buffer
115
+ *
116
+ * this moves the cursor to the end of the current
117
+ * input buffer (if any).
118
+ *
119
+ * @param string $input
120
+ * @return self
121
+ * @uses self::redraw()
122
+ */
123
+ public function setInput ($ input )
124
+ {
125
+ $ this ->linebuffer = $ input ;
126
+ $ this ->linepos = $ this ->strlen ($ this ->linebuffer );
127
+ $ this ->redraw ();
128
+
129
+ return $ this ;
130
+ }
131
+
132
+ /**
133
+ * get current text input buffer
134
+ *
135
+ * @return string
136
+ */
137
+ public function getInput ()
138
+ {
139
+ return $ this ->linebuffer ;
140
+ }
141
+
113
142
/**
114
143
* set history handler to use (or none)
115
144
*
Original file line number Diff line number Diff line change @@ -16,4 +16,15 @@ public function testSettersReturnSelf()
16
16
$ this ->assertSame ($ this ->readline , $ this ->readline ->setMove (true ));
17
17
$ this ->assertSame ($ this ->readline , $ this ->readline ->setPrompt ('' ));
18
18
}
19
+
20
+ public function testInputStartsEmpty ()
21
+ {
22
+ $ this ->assertEquals ('' , $ this ->readline ->getInput ());
23
+ }
24
+
25
+ public function testGetInputAfterSetting ()
26
+ {
27
+ $ this ->assertSame ($ this ->readline , $ this ->readline ->setInput ('hello ' ));
28
+ $ this ->assertEquals ('hello ' , $ this ->readline ->getInput ());
29
+ }
19
30
}
You can’t perform that action at this time.
0 commit comments