Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Want ColorNone to preserve existing color(s) #606

Closed
StephanieSunshine opened this issue Apr 3, 2023 · 5 comments
Closed

Want ColorNone to preserve existing color(s) #606

StephanieSunshine opened this issue Apr 3, 2023 · 5 comments
Labels

Comments

@StephanieSunshine
Copy link

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)
@rockorager
Copy link
Contributor

@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.

@gdamore
Copy link
Owner

gdamore commented Dec 3, 2023

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.

@gdamore
Copy link
Owner

gdamore commented Dec 4, 2023

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?

@gdamore
Copy link
Owner

gdamore commented Dec 4, 2023

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

@gdamore
Copy link
Owner

gdamore commented Dec 8, 2023

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

@gdamore gdamore changed the title Is there a way to make SetContent use the existing background style for a location? Want ColorNone to preserve existing color(s) Dec 8, 2023
gdamore added a commit that referenced this issue Dec 8, 2023
While here, consolidate the use of the Fill() function from
CellBuffer (eliminating redundant code).
@gdamore gdamore closed this as completed in 337e381 Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants