freebsd-dev/sys/teken
Bruce Evans 2610c9f2b2 Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color
codes.  This will be used to fix bright colors.

Improve teken_256to8().  Use a lookup table instead of calculations.  The
calculations were inaccurate since they used indexes into the xterm-256
6x6x6 color map instead of actual xterm colors.  Also, change the threshold
for converting to a primary color: require the primary's component to be
2 or more higher instead of just higher.  This affects about 1/5 of the
table entries and gives uniformly distributed colors in the 6x6x6 submap
except for greys (35 entries each for red, green, blue, cyan, brown and
magenta, instead of approx. only 15 each for the mixed colors).  Even
more mixed colors would be better for matching colors, but uniform
distribution is best for preserving contrast.

For teken_256to16(), bright colors are just the ones with luminosity >=
60%.  These are actually light colors (more white instead of more
saturation), while xterm bright colors except for white itself are
actually saturated with no white, so have luminosity only 50%.

These functions are layering violations.  teken cannot do correct
conversions since it shouldn't know the color maps of anything except
xterm.  Translating through xterm-16 colors loses information.  This
gives bugs like xterm-256 near-brown -> xterm-16 red -> VGA red.
2017-03-16 16:40:54 +00:00
..
demo
libteken Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color 2017-03-16 16:40:54 +00:00
stress
gensequences
sequences
teken_scs.h
teken_subr_compat.h
teken_subr.h Sync HPA and VPA implementations with CUP. 2015-08-24 07:49:27 +00:00
teken_wcwidth.h
teken.c Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color 2017-03-16 16:40:54 +00:00
teken.h Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color 2017-03-16 16:40:54 +00:00