Exemple #1
0
            public static DelimiterSet GetDefaultCharDelimiters()
            {
                DelimiterSet chrDel = new DelimiterSet();

                chrDel.Set(CharEncoding.Encoding.Ascii,
                           new DelimiterDef(string.Empty, '\u2018', '\u2019', string.Empty));
                chrDel.Set(CharEncoding.Encoding.HighAscii,
                           new DelimiterDef(string.Empty, '\u2018', '\u2019', " | $80"));
                chrDel.Set(CharEncoding.Encoding.C64Petscii,
                           new DelimiterDef("pet:", '\u2018', '\u2019', string.Empty));
                chrDel.Set(CharEncoding.Encoding.C64ScreenCode,
                           new DelimiterDef("scr:", '\u2018', '\u2019', string.Empty));
                return(chrDel);
            }
Exemple #2
0
        /// <summary>
        /// Constructor.  Initializes various fields based on the configuration.  We want to
        /// do as much work as possible here.
        /// </summary>
        public Formatter(FormatConfig config)
        {
            mFormatConfig = config;     // copy struct
            if (mFormatConfig.mEndOfLineCommentDelimiter == null)
            {
                mFormatConfig.mEndOfLineCommentDelimiter = string.Empty;
            }
            if (mFormatConfig.mFullLineCommentDelimiterBase == null)
            {
                mFormatConfig.mFullLineCommentDelimiterBase = string.Empty;
            }
            if (mFormatConfig.mBoxLineCommentDelimiter == null)
            {
                mFormatConfig.mBoxLineCommentDelimiter = string.Empty;
            }

            if (string.IsNullOrEmpty(mFormatConfig.mNonUniqueLabelPrefix))
            {
                mFormatConfig.mNonUniqueLabelPrefix = "@";
            }

            if (mFormatConfig.mAddSpaceLongComment)
            {
                mFullLineCommentDelimiterPlus = mFormatConfig.mFullLineCommentDelimiterBase + " ";
            }
            else
            {
                mFullLineCommentDelimiterPlus = mFormatConfig.mFullLineCommentDelimiterBase;
            }

            // Prep the static parts of the hex dump buffer.
            mHexDumpBuffer = new char[73];
            for (int i = 0; i < mHexDumpBuffer.Length; i++)
            {
                mHexDumpBuffer[i] = ' ';
            }
            mHexDumpBuffer[6] = ':';

            // Resolve boolean flags to character or string values.
            if (mFormatConfig.mUpperHexDigits)
            {
                mHexFmtChar = 'X';
            }
            else
            {
                mHexFmtChar = 'x';
            }
            if (mFormatConfig.mSuppressHexNotation)
            {
                mHexPrefix = "";
            }
            else
            {
                mHexPrefix = "$";
            }
            if (mFormatConfig.mSuppressImpliedAcc)
            {
                mAccChar = "";
            }
            else if (mFormatConfig.mUpperOperandA)
            {
                mAccChar = "A";
            }
            else
            {
                mAccChar = "a";
            }
            if (mFormatConfig.mUpperOperandXY)
            {
                mXregChar = 'X';
                mYregChar = 'Y';
            }
            else
            {
                mXregChar = 'x';
                mYregChar = 'y';
            }
            if (mFormatConfig.mUpperOperandS)
            {
                mSregChar = 'S';
            }
            else
            {
                mSregChar = 's';
            }

            // process the delimiter patterns
            DelimiterSet chrDelim = mFormatConfig.mCharDelimiters;

            if (chrDelim == null)
            {
                Debug.WriteLine("NOTE: char delimiters not set");
                chrDelim = DelimiterSet.GetDefaultCharDelimiters();
            }

            switch (mFormatConfig.mHexDumpCharConvMode)
            {
            case FormatConfig.CharConvMode.Ascii:
                mHexDumpCharConv = CharEncoding.ConvertAscii;
                break;

            case FormatConfig.CharConvMode.LowHighAscii:
                mHexDumpCharConv = CharEncoding.ConvertLowAndHighAscii;
                break;

            case FormatConfig.CharConvMode.C64Petscii:
                mHexDumpCharConv = CharEncoding.ConvertC64Petscii;
                break;

            case FormatConfig.CharConvMode.C64ScreenCode:
                mHexDumpCharConv = CharEncoding.ConvertC64ScreenCode;
                break;

            default:
                // most some things don't configure the hex dump; this is fine
                mHexDumpCharConv = CharEncoding.ConvertLowAndHighAscii;
                break;
            }
        }