nsf / termbox

Library for writing text-based user interfaces
http://code.google.com/p/termbox
MIT License
1.96k stars 185 forks source link

TB_OUTPUT_256: Cannot use black / write CSI 38;5;0 #114

Open ljrk0 opened 6 years ago

ljrk0 commented 6 years ago

The current implementation treats the value 0 (=TB_DEFAULT) for fg/bg special in write_sgr(). This leads to much unexpected behavior, for once, one cannot use the TB_* constants with this mode anymore.

Color TB_OUTPUT_NORMAL TB_OUTPUT_256
clear 0 0
black 1 -
red 2 1
... ... ...

What seems to be the most sensible but also most radical solution to me would be:

  1. Make the TB_* constants line up with the actual values used ain SGR, ie. 0 for black etc.
  2. Set TB_DEFAULT to a different magic value that's not used anywhere and catch that, if we are breaking, we could actually use -1 and use int16_t instead.
  3. In fact, if we wanted to at some point support truecolor, we should perhaps even make it a bigger value.

Also I've found that the code uses the TB_BOLD constant for bg to encode "blinking", which should be documented.