[GH-ISSUE #140] Can't correctly print ANSI #110

Closed
opened 2026-03-04 01:02:01 +03:00 by kerem · 1 comment
Owner

Originally created by @guitmz on GitHub (Jul 20, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/140

Hey, great job with tview! I wonder if you can help me.

I'm trying to write ANSI to a textview and I had little success (even using the ls example in the wiki).

Basically the output looks like this:

[:000000:d][000000::d]▄[:000000:d][000000::d]▄[f3952a:green:d]▄[blue:c37722:d][aa661d:#00ff00:d]▄▄[f8922a:green:d]▄

where there is a BG color, I can see it rendered but the color codes remain in the screen. My code:

px := renderPixels() // this returns ANSI strings such as "\033[48;2;255;0;152m▄"
app := tview.NewApplication()
	textView := tview.NewTextView().
		SetDynamicColors(true).
		SetChangedFunc(func() {
			app.Draw()
		})
	textView.SetBorder(true).SetTitle("Stdin")
	go func() {
		w := tview.ANSIWriter(textView)
		fmt.Fprint(w, px)
	}()
	if err := app.SetRoot(textView, true).Run(); err != nil {
		panic(err)
	}

Here`s a screenshot of part of the output for reference

Am I missing something?

Thanks in advance.

Originally created by @guitmz on GitHub (Jul 20, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/140 Hey, great job with tview! I wonder if you can help me. I'm trying to write ANSI to a textview and I had little success (even using the `ls` example in the wiki). Basically the output looks like this: ``` [:000000:d][000000::d]▄[:000000:d][000000::d]▄[f3952a:green:d]▄[blue:c37722:d][aa661d:#00ff00:d]▄▄[f8922a:green:d]▄ ``` where there is a BG color, I can see it rendered but the color codes remain in the screen. My code: ```go px := renderPixels() // this returns ANSI strings such as "\033[48;2;255;0;152m▄" app := tview.NewApplication() textView := tview.NewTextView(). SetDynamicColors(true). SetChangedFunc(func() { app.Draw() }) textView.SetBorder(true).SetTitle("Stdin") go func() { w := tview.ANSIWriter(textView) fmt.Fprint(w, px) }() if err := app.SetRoot(textView, true).Run(); err != nil { panic(err) } ``` Here`s a screenshot of part of the output for reference ![](https://i.imgur.com/kBQL9Pj.png) Am I missing something? Thanks in advance.
kerem closed this issue 2026-03-04 01:02:02 +03:00
Author
Owner

@rivo commented on GitHub (Jul 27, 2018):

I just committed a fix for this. Could you please try again and let me know if it solves your problem?

<!-- gh-comment-id:408401328 --> @rivo commented on GitHub (Jul 27, 2018): I just committed a fix for this. Could you please try again and let me know if it solves your problem?
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#110
No description provided.