protected override void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e) { var change = e.Change; while (change.NextChange != null) { // We actually need the last change; we're "as of" that change. change = change.NextChange; } StartNewParse(change); }
void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e) { if (!this.inputBasedEdit && !this.inUndoRedo) { // This is an edit that we didn't make. Need to update the caret // as appropriate. var lineVisual = GetLineVisual(this.Caret.Line); int spaces; var location = lineVisual.MapToLocation(this.Caret, out spaces); for (var change = e.Change; change != null; change = change.NextChange) { location = change.ApplyTo(location, false); } lineVisual = GetLineVisual(location.Line); this.MoveCaret(lineVisual.MapToCoordinate(location.Index + spaces), false); } UpdateLineLayout(true); }
void OnPencilDisposed(Pencil pencil, TextDataChangedEventArgs args) { Debug.Assert(pencil == this.activePencil, "Disposing a pencil that isn't the active one."); if (args != null) { if (this.LastChange != null) { this.LastChange.NextChange = args.Change; } TextChange finalChange = args.Change; while (finalChange.NextChange != null) { finalChange = finalChange.NextChange; } this.TextData = finalChange.NewTextData; this.LastChange = finalChange; var handler = this.TextDataChanged; if (handler != null) { handler(this, args); } if (pencil.UndoUnit != null) { var now = DateTime.Now; bool merged = false; if (((now - this.timeOfLastEdit).TotalMilliseconds < MinimumMillisecondsTimeBetweenUndoUnits) && (this.undoStack.Count > 0)) { // If possible, merge this unit with the one on the stack. TextUndoUnit existingUnit = this.undoStack.Peek(); TextUndoUnit incomingUnit = pencil.UndoUnit; if (incomingUnit.Metadata != null && incomingUnit.Metadata.TryMerge(existingUnit.Metadata)) { // Successful merge existingUnit.Metadata = incomingUnit.Metadata; existingUnit.Merge(pencil.UndoUnit); merged = true; } } if (!merged) { this.undoStack.Push(pencil.UndoUnit); } this.redoStack.Clear(); this.timeOfLastEdit = now; } } this.activePencil = null; this.pencilEvent.Set(); }
protected virtual void OnBufferTextDataChanged(object sender, TextDataChangedEventArgs e) { }