Exemplo n.º 1
0
        private void LoadErrors(IEnumerable <CompilationError> errors)
        {
            _syntaxEditor.Document.SpanIndicatorLayers.Clear();
            if (errors != null)
            {
                SpanIndicatorLayer spanIndicatorLayer = new SpanIndicatorLayer(null, 0);
                _syntaxEditor.Document.SpanIndicatorLayers.Add(spanIndicatorLayer);

                foreach (CompilationError error in errors)
                {
                    if (error.SourceRange != SourceRange.None)
                    {
                        TextRange       textRange          = GetTextRange(error.SourceRange);
                        SpanIndicator[] existingIndicators = spanIndicatorLayer.GetIndicatorsForTextRange(textRange);
                        if (existingIndicators.Length == 0)
                        {
                            SyntaxErrorSpanIndicator errorIndicator = new SyntaxErrorSpanIndicator();
                            errorIndicator.Tag = error;
                            spanIndicatorLayer.Add(errorIndicator, textRange);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
		private void LoadErrors(IEnumerable<CompilationError> errors)
		{
			_syntaxEditor.Document.SpanIndicatorLayers.Clear();
			if (errors != null)
			{
				SpanIndicatorLayer spanIndicatorLayer = new SpanIndicatorLayer(null, 0);
				_syntaxEditor.Document.SpanIndicatorLayers.Add(spanIndicatorLayer);

				foreach (CompilationError error in errors)
				{
					if (error.SourceRange != SourceRange.None)
					{
						TextRange textRange = GetTextRange(error.SourceRange);
						SpanIndicator[] existingIndicators = spanIndicatorLayer.GetIndicatorsForTextRange(textRange);
						if (existingIndicators.Length == 0)
						{
							SyntaxErrorSpanIndicator errorIndicator = new SyntaxErrorSpanIndicator();
							errorIndicator.Tag = error;
							spanIndicatorLayer.Add(errorIndicator, textRange);
						}
					}
				}
			}
		}
Exemplo n.º 3
0
        private static void DiffInSingleEditor(List<DiffMatchPatch.Diff> diffs, SyntaxEditor editor)
        {
            //editor.SuspendLayout();
            //editor.SuspendPainting();
            Document doc = new Document();

            Color backColorGreen = Color.FromArgb(230, 255, 230);
            Color backColorRed = Color.FromArgb(255, 230, 230);

            #region Deleted style
            SpanIndicatorLayer deletedLayer = new SpanIndicatorLayer("Deleted", 1000);
            HighlightingStyle deletedHighlightingStyle = new HighlightingStyle("Deleted", null, Color.Empty, backColorRed)
            {
                StrikeOutStyle = HighlightingStyleLineStyle.Solid,
                StrikeOutColor = Color.Red
            };
            doc.SpanIndicatorLayers.Add(deletedLayer);
            #endregion

            #region New style
            SpanIndicatorLayer newLayer = new SpanIndicatorLayer("New", 1000);
            HighlightingStyle newHighlightingStyle = new HighlightingStyle("New", null, Color.Empty, backColorGreen);
            doc.SpanIndicatorLayers.Add(newLayer);
            #endregion

            System.Text.StringBuilder sb = new System.Text.StringBuilder(10000);

            foreach (DiffMatchPatch.Diff aDiff in diffs)
                sb.Append(aDiff.text);

            doc.Text = sb.ToString();

            int start = 0;
            int endOffset = 0;
            int i = 0;

            foreach (DiffMatchPatch.Diff aDiff in diffs)
            {
                int diffLength = aDiff.text.Length;

                switch (aDiff.operation)
                {
                    case DiffMatchPatch.Operation.INSERT://green
                        start = i;
                        endOffset = i + diffLength;

                        if (endOffset > start)
                            newLayer.Add(new HighlightingStyleSpanIndicator("New", newHighlightingStyle), new TextRange(start, endOffset));

                        break;
                    case DiffMatchPatch.Operation.DELETE://red
                        start = i;
                        endOffset = i + diffLength;

                        if (endOffset > start)
                            deletedLayer.Add(new HighlightingStyleSpanIndicator("Deleted", deletedHighlightingStyle), new TextRange(start, endOffset));

                        break;
                    //case Operation.EQUAL:
                    //    start = i;// editor.Document.GetText(LineTerminator.Newline).Length;
                    //    //editor.Document.InsertText(DocumentModificationType.Custom, start, aDiff.text);
                    //    //editor.Document.AppendText(aDiff.text);
                    //    break;
                }
                //if (aDiff.operation != Operation.DELETE)
                i += diffLength;
            }
            editor.Document = doc;
            //editor.SelectedView.EnsureVisible(1, false);
            //editor.ResumeLayout();
            //editor.ResumePainting();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Populates two Actipro SyntaxEditors with diff-highlighted text.
        /// </summary>
        /// <param name="editor1">Actipro SyntaxEditor</param>
        /// <param name="editor2">Actipro SyntaxEditor</param>
        /// <param name="text">Fully combined text.</param>
        /// <param name="lines1">Lines unique to the left file.</param>
        /// <param name="lines2">Lines unique to the right file.</param>
        public static void PopulateSyntaxEditors(
  ActiproSoftware.SyntaxEditor.SyntaxEditor editor1,
  ActiproSoftware.SyntaxEditor.SyntaxEditor editor2,
  string text,
  SlyceMerge.LineSpan[] lines1,
  SlyceMerge.LineSpan[] lines2)
        {
            editor1.Text = text;
            editor2.Text = text;

            for (int i = 0; i < lines1.Length; i++)
            {
                for (int lineCounter = lines1[i].StartLine; lineCounter <= lines1[i].EndLine; lineCounter++)
                {
                    editor1.Document.Lines[lineCounter].BackColor = ColourNewGen;
                    editor2.Document.Lines[lineCounter].BackColor = Color.LightGray;
                    editor2.Document.DeleteText(ActiproSoftware.SyntaxEditor.DocumentModificationType.Delete, editor2.Document.Lines[lineCounter].StartOffset, editor2.Document.Lines[lineCounter].Length);
                }
            }
            for (int i = 0; i < lines2.Length; i++)
            {
                for (int lineCounter = lines2[i].StartLine; lineCounter <= lines2[i].EndLine; lineCounter++)
                {
                    editor2.Document.Lines[lineCounter].BackColor = ColourNewGen;
                    editor1.Document.Lines[lineCounter].BackColor = Color.LightGray;
                    editor1.Document.DeleteText(ActiproSoftware.SyntaxEditor.DocumentModificationType.Delete, editor1.Document.Lines[lineCounter].StartOffset, editor1.Document.Lines[lineCounter].Length);
                }
            }
            // Compact the displays
            int lineCount1 = 0;
            int lineCount2 = 0;

            for (int i = editor1.Document.Lines.Count - 1; i >= -1; i--)
            {
                Color lineColor = Color.Empty;

                if (i >= 0)
                {
                    lineColor = editor1.Document.Lines[i].BackColor;
                }
                if (lineColor == Color.Empty && (lineCount1 + lineCount2) > 0)
                {
                    // Process counted lines
                    int startIndex = i + 1;
                    int condensedLineCount = Math.Max(lineCount1, lineCount2);
                    int numLinesToRemove = lineCount1 + lineCount2 - condensedLineCount;
                    int lastLine = startIndex + lineCount1 + lineCount2 - 1;

                    //if (numLinesToRemove > 0)
                    //{
                    //   // Walk backward when processing Left
                    //   for (int removeIndex = lastLine; removeIndex >= startIndex + condensedLineCount; removeIndex--)
                    //   {
                    //      editor1.Document.Lines[removeIndex].BackColor = editor1.Document.Lines[removeIndex + 1].BackColor;
                    //      editor1.Document.Lines.RemoveAt(removeIndex);

                    //      int newPos = lastLine - condensedLineCount - (lastLine - removeIndex);
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines[newPos].Text = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines[newPos].BackColor = editor2.Document.Lines[removeIndex].BackColor;
                    //      editor2.Document.Lines[removeIndex].BackColor = editor2.Document.Lines[removeIndex + 1].BackColor;
                    //      editor2.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    numLinesToRemove = Math.Min(lineCount1, lineCount2);
                    int linesRemoved1 = 0;
                    int linesRemoved2 = 0;

                    for (int x = startIndex + (lineCount1 + lineCount2); x >= startIndex; x--)
                    {
                        if (linesRemoved1 < numLinesToRemove &&
                            editor1.Document.Lines[x].BackColor == Color.LightGray)
                        {
                            editor1.Document.Lines[x].BackColor = editor1.Document.Lines[x + 1].BackColor;
                            editor1.Document.Lines.RemoveAt(x);
                            linesRemoved1++;
                        }
                        if (linesRemoved2 < numLinesToRemove &&
                            editor2.Document.Lines[x].BackColor == Color.LightGray)
                        {
                            editor2.Document.Lines[x].BackColor = editor2.Document.Lines[x + 1].BackColor;
                            editor2.Document.Lines.RemoveAt(x);
                            linesRemoved2++;
                        }
                    }
                    if (linesRemoved1 != linesRemoved2)
                        throw new Exception("Non-equal number of lines removed.");

                    //if (lineCount1 > lineCount2)
                    //{
                    //   // Remove trailing gray lines from editor2
                    //   for (int removeIndex = startIndex; removeIndex <= startIndex + numLinesToRemove; removeIndex++)
                    //   {
                    //      string q111 = editor1.Document.Lines[removeIndex].Text;
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    //else if (lineCount2 > lineCount1)
                    //{
                    //   // Remove trailing gray lines from editor1
                    //   for (int removeIndex = lastLine; removeIndex >= startIndex + condensedLineCount; removeIndex--)
                    //   {
                    //      string q111 = editor1.Document.Lines[removeIndex].Text;
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor1.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    lineCount1 = 0;
                    lineCount2 = 0;
                    continue;
                }
                else if (lineColor == ColourNewGen)
                {
                    lineCount1++;
                }
                else if (lineColor == Color.LightGray)
                {
                    lineCount2++;
                }
            }
            // Line Marker Colours, Strikethroughs
            string layerKey = "Diff";
            string indicatorKey = "Diff";
            SpanIndicatorLayer layer = new SpanIndicatorLayer(layerKey, 1000);
            HighlightingStyle highlightingStyle = new HighlightingStyle("Diff", null, Color.Empty, Color.Empty);
            highlightingStyle.StrikeOutStyle = HighlightingStyleLineStyle.Solid;
            highlightingStyle.StrikeOutColor = Color.Red;
            editor1.Document.SpanIndicatorLayers.Add(layer);

            int lineNumber1 = 1;
            int lineNumber2 = 1;

            for (int i = 0; i < editor1.Document.Lines.Count; i++)
            {
                // Set the line marker colours
                if (editor1.Document.Lines[i].BackColor == Color.LightGray &&
                    editor2.Document.Lines[i].BackColor == ColourNewGen)
                {
                    if (i > 0 && editor2.Document.Lines[i - 1].SelectionMarginMarkColor == changedMarkerColour)
                    {
                        editor2.Document.Lines[i].SelectionMarginMarkColor = changedMarkerColour;
                        editor2.Document.Lines[i].BackColor = Color.LightYellow;
                    }
                    else
                    {
                        editor2.Document.Lines[i].SelectionMarginMarkColor = addedMarkerColour;
                        editor2.Document.Lines[i].BackColor = Color.Honeydew;
                    }
                    editor1.Document.Lines[i].BackColor = Color.WhiteSmoke;
                    editor1.Document.Lines[i].CustomLineNumber = string.Empty;
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber2++;
                }
                else if (editor1.Document.Lines[i].BackColor == ColourNewGen &&
                    editor2.Document.Lines[i].BackColor == Color.LightGray)
                {
                    editor2.Document.Lines[i].SelectionMarginMarkColor = deletedMarkerColour;
                    editor1.Document.Lines[i].BackColor = Color.MistyRose;
                    editor2.Document.Lines[i].BackColor = Color.WhiteSmoke;
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = string.Empty;
                    lineNumber1++;
                }
                else if (editor1.Document.Lines[i].BackColor == ColourNewGen &&
                    editor2.Document.Lines[i].BackColor == ColourNewGen)
                {
                    editor2.Document.Lines[i].SelectionMarginMarkColor = changedMarkerColour;
                    editor1.Document.Lines[i].BackColor = Color.LightYellow;
                    editor2.Document.Lines[i].BackColor = Color.LightYellow;
                    layer.Add(new HighlightingStyleSpanIndicator(indicatorKey, highlightingStyle), editor1.Document.Lines[i].TextRange);
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber1++;
                    lineNumber2++;
                }
                else
                {
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber1++;
                    lineNumber2++;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Populates two Actipro SyntaxEditors with diff-highlighted text.
        /// </summary>
        /// <param name="editor1">Actipro SyntaxEditor</param>
        /// <param name="editor2">Actipro SyntaxEditor</param>
        /// <param name="text">Fully combined text.</param>
        /// <param name="lines1">Lines unique to the left file.</param>
        /// <param name="lines2">Lines unique to the right file.</param>
        public static void PopulateSyntaxEditors(
            ActiproSoftware.SyntaxEditor.SyntaxEditor editor1,
            ActiproSoftware.SyntaxEditor.SyntaxEditor editor2,
            string text,
            SlyceMerge.LineSpan[] lines1,
            SlyceMerge.LineSpan[] lines2)
        {
            editor1.Text = text;
            editor2.Text = text;

            for (int i = 0; i < lines1.Length; i++)
            {
                for (int lineCounter = lines1[i].StartLine; lineCounter <= lines1[i].EndLine; lineCounter++)
                {
                    editor1.Document.Lines[lineCounter].BackColor = ColourNewGen;
                    editor2.Document.Lines[lineCounter].BackColor = Color.LightGray;
                    editor2.Document.DeleteText(ActiproSoftware.SyntaxEditor.DocumentModificationType.Delete, editor2.Document.Lines[lineCounter].StartOffset, editor2.Document.Lines[lineCounter].Length);
                }
            }
            for (int i = 0; i < lines2.Length; i++)
            {
                for (int lineCounter = lines2[i].StartLine; lineCounter <= lines2[i].EndLine; lineCounter++)
                {
                    editor2.Document.Lines[lineCounter].BackColor = ColourNewGen;
                    editor1.Document.Lines[lineCounter].BackColor = Color.LightGray;
                    editor1.Document.DeleteText(ActiproSoftware.SyntaxEditor.DocumentModificationType.Delete, editor1.Document.Lines[lineCounter].StartOffset, editor1.Document.Lines[lineCounter].Length);
                }
            }
            // Compact the displays
            int lineCount1 = 0;
            int lineCount2 = 0;

            for (int i = editor1.Document.Lines.Count - 1; i >= -1; i--)
            {
                Color lineColor = Color.Empty;

                if (i >= 0)
                {
                    lineColor = editor1.Document.Lines[i].BackColor;
                }
                if (lineColor == Color.Empty && (lineCount1 + lineCount2) > 0)
                {
                    // Process counted lines
                    int startIndex         = i + 1;
                    int condensedLineCount = Math.Max(lineCount1, lineCount2);
                    int numLinesToRemove   = lineCount1 + lineCount2 - condensedLineCount;
                    int lastLine           = startIndex + lineCount1 + lineCount2 - 1;

                    //if (numLinesToRemove > 0)
                    //{
                    //   // Walk backward when processing Left
                    //   for (int removeIndex = lastLine; removeIndex >= startIndex + condensedLineCount; removeIndex--)
                    //   {
                    //      editor1.Document.Lines[removeIndex].BackColor = editor1.Document.Lines[removeIndex + 1].BackColor;
                    //      editor1.Document.Lines.RemoveAt(removeIndex);

                    //      int newPos = lastLine - condensedLineCount - (lastLine - removeIndex);
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines[newPos].Text = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines[newPos].BackColor = editor2.Document.Lines[removeIndex].BackColor;
                    //      editor2.Document.Lines[removeIndex].BackColor = editor2.Document.Lines[removeIndex + 1].BackColor;
                    //      editor2.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    numLinesToRemove = Math.Min(lineCount1, lineCount2);
                    int linesRemoved1 = 0;
                    int linesRemoved2 = 0;

                    for (int x = startIndex + (lineCount1 + lineCount2); x >= startIndex; x--)
                    {
                        if (linesRemoved1 < numLinesToRemove &&
                            editor1.Document.Lines[x].BackColor == Color.LightGray)
                        {
                            editor1.Document.Lines[x].BackColor = editor1.Document.Lines[x + 1].BackColor;
                            editor1.Document.Lines.RemoveAt(x);
                            linesRemoved1++;
                        }
                        if (linesRemoved2 < numLinesToRemove &&
                            editor2.Document.Lines[x].BackColor == Color.LightGray)
                        {
                            editor2.Document.Lines[x].BackColor = editor2.Document.Lines[x + 1].BackColor;
                            editor2.Document.Lines.RemoveAt(x);
                            linesRemoved2++;
                        }
                    }
                    if (linesRemoved1 != linesRemoved2)
                    {
                        throw new Exception("Non-equal number of lines removed.");
                    }

                    //if (lineCount1 > lineCount2)
                    //{
                    //   // Remove trailing gray lines from editor2
                    //   for (int removeIndex = startIndex; removeIndex <= startIndex + numLinesToRemove; removeIndex++)
                    //   {
                    //      string q111 = editor1.Document.Lines[removeIndex].Text;
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor2.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    //else if (lineCount2 > lineCount1)
                    //{
                    //   // Remove trailing gray lines from editor1
                    //   for (int removeIndex = lastLine; removeIndex >= startIndex + condensedLineCount; removeIndex--)
                    //   {
                    //      string q111 = editor1.Document.Lines[removeIndex].Text;
                    //      string gg = editor2.Document.Lines[removeIndex].Text;
                    //      editor1.Document.Lines.RemoveAt(removeIndex);
                    //   }
                    //}
                    lineCount1 = 0;
                    lineCount2 = 0;
                    continue;
                }
                else if (lineColor == ColourNewGen)
                {
                    lineCount1++;
                }
                else if (lineColor == Color.LightGray)
                {
                    lineCount2++;
                }
            }
            // Line Marker Colours, Strikethroughs
            string             layerKey          = "Diff";
            string             indicatorKey      = "Diff";
            SpanIndicatorLayer layer             = new SpanIndicatorLayer(layerKey, 1000);
            HighlightingStyle  highlightingStyle = new HighlightingStyle("Diff", null, Color.Empty, Color.Empty);

            highlightingStyle.StrikeOutStyle = HighlightingStyleLineStyle.Solid;
            highlightingStyle.StrikeOutColor = Color.Red;
            editor1.Document.SpanIndicatorLayers.Add(layer);

            int lineNumber1 = 1;
            int lineNumber2 = 1;

            for (int i = 0; i < editor1.Document.Lines.Count; i++)
            {
                // Set the line marker colours
                if (editor1.Document.Lines[i].BackColor == Color.LightGray &&
                    editor2.Document.Lines[i].BackColor == ColourNewGen)
                {
                    if (i > 0 && editor2.Document.Lines[i - 1].SelectionMarginMarkColor == changedMarkerColour)
                    {
                        editor2.Document.Lines[i].SelectionMarginMarkColor = changedMarkerColour;
                        editor2.Document.Lines[i].BackColor = Color.LightYellow;
                    }
                    else
                    {
                        editor2.Document.Lines[i].SelectionMarginMarkColor = addedMarkerColour;
                        editor2.Document.Lines[i].BackColor = Color.Honeydew;
                    }
                    editor1.Document.Lines[i].BackColor        = Color.WhiteSmoke;
                    editor1.Document.Lines[i].CustomLineNumber = string.Empty;
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber2++;
                }
                else if (editor1.Document.Lines[i].BackColor == ColourNewGen &&
                         editor2.Document.Lines[i].BackColor == Color.LightGray)
                {
                    editor2.Document.Lines[i].SelectionMarginMarkColor = deletedMarkerColour;
                    editor1.Document.Lines[i].BackColor        = Color.MistyRose;
                    editor2.Document.Lines[i].BackColor        = Color.WhiteSmoke;
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = string.Empty;
                    lineNumber1++;
                }
                else if (editor1.Document.Lines[i].BackColor == ColourNewGen &&
                         editor2.Document.Lines[i].BackColor == ColourNewGen)
                {
                    editor2.Document.Lines[i].SelectionMarginMarkColor = changedMarkerColour;
                    editor1.Document.Lines[i].BackColor = Color.LightYellow;
                    editor2.Document.Lines[i].BackColor = Color.LightYellow;
                    layer.Add(new HighlightingStyleSpanIndicator(indicatorKey, highlightingStyle), editor1.Document.Lines[i].TextRange);
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber1++;
                    lineNumber2++;
                }
                else
                {
                    editor1.Document.Lines[i].CustomLineNumber = lineNumber1.ToString();
                    editor2.Document.Lines[i].CustomLineNumber = lineNumber2.ToString();
                    lineNumber1++;
                    lineNumber2++;
                }
            }
        }
Exemplo n.º 6
0
        private static void DiffInSingleEditor(List <DiffMatchPatch.Diff> diffs, SyntaxEditor editor)
        {
            //editor.SuspendLayout();
            //editor.SuspendPainting();
            Document doc = new Document();

            Color backColorGreen = Color.FromArgb(230, 255, 230);
            Color backColorRed   = Color.FromArgb(255, 230, 230);

            #region Deleted style
            SpanIndicatorLayer deletedLayer             = new SpanIndicatorLayer("Deleted", 1000);
            HighlightingStyle  deletedHighlightingStyle = new HighlightingStyle("Deleted", null, Color.Empty, backColorRed)
            {
                StrikeOutStyle = HighlightingStyleLineStyle.Solid,
                StrikeOutColor = Color.Red
            };
            doc.SpanIndicatorLayers.Add(deletedLayer);
            #endregion

            #region New style
            SpanIndicatorLayer newLayer             = new SpanIndicatorLayer("New", 1000);
            HighlightingStyle  newHighlightingStyle = new HighlightingStyle("New", null, Color.Empty, backColorGreen);
            doc.SpanIndicatorLayers.Add(newLayer);
            #endregion

            System.Text.StringBuilder sb = new System.Text.StringBuilder(10000);

            foreach (DiffMatchPatch.Diff aDiff in diffs)
            {
                sb.Append(aDiff.text);
            }

            doc.Text = sb.ToString();

            int start     = 0;
            int endOffset = 0;
            int i         = 0;

            foreach (DiffMatchPatch.Diff aDiff in diffs)
            {
                int diffLength = aDiff.text.Length;

                switch (aDiff.operation)
                {
                case DiffMatchPatch.Operation.INSERT:                        //green
                    start     = i;
                    endOffset = i + diffLength;

                    if (endOffset > start)
                    {
                        newLayer.Add(new HighlightingStyleSpanIndicator("New", newHighlightingStyle), new TextRange(start, endOffset));
                    }

                    break;

                case DiffMatchPatch.Operation.DELETE:                        //red
                    start     = i;
                    endOffset = i + diffLength;

                    if (endOffset > start)
                    {
                        deletedLayer.Add(new HighlightingStyleSpanIndicator("Deleted", deletedHighlightingStyle), new TextRange(start, endOffset));
                    }

                    break;
                    //case Operation.EQUAL:
                    //    start = i;// editor.Document.GetText(LineTerminator.Newline).Length;
                    //    //editor.Document.InsertText(DocumentModificationType.Custom, start, aDiff.text);
                    //    //editor.Document.AppendText(aDiff.text);
                    //    break;
                }
                //if (aDiff.operation != Operation.DELETE)
                i += diffLength;
            }
            editor.Document = doc;
            //editor.SelectedView.EnsureVisible(1, false);
            //editor.ResumeLayout();
            //editor.ResumePainting();
        }