mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Fix Windows stuff related to the refactor at 49a5d16
This commit is contained in:
3
tea.go
3
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 {
|
||||
|
||||
6
tty.go
6
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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user