Just checking in on this.
Using KaVir's code seems to be pretty solid and works well for general telnet stuff. He had his own color code system implemented in the output routines itself, which I plan to disable (it's fine, but you guys probably don't want another different color code system).
Taking some tips from it, and from the LpMUD I'm working on, I've expanded my own color stuff a bit. It still needs some work, but right now I have xterm256 working properly. One idea I'd like to bounce off you guys is doing away with trying to manage output by flags and instead switch to a terminal type.
To clarify, right now I use the ANSI bitflag to determine if you want ANSI or not. I also check the MSDP data variable for XTERM256 support, and use that as another flag which overrides ANSI. So, you can have xterm256 on, or you can have ANSI on, or nothing. This gets messier the more conversions you have. Right now, I plant to support nothing, ansi, xterm-256color, xterm-greyscale, mxp, as well as use the same code for imc2 and i3/pinkfish output.
So, instead of a zillion flags, it would be smoother if the user could select a terminal type from a list. Using TTYPE, if we recognize the terminal, we can pick the best match. If not, we can default to either "unknown" or "ansi". The command ansi could just set your terminal type to "ansi", or you could have it take an argument like "xterm256" or "greyscale" or "mxp" to force a particular type of output.
Idears? You like? You no like? Lemme know.