Sunday, 3 March 2013

Output Formatting

One of the things I've done so far is to write a formatter library that will - eventually - be driven by TermInfo and Charset data retrieved from the connection. (Currently it's hard-coded, which is bad but easy). The idea here is that everything in the MUD itself can then output messages in the internal markup language, which happens to be XML based (There is a reason) and the formatter then converts this to the appropriate byte stream to achieve as close as wanted on the client.

What does this look like? Well, the following:

The idea here is that if the terminal at the other end supports ANSI colours, then ANSI colour escape sequences will be emitted as appropriate to change the colours. If the terminal doesn't support colour at all then no colours will be emitted but the text still will. This way you don't get garbage on the screen because of your terminal settings, and you don't need to configure your terminal to work the way the server expects.

I've only done colours, newlines and underlines so far, but it works pretty well. More will be added as necessary.

No comments:

Post a Comment