Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Feb 13, 2009 10:42 pm   

Rant about XTerm color codes
 
Since I'm trying to get a real version of TeSSH released, the next beta version of CMUD has a lot of new features and fixes for xterm and other emulation. One of these new features is XTerm 256 color support.

But I just had to post a rant about this. You can find details on XTerm control codes here: http://www.xfree86.org/current/ctlseqs.html

If you take the time to learn all of their jargon, you'll learn that in the 256 color mode of xterm, it recognizes ANSI codes of the form:
Code:
ESC [ 38 ; 5 ; xxx m

where "xxx" is a color index from 0 to 255. To set a background color, you use:
Code:
ESC [ 48 ; 5 ; xxx m

Now, I don't have any problem using the "38" and "48" codes, since they were previously not used by the normal ANSI color ESC[xxxm code sequence. However, what's the deal with the "5" in the sequence? That just seems to violate the way ANSI codes are supposed to be interpreted. The "5" code is normally used for "blinking" text. When parsing ANSI, multiple color codes are normally allowed. This allows us to normally blink and color text like this:
Code:
ESC [ 5 ; 32 m

(this example uses the 32 code for green text, and the 5 for blinking). So by "re-using" the 5 code, either xterm is violating the standard, or whoever decided to use 5 for blinking is violating the standard. But I think it's xterm that is wrong since normal ANSI/VT100 sequences like this are not supposed to be "context sensitive". In other words, the codes are supposed to be stand-alone and should not depend upon any previous codes in the sequence.

In any case, it makes parsing 256 color codes a real pain, since I had to kludge it to "undo" the blinking attribute.

I don't know...maybe some other program is already also using the 38 and 48 codes so xterm needed some way to distinguish it's extensions from someone elses. All I know is that there is some really odd stuff in the xterm spec that makes it look like the original creators didn't really know what they were doing, and we are stuck with dealing with it now.

Oh well. 256 color support works in CMUD/TeSSH 3.04 now, along with the codes for modifying the 256 color table from the server using another odd sequence of the format
Code:
ESC ] 4 ; xxx ; rgb:rr/gg/bb ESC \

Notice the ] instead of the [ and the obscure XParseColor color format.

Still on my list is the xterm mouse support if I can figure that out too. Otherwise I might wait till the next version for that.

Oh yeah, to use this new 256 color support from scripts, the %ansi function has been extended to allow xterm color codes in the form "xnnn" where nnn is the color index. For example:
Code:
#show %ansi(x100,x200)test

will display the "test" string using color index 100 for the foreground and color index 200 for the background. I'd probably stick to MXP color names if I were you, but this exists if you really need to output the xterm color string code for some reason.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net