private void toolStripButtonPrevConflict_Click(object sender, EventArgs e) { Document currentDocument = editorOriginal.Document; VisualDiffOutput.ConflictRange conflict = CurrentDiffInfo.GetConflictBefore(editorOriginal.Caret.DocumentPosition.Line); if (conflict != null) { editorOriginal.Caret.Offset = currentDocument.PositionToOffset(new DocumentPosition(conflict.StartLineIndex, 0)); } }
private void toolStripButtonNextConflict_Click(object sender, EventArgs e) { Document currentDocument = editorOriginal.Document; VisualDiffOutput.ConflictRange conflict = CurrentDiffInfo.GetConflictAfter(editorOriginal.Caret.DocumentPosition.Line); if (conflict != null) { editorOriginal.Caret.Offset = currentDocument.PositionToOffset(new DocumentPosition(conflict.StartLineIndex, 0)); editorOriginal.SelectedView.ScrollLineToVisibleMiddle(); } }
private void editorOriginal_UserMarginPaint(object sender, UserMarginPaintEventArgs e) { if (DesignMode) { return; } if (CurrentDiffInfo == null) { return; } if (CurrentDiffInfo.IsLineInConflict(e.DocumentLineIndex) == false) { return; } userMarginPaint(CurrentDiffInfo.LeftLines, e); }
private void editorResolved_UserMarginPaint(object sender, UserMarginPaintEventArgs e) { if (DesignMode) { return; } if (CurrentDiffInfo == null) { return; } if (CurrentDiffInfo.RightLines[e.DocumentLineIndex].IsVirtual) { return; } if (CurrentDiffInfo.IsLineInConflict(e.DocumentLineIndex)) { return; } userMarginPaint(CurrentDiffInfo.RightLines, e); }
private void SetLineColours(int lineIndex) { IList <DiffLine> leftLines = CurrentDiffInfo.LeftLines, rightLines = CurrentDiffInfo.RightLines; SyntaxEditor leftEditor = editorOriginal, rightEditor = editorResolved; if (CurrentDiffInfo.IsLineInConflict(lineIndex)) { SetCommonLineColours(lineIndex, leftEditor, leftLines); rightEditor.Document.Lines[lineIndex].BackColor = ConflictColour; return; } SetCommonLineColours(lineIndex, leftEditor, leftLines); SetCommonLineColours(lineIndex, rightEditor, rightLines); if (rightLines[lineIndex].Change == ChangeType.None) { return; } if (rightLines[lineIndex].IsVirtual) { switch (rightLines[lineIndex].Change) { case ChangeType.Template: leftEditor.Document.Lines[lineIndex].BackColor = TemplateChangeColour; break; case ChangeType.User: leftEditor.Document.Lines[lineIndex].BackColor = UserChangeColour; break; case ChangeType.UserAndTemplate: leftEditor.Document.Lines[lineIndex].BackColor = UserAndTemplateChangeColour; break; } } }
void editorResolved_DocumentTextChanged(object sender, DocumentModificationEventArgs e) { if (e.IsProgrammaticTextReplacement || ModifyingEditorText) { return; } if (e.Cancel) { return; } DocumentModification docMod = e.Modification; // Handled added text. // If the text was on one line. // - Set the right hand line to the new text. // - Set the right hand line to UserChange. // - Set the left line to UserChange. // If the text was on multiple lines // - Determine how many lines changed (numLinesChanged) // - Add the text of the changed lines to the right hand side. // - Set these lines to UserChange. // - Add any needed virtual lines to the left. int newCaretOffset = docMod.StartOffset; int startLineIndex = docMod.StartLineIndex; if (docMod.LinesDelta == 0) { CurrentDiffInfo.RightLines[startLineIndex].Text = editorResolved.Document.Lines[startLineIndex].Text; CurrentDiffInfo.RightLines[startLineIndex].Change = ChangeType.User; newCaretOffset = docMod.LengthDelta > 0 ? docMod.InsertionEndOffset : Math.Max(0, docMod.DeletionEndOffset - 1); } else if (string.IsNullOrEmpty(docMod.InsertedText) == false) { int numLinesChanged = docMod.LinesInserted; // Remove the original start line CurrentDiffInfo.RightLines.RemoveAt(startLineIndex); // Recreate it and add new lines from editor for (int i = 0; i < numLinesChanged + 1; i++) { string lineText = editorResolved.Document.Lines[startLineIndex + i].Text; CurrentDiffInfo.RightLines.Insert(startLineIndex + i, new DiffLine(lineText, ChangeType.User)); } // Add the virtual lines to the left side. for (int i = 0; i < numLinesChanged; i++) { CurrentDiffInfo.LeftLines.Insert(docMod.InsertionEndLineIndex, new DiffLine("", ChangeType.User, true)); } newCaretOffset = docMod.InsertionEndOffset; } CurrentDiffInfo.CleanUp(); FillEditors(); editorResolved.Caret.Offset = newCaretOffset; editorOriginal.SelectedView.FirstVisibleX = editorResolved.SelectedView.FirstVisibleX; editorOriginal.SelectedView.FirstVisibleDisplayLineIndex = editorResolved.SelectedView.FirstVisibleDisplayLineIndex; }