private void syntaxEditor1_DocumentTextChanged(object sender, DocumentModificationEventArgs e) { // Colour lines correctly when new lines inserted or existing lines deleted if (e.Modification.LinesInserted + e.Modification.LinesDeleted > 0) { int lineNum = e.Modification.StartLineIndex; // -1; if (e.Modification.LinesInserted > 0 && syntaxEditorExternal.Document.Lines[lineNum].BackColor == Color.Red && syntaxEditorExternal.Document.Lines[lineNum + 1].BackColor != Color.Red) { DeselectLines(); } if (e.Modification.LinesDeleted > 0 && OrigianlLineSpan != null) { if (OrigianlLineSpan.EndLine - OrigianlLineSpan.StartLine > 0) { OrigianlLineSpan.EndLine -= 1; } if (OrigianlLineSpan.EndLine == OrigianlLineSpan.StartLine) { DeselectLines(OrigianlLineSpan.StartLine, OrigianlLineSpan.EndLine); OrigianlLineSpan = null; } if (lineNum + 1 < syntaxEditorExternal.Document.Lines.Count && (syntaxEditorExternal.Document.Lines[lineNum].BackColor == Color.White && syntaxEditorExternal.Document.Lines[lineNum + 1].BackColor == Color.Red)) { DeselectLines(); } } } }
/// <summary> /// Occurs after automatic outlining is performed on a <see cref="Document"/> that uses this language. /// </summary> /// <param name="document">The <see cref="Document"/> that is being modified.</param> /// <param name="e">A <c>DocumentModificationEventArgs</c> that contains the event data.</param> /// <remarks> /// A <see cref="DocumentModification"/> may or may not be passed in the event arguments, depending on if the outlining /// is performed in the main thread. /// </remarks> protected override void OnDocumentAutomaticOutliningComplete(Document document, DocumentModificationEventArgs e) { // If programmatically setting the text of a document... if (e.IsProgrammaticTextReplacement) { // Collapse all outlining region nodes document.Outlining.RootNode.CollapseDescendants("Region"); } }
protected override void OnDocumentAutomaticOutliningComplete(Document document, DocumentModificationEventArgs e) { if (e.get_IsProgrammaticTextReplacement()) { document.get_Outlining().get_RootNode().CollapseDescendants("Region"); } }
/// <summary> /// Occurs after automatic outlining is performed on a <see cref="Document"/> that uses this language. /// </summary> /// <param name="document">The <see cref="Document"/> that is being modified.</param> /// <param name="e">A <c>DocumentModificationEventArgs</c> that contains the event data.</param> /// <remarks> /// A <see cref="DocumentModification"/> may or may not be passed in the event arguments, depending on if the outlining /// is performed in the main thread. /// </remarks> protected override void OnDocumentAutomaticOutliningComplete(Document document, DocumentModificationEventArgs e) { // If programmatically setting the text of a document... if (e.IsProgrammaticTextReplacement) { // Collapse all outlining region nodes document.Outlining.RootNode.CollapseDescendants("Region"); } }
private void editorResolved_DocumentTextChanging(object sender, DocumentModificationEventArgs e) { if (e.IsProgrammaticTextReplacement || ModifyingEditorText) { return; } HasUnsavedChanges = true; DocumentModification docMod = e.Modification; int startLineIndex = docMod.StartLineIndex; if (docMod.LinesDelta == 0) // User modified some text on a single line. { // This gets handled in DocumentTextChanged. return; } if (string.IsNullOrEmpty(docMod.DeletedText)) { return; } // Handle deleted text here. // If the changed text was all 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 were removed (numLinesChanged). // - Removed numLinesChanged from the right hand side. // - Add the new text in as a UserChange. // - Add in any needed virtual lines on the right. int numLinesChanged = docMod.LinesDeleted; DocumentLine oldStartLine = editorResolved.Document.Lines[startLineIndex]; int endLineIndex = docMod.DeletionEndLineIndex; DocumentLine oldEndLine = editorResolved.Document.Lines[endLineIndex]; string newLineText = oldStartLine.Text.Substring(0, docMod.StartOffset - oldStartLine.StartOffset) + oldEndLine.Text.Substring(docMod.DeletionEndOffset - oldEndLine.StartOffset); for (int i = 0; i < numLinesChanged + 1; i++) { CurrentDiffInfo.RightLines.RemoveAt(startLineIndex); } for (int i = 0; i < numLinesChanged; i++) { CurrentDiffInfo.RightLines.Insert(startLineIndex, new DiffLine("", ChangeType.User, true)); } CurrentDiffInfo.RightLines.Insert(startLineIndex, new DiffLine(newLineText, ChangeType.User)); }
private void Document_PreTextChanging(object sender, DocumentModificationEventArgs e) { if (e.IsProgrammaticTextReplacement || ModifyingEditorText) { return; } DocumentModification docMod = e.Modification; if (CurrentDiffInfo != null && CurrentDiffInfo.RightLines[docMod.StartLineIndex].IsVirtual) { e.Cancel = true; } }
/// <summary> /// Occurs after the document is modified. /// </summary> private void EditorDocumentTextChanged(object sender, DocumentModificationEventArgs e) { // Add status message //Console.WriteLine("TextChanged: " + e.ToString()); if (EditorTextChanged == null) return; string str = null; var startOffset = e.Modification.StartOffset; var endoffset = -1; var startLine = e.Modification.StartLineIndex + 1; var endLine = -1; if (!String.IsNullOrEmpty(e.Modification.InsertedText)) { endoffset = e.Modification.InsertionEndOffset; str = e.Modification.InsertedText; endLine = e.Modification.InsertionEndLineIndex + 1; } else if (!String.IsNullOrEmpty(e.Modification.DeletedText)) { endoffset = e.Modification.DeletionEndOffset; str = e.Modification.DeletedText; endLine = e.Modification.DeletionEndLineIndex + 1; } var arg = new EditorTextChangedEventArgs( str, startOffset, endoffset, startLine, endLine); EditorTextChanged(this, arg); }
private void editorResolved_DocumentTextChanging(object sender, DocumentModificationEventArgs e) { if (e.IsProgrammaticTextReplacement || ModifyingEditorText) return; HasUnsavedChanges = true; DocumentModification docMod = e.Modification; int startLineIndex = docMod.StartLineIndex; if (docMod.LinesDelta == 0) // User modified some text on a single line. { // This gets handled in DocumentTextChanged. return; } if (string.IsNullOrEmpty(docMod.DeletedText)) return; // Handle deleted text here. // If the changed text was all 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 were removed (numLinesChanged). // - Removed numLinesChanged from the right hand side. // - Add the new text in as a UserChange. // - Add in any needed virtual lines on the right. int numLinesChanged = docMod.LinesDeleted; DocumentLine oldStartLine = editorResolved.Document.Lines[startLineIndex]; int endLineIndex = docMod.DeletionEndLineIndex; DocumentLine oldEndLine = editorResolved.Document.Lines[endLineIndex]; string newLineText = oldStartLine.Text.Substring(0, docMod.StartOffset - oldStartLine.StartOffset) + oldEndLine.Text.Substring(docMod.DeletionEndOffset - oldEndLine.StartOffset); for (int i = 0; i < numLinesChanged + 1; i++) { CurrentDiffInfo.RightLines.RemoveAt(startLineIndex); } for (int i = 0; i < numLinesChanged; i++) { CurrentDiffInfo.RightLines.Insert(startLineIndex, new DiffLine("", ChangeType.User, true)); } CurrentDiffInfo.RightLines.Insert(startLineIndex, new DiffLine(newLineText, ChangeType.User)); }
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; }
private void Document_PreTextChanging(object sender, DocumentModificationEventArgs e) { if (e.IsProgrammaticTextReplacement || ModifyingEditorText) return; DocumentModification docMod = e.Modification; if (CurrentDiffInfo != null && CurrentDiffInfo.RightLines[docMod.StartLineIndex].IsVirtual) { e.Cancel = true; } }
protected override void OnDocumentAutomaticOutliningComplete(Document document, DocumentModificationEventArgs e) { if (e.get_IsProgrammaticTextReplacement()) { document.get_Outlining().get_RootNode().CollapseDescendants("RegionPreProcessorDirective"); } }
private void syntaxEditor1_DocumentTextChanged(object sender, DocumentModificationEventArgs e) { if (!IsDirty && !BusyPopulating) { IsDirty = true; SetTabStripText(GetTabStripText() + " *"); if (!Project.Instance.IsDirty) { Project.Instance.IsDirty = true; } } }
private void EditorDocumentTextChanged(object sender, DocumentModificationEventArgs e) { if (EditorTextChanged == null) return; string str = null; int startOffset = e.Modification.StartOffset; int endoffset = -1; int startLine = e.Modification.StartLineIndex + 1; int endLine = -1; if (!String.IsNullOrEmpty(e.Modification.InsertedText)) { endoffset = e.Modification.InsertionEndOffset; str = e.Modification.InsertedText; endLine = e.Modification.InsertionEndLineIndex + 1; } else if (!String.IsNullOrEmpty(e.Modification.DeletedText)) { endoffset = e.Modification.DeletionEndOffset; str = e.Modification.DeletedText; endLine = e.Modification.DeletionEndLineIndex + 1; } EditorTextChanged(this, new EditorTextChangedEventArgs(str, startOffset, endoffset, startLine, endLine)); }
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; }