nsf / termbox

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

Cleanup color output control and fix issue with background in other color mode than normal #73

Closed rikvdh closed 8 years ago

rikvdh commented 8 years ago

Hi,

I've changed the color output functions write_sgr to have only one color output mode. For 256 color-mode the background-color (when set to TB_DEFAULT) was emitting "\033[48;5;0m". When the actual background of your terminal isn't black it could interfere with the background-colors.

Also moving the switch-case from send_attr to write_sgr makes further maintenance on this behavior better instead of having the same switch-case twice in the same file. Also checking for TB_DEFAULT in write_sgr allows removal of the _bg and _fg functions.

See the following pictures. On the right is before my change, on the left includes my change. My small program writes 'x' to the screen with bg set to TB_DEFAULT and fg iterating over the colors.

colors

Kind regards,

Rik

nsf commented 8 years ago

Hm. The new code produces slightly more verbose output with normal mode, but I guess that's fine. I hope you know what you're doing, I'll merge it.