Color and escape codes in text/gemini
Brian Evans b__m__e at mailfence.com
Fri Dec 13 00:27:07 GMT 2019
This is interesting timing. Bombadillo v1.x supported printing any escape codes it received.
With 2.0.0 we eliminated that support in favor of filtering out escape codes (likely in a naive
but mostly functional way andy time `\033` is encountered anything that follows it until a
`[A-Za-z]` character is reached will not be rendered (including the terminal character that
ends the sequence). That is where things stand with Bombadillo's mainline release right
now.
However, there has been an issue in our backlog for awhile now to reinstate color. I worked
on this a bit over the last week and have done the following:
I have added a "theme" (previoiusly there was only 'normal' and 'inverse') called 'color'. This
theme looks identical to the normal theme, except it will render the escape sequences. This
approach allows the user to move in and out of this rendering at will. If something doesnt
look right in `color` mode they can always switch to `normal` mode. Sadly, color is not
compatible with `inverse` mode since I use escape sequences to achieve the inverse effect
and it is immediately removed anyone tosses out a `\033[0m`.
I am kind of opposed to developing any syntax for text/gemini that would treat escape
sequences any differently than any other text. Clients can choose how and if to implement
escape codes in a way that makes sense to them and their user-base. I think most clients
will be well served taking Sean's approach of filtering out escape codes.
For those wanting to keep clients lightweight a simple string replace for `\033` to any other
character (maybe a box?) will make the escape codes not render, but still show document
intent. This is REALLY easy to implement in just about any language.
I really like the usage of color on cat's recent page and hope to see more people using
color. I do 100% agree with Sean though that using color is often presumptuous and I have
ran into issues where my terminal's bg color did not mesh well at all with the colors being
used by an application (which is partly why bombadillo's tui does not use colors, only
inversion).
I also agree with Sean (it seems to be happening a lot this time around) that getting
closer to an answer on reflow eventually would be a good idea. As it stands I am
wrapping but doing no reflow whatsoever.
--?
Sent with https://mailfence.com
Secure and private email
Archive home | About this archive