mirror of
https://github.com/rclone/rclone.git
synced 2024-11-27 02:34:21 +08:00
29 lines
553 B
Go
29 lines
553 B
Go
//+build windows
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"sync"
|
|
|
|
ansiterm "github.com/Azure/go-ansiterm"
|
|
"github.com/Azure/go-ansiterm/winterm"
|
|
)
|
|
|
|
var (
|
|
initAnsiParser sync.Once
|
|
ansiParser *ansiterm.AnsiParser
|
|
)
|
|
|
|
func writeToTerminal(b []byte) {
|
|
initAnsiParser.Do(func() {
|
|
winEventHandler := winterm.CreateWinEventHandler(os.Stdout.Fd(), os.Stdout)
|
|
ansiParser = ansiterm.CreateParser("Ground", winEventHandler)
|
|
})
|
|
_, err := ansiParser.Parse(b)
|
|
if err != nil {
|
|
_, _ = fmt.Fprintf(os.Stderr, "\n*** Error from ANSI parser: %v\n", err)
|
|
}
|
|
}
|