Up to Main Index Up to Journal for April, 2013 JOURNAL FOR THURSDAY 11TH APRIL, 2013 ______________________________________________________________________________ SUBJECT: Text formatting and folding DATE: Thu Apr 11 22:41:12 BST 2013 Yesterday was WolfMUD Wednesday again. So I spent the time working on fixing up the broken tests. In doing so I also started looking into the text folding bug. I then spent about four hours digging around ... and then another four hours this evening digging around some more. It seems I have two problems. The first is an off by one bug. The second is more subtle and concerns line feeds. If we have the following example and assume a terminal width of 20: The quick brown fox jumps over the lazy dog. We can easily fold the text: The quick brown fox jumps over the lazy dog. Now if the text contains line feeds already: The quick brown fox jumps over the lazy dog. The folding obviously changes: The quick brown fox jumps over the lazy dog. So where is the problem? Well in the zinara.wrj file the descriptive text is already wrapped to 78 columns. For example: You are in the corner of a common room in the Dragon's Breath tavern. There is a fire burning away merrily in an ornate fireplace giving comfort to weary travellers. Shadows flicker around the room, changing light to darkness and back again. To the south the common room extends and east the common room leads to the tavern entrance. Now if we fold this to a shorter length, say 50 we get: You are in the corner of a common room in the Dragon's Breath tavern. There is a fire burning away merrily in an ornate fireplace giving comfort to weary travellers. Shadows flicker around the room, changing light to darkness and back again. To the south the common room extends and east the common room leads to the tavern entrance. What a mess :( The trouble is we are not 'unfolding' the existing line feeds. What we really want to end up with is: You are in the corner of a common room in the Dragon's Breath tavern. There is a fire burning away merrily in an ornate fireplace giving comfort to weary travellers. Shadows flicker around the room, changing light to darkness and back again. To the south the common room extends and east the common room leads to the tavern entrance. Now that would look much better. Can we just strip out the existing line endings? Not really. What if we assume a width of 50 again and have: A little something ------------------ The quick brown fox jumps over the lazy dog. We would end up with: A little something ------------------ The quick brown fox jumps over the lazy dog. Gah! So we want to strip out line feeds for folding but we also want to keep them ther for formatting. Hrm... soft and hard line breaks? Unicode has a number of whitespace characters including line feed (U+000A), form feed (U+000C), next line (U+0085), line separator (U+2028) and paragraph separator (U+2029). It would be easy enough to use the line separators and paragraph separators for what we want. However the wrj files are supposed to be "plain text and easily editable" - how do we get users to easily use line separators and paragraph separators? I was thinking that maybe an explicit line break - one that should not be unfolded could be respresented using the unicode return symbol '⏎' (U+23CE). Then the source of our previous example would look like: A little something⏎ ------------------⏎ The quick brown fox⏎ jumps over the lazy⏎ dog.⏎ Workable, but a bit butt ugly :( The only alternative I can think of is to not put line breaks where you don't want them, and rely on line wrapping in your editor instead. This means the descriptive text from before becomes one long line. That would work. It's a better option than the unicode return symbol at any rate. Or we could disallow preformatting like the 'A little something' example and just strip out existing line feeds[1] - bleugh! I guess I'll have to leave it for tonight and ponder for a while. -- Diddymus [1] Except consecutive line feeds with no text - multiple blank lines - could be used to denote a paragraph break? Up to Main Index Up to Journal for April, 2013