mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
feat: use Termenv.Output to write to tty
This commit is contained in:
@@ -4,11 +4,9 @@
|
||||
package tea
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/containerd/console"
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func (p *Program) initInput() error {
|
||||
@@ -26,8 +24,6 @@ func (p *Program) initInput() error {
|
||||
p.console = c
|
||||
}
|
||||
|
||||
enableAnsiColors(p.output)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -49,18 +45,3 @@ func openInputTTY() (*os.File, error) {
|
||||
}
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// enableAnsiColors enables support for ANSI color sequences in Windows
|
||||
// default console. Note that this only works with Windows 10.
|
||||
func enableAnsiColors(w io.Writer) {
|
||||
f, ok := w.(*os.File)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
stdout := windows.Handle(f.Fd())
|
||||
var originalMode uint32
|
||||
|
||||
_ = windows.GetConsoleMode(stdout, &originalMode)
|
||||
_ = windows.SetConsoleMode(stdout, originalMode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user