Open robinkrahl opened 4 years ago
Hi again!
I think there are two separate potential improvements:
There's also the more conceptual question "is style attached to the text content, or to the view itself?".
Some of this point to hierarchy of applied styles, maybe closer to CSS. I don't have a very clear idea of how to get there though, and the two improvements I mentioned are not exactly trivial to add (especially the second one), so for now having a dedicated style for the TextView
itself which is merged with the content is perfectly fine.
Alternatively, there could be a StyledView
that wraps an arbitrary view and applies a style to the printer before drawing it, maybe together with a Styleable
trait.
On the latest commit there is now a set_style
option to TextView
.
We'll see later for a more general solution.
This is a both a question and a feature request.
Problem description
I saw the
TextView::set_effect
method and wanted to have aset_style
method too. I was about to implement it when I saw your comment intext_view.rs
:So I wanted to discuss this here first.
Yes, the user can just set the content to a styled string instead of setting the effect or style for the text view. But for views that are created once and then updated regularly and from multiple code locations (e. g. a status bar), it is useful to have a way to set a default style for the view. So I think it would make sense to keep the
set_effect
method and to even add aset_style(Into<Style)
method. (Theset_effect
method could also be dropped in favor ofset_style
.) What do you think?