Closed grayswandyr closed 4 years ago
I think that you could have colors right now (by using CCFormat.sprintf
with colored tags) but it would break the layout because the string would take less space than expected (the chars part of the ANSI code would count in the expected size, but not in actual screen space). It's probably more realistic to have styling directly in printbox (colored boxes), even if it's less flexible. I have no better solution right now.
You mean colored backgrounds for boxes? If so, that would indeed already be nice. I print chronograms as tables and my aim is to outline cells that contain data whose value differs from the previous one.
Yeah, something like that (or colored text); both should be actually possible, the point is that printbox must be aware of the formatting.
Other argument: there is also a html backend (where colors should be handled natively with inline style).
Would you be interested in contributing this? The simplest way would be to add a Set_fg_color of t * color | Set_bg_color of t * color
to Printbox.t
, and handle these properly in both backends.
Though the set_color
option seems the simplest to implement, I'd like to also have optional arguments for the box constructors.
In order to avoid having too many arguments (colors, bg_color, bold/italic, etc...), I think we could take inspiration from what is done in notty (cf http://pqwy.github.io/notty/doc/Notty.A.html#TYPEstyle ), which defines a 'style' type, with combinators.
@c-cube In principle I would answer positively but I don't think I have the necessary combination of available time and understanding of the library as well as of terminal manipulation. Hence I'll pass here, sorry.
Thanks for this useful package. It would be great to be able to apply styles (bold, italic) or colors on specific boxes; or to have boxes preserve the style of strings inside them (set with libraries such as CCFormat or Fmt).