There are plenty terminal color gems out there. Now, there is one more. Why?
What’s out there?
I’ve found about 14 miscellaneous ansi color string libraries with some quick searches on github and rubygems. However, about eight of them where using string extensions. This is not really suitable for library development.
The most interesting (and popular) ones are rainbow, which supports 256-color terminals, and term-ansicolor, which can be used very flexible without forcing string extensions. HighLine is another nice gem that’s capable of terminal colors, but it’s just a little part of something that maybe can be described as a “console io framework”.
My design goals
- Should not use string extensions by default
- Should support 256 colors
- Should have a consistent api that is easy to use
- Should allow applying multiple effects via one escape sequence, not by nesting (so red and bold is \e[31;1m not \e[31m\e[1m)
- Should provide a way to define custom color names (this also allows to get compatible with gems that use “wrong” color names, e.g. Wirb and Wirble)
- Should support setting any escape sequences, even if the current terminal does not support it
- Should stay as thin as possible
See the results at github.com/janlelis/paint ;)