Skip to content

Commit 8a7d472

Browse files
authored
Make stdio configurable (#112)
Make stdio configurable
2 parents cb50f5d + 868166a commit 8a7d472

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

select.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ type Select struct {
7676

7777
// A function that determines how to render the cursor
7878
Pointer Pointer
79+
80+
Stdin io.ReadCloser
81+
Stdout io.WriteCloser
7982
}
8083

8184
// SelectKeys defines the available keys used by select mode to enable the user to move around the list
@@ -216,14 +219,16 @@ func (s *Select) RunCursorAt(cursorPos, scroll int) (int, string, error) {
216219
}
217220

218221
func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) {
219-
stdin := readline.NewCancelableStdin(os.Stdin)
220-
c := &readline.Config{}
222+
c := &readline.Config{
223+
Stdin: s.Stdin,
224+
Stdout: s.Stdout,
225+
}
221226
err := c.Init()
222227
if err != nil {
223228
return 0, "", err
224229
}
225230

226-
c.Stdin = stdin
231+
c.Stdin = readline.NewCancelableStdin(c.Stdin)
227232

228233
if s.IsVimMode {
229234
c.VimMode = true

0 commit comments

Comments
 (0)