As some of you might now, I am creating a Multi User Dungeon (a text-based multiplayer game) in Elixir. This is mostly a hobby project, to learn what a non-trivial project in Elixir will look like, and do’s and don’t when an Elixir project grows in size.
The text that is generated in the game is sent over a simple TCP connection to the telnet shells of connected clients. What I would like to do, is to format this text, so lines break nicely, instead of cutting words in half.
I think the Inspect.Algebra module is useful for this, as I presume that this is what Elixir uses underwater to print the pretty-printed documentation whenever you use h Modulename
in IEx.
However, I am a bit stumped on how to use it properly. Can someone explain how I can use it to generate line-breaks from an iodata string?