mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Use correct output when enabling ANSI colors on Windows (see #39)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package tea
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
@@ -10,8 +11,13 @@ import (
|
||||
|
||||
// enableAnsiColors enables support for ANSI color sequences in Windows
|
||||
// default console. Note that this only works with Windows 10.
|
||||
func enableAnsiColors() {
|
||||
stdout := windows.Handle(os.Stdout.Fd())
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user