mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #314] Set transparent background for TreeView #240
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#240
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 @robinmitra on GitHub (Jun 19, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/314
Context
I'm trying to set the background colour of a TreeView widget to be transparent (i.e. the default terminal background).
I've gone through the documentation and past issues but was unable to find a solution which works properly. The following code does make the background transparent, but selecting a different node completely messes up the background colour.
The following images should explain the issue better:
For reference, this is how the same tree looks like without setting the background colour to default like done above (if you look closely, you can basically see how the tree background is black, but the edges of my terminal are dark blue, which is made apparent by the fact that my terminal has padding added):
Question
How do I set the background colour of a TreeView to be transparent? Am I doing this wrong?
@rivo commented on GitHub (Jul 10, 2019):
The `tcell.ColorDefault´ description says:
So the background colour doesn't get cleared when you use
tcell.ColorDefault. This is why you're seeing those effects. I would advise against using that value.tviewneeds to clear the background and it needs a concrete colour for that.I actually don't know how you can find out what your terminal's default background colour is and whether this is exposed to applications at all. I would suggest asking about that over at the
tcellproject and letting us know here when you have an answer.@robinmitra commented on GitHub (Jul 18, 2019):
Thanks for looking into it, I've asked a question in the
tcellproject.@gdamore commented on GitHub (Jul 18, 2019):
I actually think for some terminals we should be able to clear the background color to the default background color. For example, XTerm supports the notion of resetting that.
@rivo commented on GitHub (Jul 21, 2019):
I understand (except maybe on Windows) there is no way to find out what the default colour is. Maybe we can clear a screen to the default background colour on some terminals. But we do want to avoid clearing and redrawing the entire screen each time something changes.
So all in all, my feeling is that there is no acceptable solution at the moment.
@rivo commented on GitHub (Aug 29, 2019):
Will close for now as we don't know of any good solution to this.
@gdamore commented on GitHub (Aug 29, 2019):
Actually, I think this might be a bug in tcell. Some terminals have escape sequences to set the default color on a cell -- we aren't using those, but simply assuming that Default means no change to whatever is already there.
I'm not sure what the best semantic here is though -- people might be relying on the current semantic.
@rivo commented on GitHub (Aug 29, 2019):
If there was something like
tcell.ColorBackground(for the terminal's default background colour, often black) andtcell.ColorForeground(for the terminal's default foreground color, often white), that would be quite nice as it wouldn't force a specific theme on everyone. Of course,tcell.ColorDefaultwould still exist, it would still mean "don't change the color".@blefevre commented on GitHub (Jan 24, 2020):
While waiting for some progress on https://github.com/gdamore/tcell/issues/314 which will hopefully address this, I was able to workaround the issue of using
tcell.ColorDefaultby clearing the screen before each draw: