gyscos / cursive

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

Styling of TextArea #362

Open bob1de opened 5 years ago

bob1de commented 5 years ago

Hi,

First, thanks for this great library. It turned out to be quite difficult to find a well-matured TUI toolkit which feels more comfortable to use than ncurses directly.

I'm aiming at getting fairly basic multiline string editing embedded into a CLI-based password manager and wanted to use TextArea for that purpose. However, it seems like TextArea, in contrast to EditView, doesn't support setting the colors to use. Do I just miss something or is this simply not implemented and/or desired?

Thanks in advance.

Best regards Robert

gyscos commented 5 years ago

Hi, and thanks for the report!

Indeed, TextArea currently has limited styling options. For now it would be easy to give it a style parameter so it could at least color the text differently.

There are two related long-term ideas I had:

The second one in particular is probably quite a long time away, but the first one may be doable soon~ish.

bob1de commented 5 years ago

Indeed, TextArea currently has limited styling options. For now it would be easy to give it a style parameter so it could at least color the text differently.

Yes, that would be great!

There are two related long-term ideas I had:

* Have "sub-tree theme override" where you have some wrapper view that uses a modified theme for its subtree. Using this, you could just wrap `TextArea` in such a view where the basic `Primary` color maps to something else.

TBH, I find the theme subsystem a little complex in general. I just want to have white text on black background and white panel borders, and this alone drives me crazy with an EditView and TextArea in the same panel, because the input field content always has the same color as the panel in which the inputs reside. I don't know whether that idea would make it less or even more complex than it is right now...

* Have a fully-styled `TextArea` where you could have styled text (colored, bold, underlined, ...) in a kind of WYSIWYG editor. Maybe a code editor with syntax highlighting?

Hmm, if you can think of a good API for such functionality, why not, but I can imagine that things will become rather complex, especially with string representations and cursor positioning.

The second one in particular is probably quite a long time away, but the first one may be doable soon~ish.

I'm still very new to Rust though, but I could test something when it's available.

gyscos commented 3 years ago

In the latest commit I added a ThemedView: it lets you wrap any view and apply a different theme to it.

Right now you have to specify a full theme (so you'd usually take the current theme, and apply modifications to it - see the themed_view example).

In the future you might be able to define theme overlays that only override a few values, but that's for later.