[GH-ISSUE #24] Support escape sequences #18

Closed
opened 2026-03-04 01:01:09 +03:00 by kerem · 2 comments
Owner

Originally created by @maja42 on GitHub (Jan 13, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/24

I'm using the io.Writer interface from the TextView and directly feed the stdout/stderr output from another application, which is started via the io.exec package.

This application prints standard linux escape sequences to change the text color. However, tview does not interpret this escape sequences and prints them as standard ascii characters.

Is it possible to use ansi escape sequences to define colors, or convert them to the appropiate color strings automatically?

Originally created by @maja42 on GitHub (Jan 13, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/24 I'm using the io.Writer interface from the TextView and directly feed the stdout/stderr output from another application, which is started via the io.exec package. This application prints standard linux escape sequences to change the text color. However, tview does not interpret this escape sequences and prints them as standard ascii characters. Is it possible to use ansi escape sequences to define colors, or convert them to the appropiate color strings automatically?
kerem closed this issue 2026-03-04 01:01:09 +03:00
Author
Owner

@rivo commented on GitHub (Jan 14, 2018):

To my knowledge, I can't just write escape sequences to tcell. It always wants a tcell.Color. I do have color tags in the TextView such as [red] or [#ff00ff]. I decided to do this instead of escape sequences (like gocui) because it allows me to add color easily without having to google all the cryptic codes needed to change a color.

For your application, you could implement a io.Writer which translates escape sequences to these color tags. I might include something like that in the package at some point (can't tell you when, though).

<!-- gh-comment-id:357510988 --> @rivo commented on GitHub (Jan 14, 2018): To my knowledge, I can't just write escape sequences to `tcell`. It always wants a `tcell.Color`. I do have color tags in the `TextView` such as `[red]` or `[#ff00ff]`. I decided to do this instead of escape sequences (like `gocui`) because it allows me to add color easily without having to google all the cryptic codes needed to change a color. For your application, you could implement a `io.Writer` which translates escape sequences to these color tags. I might include something like that in the package at some point (can't tell you when, though).
Author
Owner

@rivo commented on GitHub (Apr 13, 2018):

As a heads up, tview now has functions that can translate ANSII escape codes to color tags. The Wiki also has an example for how colorized output from other programs can be piped into tview: https://github.com/rivo/tview/wiki/ANSII

<!-- gh-comment-id:381273237 --> @rivo commented on GitHub (Apr 13, 2018): As a heads up, `tview` now has functions that can translate ANSII escape codes to color tags. The Wiki also has an example for how colorized output from other programs can be piped into `tview`: https://github.com/rivo/tview/wiki/ANSII
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#18
No description provided.