mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #24] Support escape sequences #18
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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?
@rivo commented on GitHub (Jan 14, 2018):
To my knowledge, I can't just write escape sequences to
tcell. It always wants atcell.Color. I do have color tags in theTextViewsuch as[red]or[#ff00ff]. I decided to do this instead of escape sequences (likegocui) 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.Writerwhich 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).@rivo commented on GitHub (Apr 13, 2018):
As a heads up,
tviewnow 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 intotview: https://github.com/rivo/tview/wiki/ANSII