Skip to content

Commit

Permalink
Make stdio configurable (#112)
Browse files Browse the repository at this point in the history
Make stdio configurable
  • Loading branch information
enmand authored Nov 29, 2019
2 parents cb50f5d + 868166a commit 8a7d472
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions select.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ type Select struct {

// A function that determines how to render the cursor
Pointer Pointer

Stdin io.ReadCloser
Stdout io.WriteCloser
}

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

func (s *Select) innerRun(cursorPos, scroll int, top rune) (int, string, error) {
stdin := readline.NewCancelableStdin(os.Stdin)
c := &readline.Config{}
c := &readline.Config{
Stdin: s.Stdin,
Stdout: s.Stdout,
}
err := c.Init()
if err != nil {
return 0, "", err
}

c.Stdin = stdin
c.Stdin = readline.NewCancelableStdin(c.Stdin)

if s.IsVimMode {
c.VimMode = true
Expand Down

0 comments on commit 8a7d472

Please sign in to comment.