/// <summary> /// Undo operation /// </summary> public override void Undo() { ts.CurrentTB.Selection.Start = new Place(sel.FromX, Math.Min(sel.Start.iLine, sel.End.iLine)); ts.OnTextChanging(); InsertTextCommand.InsertText(deletedText, ts); ts.OnTextChanged(sel.Start.iLine, sel.End.iLine); ts.CurrentTB.Selection.Start = sel.Start; ts.CurrentTB.Selection.End = sel.End; }
/// <summary> /// Undo operation /// </summary> public override void Undo() { var tb = ts.CurrentTB; ts.OnTextChanging(); tb.Selection.BeginUpdate(); //tb.BeginUpdate(); for (int i = 0; i < iLines.Count; i++) { int iLine = iLines[i]; if (iLine < ts.Count) { tb.Selection.Start = new Place(0, iLine); } else { tb.Selection.Start = new Place(ts[ts.Count - 1].Count, ts.Count - 1); } InsertCharCommand.InsertLine(ts); tb.Selection.Start = new Place(0, iLine); string text = prevText[prevText.Count - i - 1]; InsertTextCommand.InsertText(text, ts); ts[iLine].IsChanged = true; if (iLine < ts.Count - 1) { ts[iLine + 1].IsChanged = true; } else { ts[iLine - 1].IsChanged = true; } if (text.Trim() != string.Empty) { ts.OnTextChanged(iLine, iLine); } } //tb.EndUpdate(); tb.Selection.EndUpdate(); ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1)); }
/// <summary> /// Execute operation /// </summary> public override void Execute() { var tb = ts.CurrentTB; prevText.Clear(); ts.OnTextChanging(); tb.Selection.BeginUpdate(); for (int i = ranges.Count - 1; i >= 0; i--) { tb.Selection.Start = ranges[i].ReplacedRange.Start; tb.Selection.End = ranges[i].ReplacedRange.End; prevText.Add(tb.Selection.Text); ClearSelectedCommand.ClearSelected(ts); InsertTextCommand.InsertText(ranges[i].ReplaceText, ts); ts.OnTextChanged(ranges[i].ReplacedRange.Start.iLine, ranges[i].ReplacedRange.End.iLine); } tb.Selection.EndUpdate(); ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1)); lastSel = new RangeInfo(tb.Selection); }
/// <summary> /// Undo operation /// </summary> public override void Undo() { var tb = ts.CurrentTB; ts.OnTextChanging(); tb.Selection.BeginUpdate(); for (int i = 0; i < ranges.Count; i++) { tb.Selection.Start = ranges[i].Start; for (int j = 0; j < insertedText.Length; j++) { tb.Selection.GoRight(true); } ClearSelectedCommand.ClearSelected(ts); InsertTextCommand.InsertText(prevText[prevText.Count - i - 1], ts); ts.OnTextChanged(ranges[i].Start.iLine, ranges[i].Start.iLine); } tb.Selection.EndUpdate(); ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1)); }