expand ANSI color support

adds support for 256 colors

does not yet add support for themed 16-color mapping ([01;38;5;[0-15]),
but the rest of 256-color should work.

It should also improve the handling of unrecognized color escapes (stripping, rather than leaving untouched).

Definitely needs testing, as the 256-color support is a bit complicated (ping @ivanov).

There is one related benefit that I was able to get this into a single replace call with regular expressions,
rather than a sequence of replacements, so it might be faster than before.

closes #3617