Rich, suitability for MUDs? #1193
Replies: 2 comments 5 replies
-
I had no idea people still played MUDs! I think your assessment is correct. If you need to export custom xml tags you will need to extend the Style class. Bear in mind that Something to be aware of is that when the content is rendered, Rich will combine overlapping styles. To illustrate this, if you print this string:
It is converted to a flat list of Segment instances without any nesting: [Segment("Hello ", style="red"), Segment("world", style="bold red")] So your xml tags may be duplicated if they contain style changes inside them. Not sure if that's a problem. I can't think of any other potential gotchas... |
Beta Was this translation helpful? Give feedback.
-
One more thing, but am writing from phone. My project calla for the ability to parse different MU* player facing markups into Texts. This looks doable thanks to Text.assemble and .append, I just need to handle parsing and stare management to generate a stream of Tuple[str, Style] The question is: is adding MXP support an acceptable addition to rich, if I make a PR? or am I better off using a fork or monkey patching? Unsure if MUD features is within scope of Rich. |
Beta Was this translation helpful? Give feedback.
-
So I've been having a blast looking over the Rich package and trying out some things... and there is one use case which I am not sure if anyone has considered, but which I have been desperately seeking a solution like this one.
There is a genre of multiplayer games known as MUDs. These are RPG's played via a bastardized subset of the telnet protocol, and most such MUDs use ANSI standard colors or xterm256 colors to some extent.
This package is a GODSEND to almost any use-case one might want for sending colored, formatted fancy text to game clients, and even if the color features are turned off then the formatting tools like Table are still amazing.
There's only one area in which it doesn't quite handle the needs.
There is a MUD-specific telnet protocol known as MXP / Mud eXtension Protocol - this is a way for the server and client to send special commands and game-specific information back and forth by agreeing to send data in XML format instead of the normal stream. This DOESN'T look like the output generated by Console.export_html() mind you - it is, instead, a normal terminal/console byte stream with ANSI codes, where non-ANSI text has been html.escape()'d and XML elements can be present in the stream.
For instance:
I have been studying the guts of Rich, pondering the best way to add something like a Console.export_mxp() or Console.export_mud(). I think it may be quite doable, but would require some adjustments to the Style class to store the tag+attributes for a given style (which does not work the same way as a Link currently does) and another few methods to handle the alternate rendering.
What other difficulties might there be in enabling this approach?
Beta Was this translation helpful? Give feedback.
All reactions