private void Scintilla_BeforeTextInsert(object sender, TextModifiedEventArgs e) { if (this._snippetLinks.IsActive && !this._pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo)) { this._pendingUndo = true; Scintilla.UndoRedo.BeginUndoAction(); this._snippetLinkTimer.Enabled = true; } }
private void Scintilla_TextInserted(object sender, TextModifiedEventArgs e) { // I'm going to have to look into making this a little less "sledge hammer to // the entire documnet"ish if (this._snippetLinks.IsActive && (e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo)) Scintilla.NativeInterface.Colourise(0, -1); }
private void Scintilla_BeforeTextDelete(object sender, TextModifiedEventArgs e) { if (!this._isEnabled) return; if (this._snippetLinks.IsActive && !this._pendingUndo && !(e.UndoRedoFlags.IsUndo || e.UndoRedoFlags.IsRedo)) { this._pendingUndo = true; Scintilla.UndoRedo.BeginUndoAction(); this._snippetLinkTimer.Enabled = true; } ManagedRange undoneSnippetLinkRange = null; if (e.UndoRedoFlags.IsUndo && this._snippetLinks.IsActive) { foreach (ManagedRange mr in Scintilla.ManagedRanges) { if (mr.Start == e.Position && mr.Length == e.Length && mr.Length > 1) { undoneSnippetLinkRange = mr; // Expanding the range So that it won't get marked for deletion mr.End++; } } } // It's possible that the _end point may have been deleted. The endpoint // is an ultra persistent marker that cannot be deleted until the Snippet // Link mode is deactivated. Place a new EndPoint at the begining of the // deleted range. if (this._snippetLinks.IsActive && this._snippetLinks.EndPoint != null && this._snippetLinks.EndPoint.Scintilla == null) { var eci = new SnippetLinkEnd(e.Position, Scintilla); Scintilla.ManagedRanges.Add(eci); this._snippetLinks.EndPoint = eci; } // Now collapse the Undone range in preparation for the // newly inserted text that will be put in here if (undoneSnippetLinkRange != null) undoneSnippetLinkRange.End = undoneSnippetLinkRange.Start; // Check to see if all SnippetLink ranges have been deleted. // If this is the case we need to turn Deactivate SnippetLink // mode. bool deactivate = true; foreach (SnippetLink sl in this._snippetLinks.Values) { if (sl.Ranges.Count > 0) { foreach (SnippetLinkRange slr in sl.Ranges) { if (slr.Scintilla != null) { deactivate = false; break; } } } if (!deactivate) break; } if (deactivate && this.IsActive) this.IsActive = false; }