cursor icon indicating copy to clipboard operation
cursor copied to clipboard

Don't write ANSI escape codes when writer is not a terminal.

Open LennartC opened this issue 2 years ago • 0 comments

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 https://github.com/pterm/pterm/issues/518

LennartC avatar Nov 16 '23 16:11 LennartC