diff --git a/tea.go b/tea.go index 689b701..f32e82f 100644 --- a/tea.go +++ b/tea.go @@ -371,9 +371,8 @@ func (p *Program) Start() error { }() } - // Is output a terminal? if f, ok := p.output.(*os.File); ok { - // Get initial terminal size + // Get initial terminal size and send it to the program go func() { w, h, err := term.GetSize(int(f.Fd())) if err != nil { diff --git a/tty.go b/tty.go index c8cf968..c9006cc 100644 --- a/tty.go +++ b/tty.go @@ -1,11 +1,5 @@ package tea -import ( - "errors" -) - -var errInputIsNotAFile = errors.New("input is not a file") - func (p *Program) initTerminal() error { err := p.initInput() if err != nil { diff --git a/tty_windows.go b/tty_windows.go index 7f1ce23..ad432d5 100644 --- a/tty_windows.go +++ b/tty_windows.go @@ -11,28 +11,19 @@ import ( ) func (p *Program) initInput() error { - if !p.inputIsTTY { - return nil - } - - // If input's a TTY this should always succeed. - f, ok := p.input.(*os.File) - if !ok { - return errInputIsNotAFile - } - - if p.inputStatus == managedInput { + // If input's a file, use console to manage it + if f, ok := p.input.(*os.File); ok { // Save a reference to the current stdin then replace stdin with our // input. We do this so we can hand input off to containerd/console to // set raw mode, and do it in this fashion because the method // console.ConsoleFromFile isn't supported on Windows. p.windowsStdin = os.Stdin os.Stdin = f - } - // Note: this will panic if it fails. - c := console.Current() - p.console = c + // Note: this will panic if it fails. + c := console.Current() + p.console = c + } enableAnsiColors(p.output)