[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Perl Programmers Reference for Color Codes (some historicalcommentary)
Note: While most of what I'm posting is my personal opinion, it has at
least been formed from long-experience with IRC clients in general
dating from before even BitchX existed as anything other than a fancy
script for ircII. This having been said, there are some things here
that script authors should definitely keep in mind when writing lines
that output text to remote clients and not just the local user's
display. Pardon the address munging as well--I'm trying to avoid being
inundated with spam.
On Sat, 2003-01-11 at 18:36, 1-hop Sales wrote:
> Thanks to all that replied...
>
> The diversity of replies clearly indicates that a reference document or
> information would be helpfull to all.
> I do understand the numeric codes for the colors since they are listed under
> the Settings >> Palette command in Xchat.
> But I was also interested in the block colors, underline, etc..
>
> In any event here is a short summary of of some of the replies. Hope others
> find them helpful as well. For those of you using the trial and error
> method please add to this list of codes as you find new ones.
>
> Here are some of the decoration codes:
> ======================================
> When using the Perl API for Xchat use the \XXX, in a chat window use the %X.
> \002 %B bold
> \00307 %C07 foreground colour
> \00307,00 %C07,00 foreground and background colour
> \017 %O reset
> \026 %R reverse foreground and background
> \037 %U underline
> * I have not tried it but my guess is that in those lines with \003?? above
> only the \003 represents the type of decoration and the '07' and '07,00'
> represent the colors themselves. Originally from lennart.
This makes things sound somewhat more complex than they really are.
Most of these codes were "brought over" from VT52/VT100 control codes.
Control codes that fall specifically into this category would be Bold
(^B), Underline (^U), and Italics (memory is fuzzy on this one because
it was much more rarely used, although I think it was ^I), and
everyone's absolute nemesis code, Bell (^G). These three codes were
rather widely used by ircII scripts around the time mIRC first appeared
on the scene, mainly for beautifying messages sent to the user's display
although Bold was by far the most commonly used control code. I don't
think Reverse was used very often, if at all. (This was LONG time ago.
I don't remember seeing it used and I'm no longer sure if VT52/VT100 had
provisions for this.) In any case, if someone is going to use Reverse,
they should cross their fingers and hope that the client on the other
end will interpret them properly and use a second ^R as a cue that
reverse mode should be turned off. I wouldn't count on ^O working for
anything other than X-Chat (and possibly mIRC) although BitchX and ircII
might well have put something in to recognize it by now, this _really_
passes a bit beyond their scope, since the other codes work reliably
merely by being passed straight to the user's display program (Telix,
Procomm, whatever). Folks, let's not get into the habit of writing
scripts that output to remote clients codes that their terminals aren't
likely to interpret properly--if you're already going to use ^C color
codes, you might consider simply switching the numbers around to get
your reversed-text.
Since most people were not using Xterms then, but rather, DOS-based
terminal programs like Telix and Procomm and whatnot using ANSI
emulation (or at the very least VT52/VT100) the use of Bold and Italics
could at least be counted on to give the script author the ability to
make text appear in three different ways (commonly white for normal,
yellow for bold, and blue for italics) without running the risk of the
codes being misinterpreted/ignored by the client. ANSI codes didn't
particularly endear you to channel operators because these could be used
to cause *serious* havoc for people who actually used ANSI emulated
displays, so most clients would summarily strip out anything that looked
like the ANSI escape sequence, leaving otherwise colorful output riddled
with curious left brackets, random digits, and semicolons. If you
thought having your terminal "flashed" was bad, there are far worse
things that could be done by someone who knew ANSI escapes well enough
(remapping keys, Enter being a good target, inserting character
sequences into the *input* buffer, etc.) In truth, in _many_ channels
daring to spew out an ANSI sequence would be an automatic kickban.
> Here are some of the color codes:
> =================================
> Xchat supports a Palette of 16 colors (0-15)that are user definable (the
> colors themselves, not the number of colors in the palette).
> The default color palette in xchat is as follows:
> Color 0 $lightgrey = 0
> Color 1 $black = 1
> Color 2 $royalblue = 2
> Color 3 $green = 3
> Color 4 $red = 4
> Color 5 $marroon = 5
> Color 6 $purple = 6
> Color 7 $orange = 7
> Color 8 $yellow = 8
> Color 9 $lightgreen = 9
> Color 10 $darkcyan = 10
> Color 11 $cyan = 11
> Color 12 $darkblue = 12
> Color 13 $indigo = 13
> Color 14 $darkgrey = 14
> Color 15 $mediumgrey = 15
Somewhere on the mIRC site (although definitely in the client help
documentation--I had to look them up once) these are listed. Much to my
(and almost everyone else's annoyance) the dratted things don't quite
follow along with the sequence ANSI-defined colors everyone was used to
using. (I'm not arguing your list, I just don't want anyone to assume
these colors are the same as what a normal xterm/ANSI client is capable
of displaying.) I think his color choices were based on what Windows
chose as basic colors for those souls damned to a 16-color display.
When Khaled's idea of color codes first appeared in mIRC, there
definitely was a great wailing and gnashing of teeth about it
specifically because they didn't correspond to anything the majority of
IRCers used. (Although most of IRC is filled with "mIRC lamers" now,
they used to be far, far in the minority.)
...and of course we still have the fundamental difference that mIRC
traditionally uses black text on a white background, while Unix people
still typically prefer things the other way around. Invoking either
black or white directly in a ^C code can cause "issues" for people whose
clients don't kludge around it. (Khaled took quite awhile to recognize
this was an easily abuseable trick to annoy mIRC users.) I'm aware this
can plague X-Chat as well, but in light of transparency and background
pixmaps I don't see it as an _elegantly_ solvable problem compared to
the simplicity of the user merely redefining 6F black and 6F white on
their own based on whatever they're using as a background to channel
text.
> To use them with Perl you first specify a decoration code from the list
> above followed by a one or two digit color code. For example the code
> '\0034' results in text(foreground) color red - \003=foreground color,
> 4=red.
>
> One reply had color codes greater than 16 which will still work, but Xchat
> still only uses the 16-color color palette. For example the code '$red =
> "\00320" still results in red because 20-16=4 which is red in the default
> palette.
(list snipped)
I'm not sure why they listed those colors with high numbers, and you are
mainly correct in that all the numbers are effectively AND'd with 15.
Additionally, the numbers do not need to be zero-padded. (I can only
roll my eyes in response if Khaled has changed his client to require
they be zero-padded.)
--
XChat-perl: mailing list for XChat perl scripters
Archive: http://mail.nl.linux.org/xchat-perl/