Exemple #1
0
        void ApplySyntaxColoring(ProcessedSourceLine processedLine)
        {
            mSourceBox.SelectionStart  = (processedLine.LineTextIndex - lineNumberSeparator.Length) - mLineNumberLength;
            mSourceBox.SelectionLength = mLineNumberLength;
            mSourceBox.SelectionColor  = mLineNumberColor;
            mSourceBox.SelectionStart += mLineNumberLength;
            mSourceBox.SelectionLength = lineNumberSeparator.Length;
            mSourceBox.SelectionColor  = mLineNumberSeparatorColor;

            if (!processedLine.SourceLine.IsCommentLine)
            {
                if (processedLine.SourceLine.LocationField.Length > 0)
                {
                    mSourceBox.SelectionStart  = processedLine.LocTextIndex;
                    mSourceBox.SelectionLength = processedLine.SourceLine.LocationField.Length;
                    mSourceBox.SelectionColor  = mLocColor;
                }

                if (processedLine.SourceLine.OpField.Length > 0)
                {
                    mSourceBox.SelectionStart  = processedLine.OpTextIndex;
                    mSourceBox.SelectionLength = processedLine.SourceLine.OpField.Length;
                    mSourceBox.SelectionColor  = mOpColor;
                }

                if (processedLine.SourceLine.AddressField.Length > 0)
                {
                    mSourceBox.SelectionStart  = processedLine.AddressTextIndex;
                    mSourceBox.SelectionLength = processedLine.SourceLine.AddressField.Length;
                    mSourceBox.SelectionColor  = mAddressColor;
                }
            }

            if (processedLine.SourceLine.Comment.Length > 0)
            {
                mSourceBox.SelectionStart  = processedLine.CommentTextIndex;
                mSourceBox.SelectionLength = processedLine.SourceLine.Comment.Length;
                mSourceBox.SelectionColor  = mCommentColor;
            }
        }
Exemple #2
0
        void AddLine(ParsedSourceLine sourceLine)
        {
            int count = mInstructions.Count;

            if (mSourceBox.TextLength != 0)
            {
                mSourceBox.AppendText(Environment.NewLine);
            }

            var lineNumberText = (count + 1).ToString();

            mSourceBox.AppendText(new string(' ', mLineNumberLength - lineNumberText.Length) + lineNumberText + lineNumberSeparator);

            var processedLine = new ProcessedSourceLine(sourceLine, mSourceBox.TextLength);

            mInstructions.Add(processedLine);

            if (sourceLine.IsCommentLine)
            {
                if (sourceLine.Comment.Length > 0)
                {
                    mSourceBox.AppendText(sourceLine.Comment);
                }
            }
            else
            {
                mSourceBox.AppendText(sourceLine.LocationField + new string(' ', (processedLine.LocTextLength - sourceLine.LocationField.Length) + Parser.FieldSpacing));
                mSourceBox.AppendText(sourceLine.OpField + new string(' ', (processedLine.OpTextLength - sourceLine.OpField.Length) + Parser.FieldSpacing));
                mSourceBox.AppendText(sourceLine.AddressField + new string(' ', (processedLine.AddressTextLength - sourceLine.AddressField.Length) + Parser.FieldSpacing));
                if (sourceLine.Comment.Length > 0)
                {
                    mSourceBox.AppendText(sourceLine.Comment);
                }
            }

            ApplySyntaxColoring(processedLine);
        }
Exemple #3
0
        void ApplyFindingColoring(AssemblyFinding finding, MarkOperation mark)
        {
            if (finding != null && finding.LineNumber != int.MinValue && finding.LineNumber >= 0 && finding.LineNumber < mInstructions.Count)
            {
                ProcessedSourceLine processedLine = mInstructions[finding.LineNumber];
                int lineTextIndex = processedLine.LineTextIndex;
                int length        = 0;

                switch (finding.LineSection)
                {
                case LineSection.LocationField:
                    if (finding.Length <= 0)
                    {
                        lineTextIndex = processedLine.LocTextIndex;
                        length        = processedLine.SourceLine.LocationField.Length;

                        break;
                    }

                    lineTextIndex = processedLine.LocTextIndex + finding.StartCharIndex;
                    length        = finding.Length;

                    break;

                case LineSection.OpField:
                    if (finding.Length <= 0)
                    {
                        lineTextIndex = processedLine.OpTextIndex;
                        length        = processedLine.SourceLine.OpField.Length;

                        break;
                    }

                    lineTextIndex = processedLine.OpTextIndex + finding.StartCharIndex;
                    length        = finding.Length;

                    break;

                case LineSection.AddressField:
                    if (finding.Length <= 0)
                    {
                        lineTextIndex = processedLine.AddressTextIndex;
                        length        = processedLine.SourceLine.AddressField.Length;

                        break;
                    }

                    lineTextIndex = processedLine.AddressTextIndex + finding.StartCharIndex;
                    length        = finding.Length;

                    break;

                case LineSection.CommentField:
                    if (finding.Length <= 0)
                    {
                        lineTextIndex = processedLine.CommentTextIndex;
                        length        = processedLine.SourceLine.Comment.Length;

                        break;
                    }

                    lineTextIndex = processedLine.CommentTextIndex + finding.StartCharIndex;
                    length        = finding.Length;

                    break;

                case LineSection.EntireLine:
                    length = processedLine.LineTextLength;

                    break;
                }

                mSourceBox.Select(lineTextIndex, length);

                if (length != 0)
                {
                    if (mark == MarkOperation.Mark)
                    {
                        Font font = mSourceBox.Font;

                        mSourceBox.SelectionFont = new Font(font.Name, font.Size, FontStyle.Underline, font.Unit, font.GdiCharSet);
                        mSourceBox.Focus();
                        mSourceBox.ScrollToCaret();
                    }
                    else if (mark == MarkOperation.Unmark)
                    {
                        mSourceBox.SelectionFont = mSourceBox.Font;
                    }

                    mSourceBox.SelectionColor  = findingColors[(int)finding.Severity];
                    mSourceBox.SelectionLength = 0;
                }
            }
        }