mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.23k stars 243 forks source link

Request: spannable text? #239

Open jslater89 opened 8 years ago

jslater89 commented 8 years ago

It would be great to be able to set bold or underline on certain spans of text in a label, so I could emphasize certain parts of it without having to combine labels.

jslater89 commented 8 years ago

Alternately, implementing some ANSI escape codes in the Swing terminal might be easier, and that's probably something I'm capable of doing on my own.

mabe02 commented 8 years ago

I can see how this would be useful, but unfortunately, it's going to be pretty low on the priority list as it's a quite large task. Maybe you can override label or create a custom component to make it look the way you like?

avl42 commented 8 years ago

This consist of three parts:

  1. define a markup language. maybe some subset of html, or something simpler.
  2. write a renderer that would render the markup language into a TextImage.
  3. let components of lanterna accept a TextImage just like they accept a String now, and just do the simple parts of re-displaying that TextImage instead of drawing a String.

If lanterna could add just the "3.", then this would already help some users.

avl42 commented 8 years ago

Finally, that one TextImage could be changed to a sequence of TextImages (one for each word) to allow for word-wrapping lateron. Some special values in that sequence could be used for forced line breaks and other fancy formatting hints.