gdamore/tcell

Want ColorNone to preserve existing color(s)

StephanieSunshine opened this issue · 5 comments

Is it possible to tell SetContent via a special flag to use whatever the existing background color is at a location automatically with whatever foreground is set in the style. Example:

tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.Inherit)

@StephanieSunshine The closest you can do is a call to GetContent followed by SetContent:

_, _, style, _ := screen.GetContent(x,y)
screen.SetContent(...)

It looks like a tcell.Inherit color definition would be possible, since the Color type has a lot of extra bits available for flags.

As @rockorager says, you can retrieve the current style and modify it yourself. There is no convenience method for this. But maybe we can add something. I'm looking at ways to apply some style changes (specifically colors for now) to regions at a time. One can imagine a SetRegionForeground, SetRegionBackground, etc. This will probably be better for most use cases anyway.

Please see #579.

That's about lines, but if this could be on a region, and you could use StyleDefault with either just the foreground or the background (or for that matter just attributes), would that solve the need?

If it would, let's close this as a duplicate of #579.

Actually, I've decided to have ColorNone for this purpose, and to use this ticket for it.
I'll have a FillRegion later.