Evennia, ANSI and Xterm256¶
All modern MUD clients support colors; nevertheless, the standards to which all clients abide dates back to old day of terminals, and when it comes to colors we are dealing with ANSI and Xterm256 standards.
Evennia handles transparently, behind the scenes, all the code required to enforce these standards—so, if a user connects with a client which doesn’t support colors, or supports only ANSI (16 colors), Evennia will take all due steps to ensure that the output will be adjusted to look right at the client side.
As for you, the developer, all you need to care about is knowing how to correctly use the color tags within your MUD. Most likely, you’ll be adding colors to help pages, descriptions, automatically generated text, etc.
You are free to mix together ANSI and Xterm256 color tags, but you should be aware of a few pitfalls. ANSI and Xterm256 coexist without conflicts in Evennia, but in many ways they don’t «see» each other: ANSI-specific color tags will have no effect on Xterm-defined colors, as we shall see here.
ANSI has a set of 16 colors, to be more precise: ANSI has 8 basic colors which come in dark and bright flavours—with dark being normal. The colors are: red, green, yellow, blue, magenta, cyan, white and black. White in its dark version is usually referred to as gray, and black in its bright version as darkgray. Here, for sake of simplicity they’ll be referred to as dark and bright: bright/dark black, bright/dark white.
The default colors of MUD clients is normal (dark) white on normal black (ie: gray on black).
It’s important to grasp that in the ANSI standard bright colors apply only to text (foreground), not to background. Evennia allows to bypass this limitation via Xterm256, but doing so will impact the behavior of ANSI tags, as we shall see.
Also, it’s important to remember that the 16 ANSI colors are a convention, and the final user can always customize their appearance—he might decide to have green show as red, and dark green as blue, etc.
The 16 colors of ANSI should be more than enough to handle simple coloring of text. But when an author wants to be sure that a given color will show as he intended it, she might choose to rely on Xterm256 colors.
Xterm256 doesn’t rely on a palette of named colors, it instead represent colors by their values. So,
a red color could be
|[500 (bright and pure red), or
|[300 (darker red), and so on.