gyscos / cursive

A Text User Interface library for the Rust programming language
MIT License
4.31k stars 247 forks source link

[Suggestion] Add Effects to themes Palette or HighlightText #305

Open Inrin opened 5 years ago

Inrin commented 5 years ago

Problem description

I'm creating my own theme. There I'd prefer to have highlighting less verbose. Thus I'm trying to Reverse the highlighting colors, meaning the text itself gets highlighted (changes to the Highlighting color and the background is kept.)

Code example

See the examples SelectView and Theme*

Environment

Proposal

Easiest would be to change ColorStyle::highlight()s foreground to Background to allow a bit flexiblity.

Other more complex solutions could be allowing to introduce custom variants used then set or binding custom colors to them. (This sounds messy)

Another variant would be to just change them from Color -> Colorstyle in the palette. This would break the current TOML-Theme-Syntax but streamlines Palette/ColorStyles.

You might have other/better ideas.

PS

I'm a beginner at rust, so please excuse if I've overseen something completely obvious.

gyscos commented 5 years ago

Hi, and thanks for the report!

This is a very good point; highlighting is currently not very flexible.

Note that Background is not whichever background was used for this text, it's the color of the background of the entire application (blue in the default theme).

One easy solution is to add a color to the palette, so we can control both colors of the Highlight style (right now you can control the background, but the foreground is always the view's background color, so it would not be readable if you set Highlight to the same color as View).

Adding effects to themes could also be interesting, but a bit more complex and with different benefits (it would mostly enable bold or italic text).

gyscos commented 1 year ago

Hi!

It's been a while, but a recent commit brings the ability to customize the entire style used for things like highlighting.

For the "Highlight" palette style, you can use a style with no "reverse" effect, InheritParent as background, and your accent color as foreground, and it should do the trick.