Don't write ANSI escape codes when writer is not a terminal.
Opened this issue · 0 comments
LennartC commented
Description
Cursor should check if the writer is a terminal or not, before writing the control characters.
To Reproduce
func main() {
cursor.Hide()
fmt.Print("Hello World!")
cursor.Show()
}
$ go run main.go > hello.txt
If you open hello.txt you'll see
\x1B[?25lHello World!\x1B[?25h
If the writer is not a terminal, the ANSI escape sequences shouldn't be written.
This is also the cause for pterm/pterm#518