NuSkooler / enigma-bbs

ENiGMA½ BBS Software
https://nuskooler.github.io/enigma-bbs/
BSD 2-Clause "Simplified" License
529 stars 104 forks source link

ANSI art from PabloDraw not compatible with Enigma #494

Closed cognitivegears closed 10 months ago

cognitivegears commented 10 months ago

Describe the Bug ANSI art drawn with PabloDraw (at least version 3.3.12.0) is not compatible with Enigma. The reason is an unknown control sequence added by Pablo, "ESC [ #;#;#;#t (where # is various numbers). Since the regex doesn't catch this sequence, it treats it as literals and outputs it, but counts it as columns, throwing off all further processing for MCI codes etc.

To Reproduce Save an art file with PabloDraw that includes at least one MCI code (I used MATRIX.ANS as an example.)

Expected Behavior Page displays correctly with MCI codes in position.

Actual Behavior

MCI codes are off from the expected location.

Screenshots Added in Discord, will add here if needed.

Environment

cognitivegears commented 10 months ago

Here is the code from the PabloDraw source base:

void GetRgbColourChanges (StringBuilder sb, bool force, Attribute attr, Attribute standardAttr)
            {
                if (force || lastRgbAttr.Background != attr.Background) {
                    var col = palette [attr.Background];
                    var standardCol = standardPalette [standardAttr.Background];
                    if (col != standardCol || lastRgbAttr.Background != -1)
                    {
                        sb.AppendFormat("\x1b[0;{0};{1};{2}t", (byte)(col.R * 255), (byte)(col.G * 255), (byte)(col.B * 255));
                        lastRgbAttr.Background = attr.Background;
                    }
                }
                if (force || lastRgbAttr.Foreground != attr.Foreground) {
                    var col = palette [attr.Foreground];
                    var standardCol = standardPalette [standardAttr.Foreground];
                    if (col != standardCol || lastRgbAttr.Foreground != -1)
                    {
                        sb.AppendFormat("\x1b[1;{0};{1};{2}t", (byte)(col.R * 255), (byte)(col.G * 255), (byte)(col.B * 255));
                        lastRgbAttr.Foreground = attr.Foreground;
                    }
                }
            }

(https://github.com/cwensley/pablodraw/blob/c1df6febcc7fb6b2d9b7876fb783ff224e0e87f5/Source/Pablo/Formats/Character/Types/Ansi.cs)

cognitivegears commented 10 months ago

This should be fixed with PR #495

NuSkooler commented 10 months ago

Nice work!