Skip to content

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

@LennartC

Description

@LennartC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions