[GH-ISSUE #520] Use of "[-:-:-]" resets to the terminal's background colour not TextView's background colour #377

Closed
opened 2026-03-04 01:04:28 +03:00 by kerem · 5 comments
Owner

Originally created by @berrange on GitHub (Nov 4, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/520

Consider the following code snippet:

package main

import (
	"github.com/rivo/tview"
)

func main() {
	app := tview.NewApplication()
	textView := tview.NewTextView().
		SetDynamicColors(true)
	textView.SetText("Hello [red:green:]world[-:-:-] again")
	if err := app.SetRoot(textView, true).Run(); err != nil {
		panic(err)
	}
}

I was expecting this to display "Hello" and "again" using the default TextView colour scheme producing white text on black backround, and "world" using red text, green background.

What actually happens though is that "again" is displayed white text, light gray background. The "white" text is the TextView colour scheme, but the "light gray" appears to be my terminal's default background colour.

Am I misunderstanding what "-" means? I was expecting it t reset to TextView's default background colour, not my terminal's default background colour.

Originally created by @berrange on GitHub (Nov 4, 2020). Original GitHub issue: https://github.com/rivo/tview/issues/520 Consider the following code snippet: ``` package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() textView := tview.NewTextView(). SetDynamicColors(true) textView.SetText("Hello [red:green:]world[-:-:-] again") if err := app.SetRoot(textView, true).Run(); err != nil { panic(err) } } ``` I was expecting this to display "Hello" and "again" using the default TextView colour scheme producing white text on black backround, and "world" using red text, green background. What actually happens though is that "again" is displayed white text, light gray background. The "white" text is the TextView colour scheme, but the "light gray" appears to be my terminal's default background colour. Am I misunderstanding what "-" means? I was expecting it t reset to TextView's default background colour, not my terminal's default background colour.
kerem closed this issue 2026-03-04 01:04:28 +03:00
Author
Owner

@rivo commented on GitHub (Nov 18, 2020):

I cannot reproduce this:

image

Is this with the latest version of tview?

<!-- gh-comment-id:729459282 --> @rivo commented on GitHub (Nov 18, 2020): I cannot reproduce this: ![image](https://user-images.githubusercontent.com/480930/99492911-a8332e80-296e-11eb-8aef-98f219ff0734.png) Is this with the latest version of `tview`?
Author
Owner

@berrange commented on GitHub (Nov 18, 2020):

Yes, same scenario as my other issue #521, I'm using latst tview git as of right now, with Fedora 33, x86_64, with GNOME Terminal (gnome-terminal-3.38.1-1.fc33.x86_64).

Normally I'm using a white-ish background, and black text, but for this screenshot I've set my terminal background to pink, to make it obvious that the borders are inheriting the terminal's default background colour instead of any tview colour theme:
tview-text

<!-- gh-comment-id:729552457 --> @berrange commented on GitHub (Nov 18, 2020): Yes, same scenario as my other issue #521, I'm using latst tview git as of right now, with Fedora 33, x86_64, with GNOME Terminal (gnome-terminal-3.38.1-1.fc33.x86_64). Normally I'm using a white-ish background, and black text, but for this screenshot I've set my terminal background to pink, to make it obvious that the borders are inheriting the terminal's default background colour instead of any tview colour theme: ![tview-text](https://user-images.githubusercontent.com/1517315/99511646-74f99b00-2980-11eb-8c9c-0d174f735a90.png)
Author
Owner

@rivo commented on GitHub (Mar 12, 2021):

It turns out that the definition of tcell.ColorDefault has changed. It used to mean "transparent". So when you used this as a background colour somewhere, it would not change the existing background colour. Now it's different: It means "the terminal's default background colour". So it will always overwrite the background colour on screen.

So the assumptions made in tview were now wrong, especially when I instantiated a new tcell.Style object (it gets tcell.ColorDefault as its default colours and it doesn't mean "transparent" anymore).

The latest commit should get rid of all the side effects of this tcell change. Please upgrade and let me know if it works as expected now.

<!-- gh-comment-id:797659408 --> @rivo commented on GitHub (Mar 12, 2021): It turns out that the definition of [`tcell.ColorDefault`](https://pkg.go.dev/github.com/gdamore/tcell/v2#ColorDefault) has changed. It used to mean "transparent". So when you used this as a background colour somewhere, it would not change the existing background colour. Now it's different: It means "the terminal's default background colour". So it will always overwrite the background colour on screen. So the assumptions made in `tview` were now wrong, especially when I instantiated a new [`tcell.Style`](https://pkg.go.dev/github.com/gdamore/tcell/v2#Style) object (it gets `tcell.ColorDefault` as its default colours and it doesn't mean "transparent" anymore). The latest commit should get rid of all the side effects of this `tcell` change. Please upgrade and let me know if it works as expected now.
Author
Owner

@mevdschee commented on GitHub (Mar 12, 2021):

This seems fixed to me. See: https://github.com/rivo/tview/issues/519#issuecomment-797680773

<!-- gh-comment-id:797686406 --> @mevdschee commented on GitHub (Mar 12, 2021): This seems fixed to me. See: https://github.com/rivo/tview/issues/519#issuecomment-797680773
Author
Owner

@rivo commented on GitHub (Mar 12, 2021):

Sounds good, thank you.

<!-- gh-comment-id:797731325 --> @rivo commented on GitHub (Mar 12, 2021): Sounds good, thank you.
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#377
No description provided.