/// <summary> /// Constructor /// </summary> /// <param name="tb">Underlaying textbox</param> /// <param name="ranges">List of ranges for replace</param> /// <param name="insertedText">Text for inserting</param> public RemoveLinesCommand(TextSource ts, List <int> iLines) : base(ts) { //sort iLines iLines.Sort(); // this.iLines = iLines; lastSel = sel = new RangeInfo(ts.CurrentTB.Selection); }
/// <summary> /// Constructor /// </summary> /// <param name="ts">Underlaying textsource</param> /// <param name="ranges">List of ranges for replace</param> public ReplaceMultipleTextCommand(TextSource ts, List <ReplaceRange> ranges) : base(ts) { //sort ranges by place ranges.Sort((r1, r2) => { if (r1.ReplacedRange.Start.iLine == r2.ReplacedRange.Start.iLine) { return(r1.ReplacedRange.Start.iChar.CompareTo(r2.ReplacedRange.Start.iChar)); } return(r1.ReplacedRange.Start.iLine.CompareTo(r2.ReplacedRange.Start.iLine)); }); // this.ranges = ranges; lastSel = sel = new RangeInfo(ts.CurrentTB.Selection); }
/// <summary> /// Constructor /// </summary> /// <param name="tb">Underlaying textbox</param> /// <param name="ranges">List of ranges for replace</param> /// <param name="insertedText">Text for inserting</param> public ReplaceTextCommand(TextSource ts, List <Range> ranges, string insertedText) : base(ts) { //sort ranges by place ranges.Sort((r1, r2) => { if (r1.Start.iLine == r2.Start.iLine) { return(r1.Start.iChar.CompareTo(r2.Start.iChar)); } return(r1.Start.iLine.CompareTo(r2.Start.iLine)); }); // this.ranges = ranges; this.insertedText = insertedText; lastSel = sel = new RangeInfo(ts.CurrentTB.Selection); }
/// <summary> /// Execute operation /// </summary> public override void Execute() { var tb = ts.CurrentTB; string temp = null; ts.OnTextChanging(ref temp); if (temp == "") { throw new ArgumentOutOfRangeException(); } deletedText = tb.Selection.Text; ClearSelected(ts); lastSel = new RangeInfo(tb.Selection); ts.OnTextChanged(lastSel.Start.iLine, lastSel.Start.iLine); }
/// <summary> /// Execute operation /// </summary> public override void Execute() { var tb = ts.CurrentTB; prevText.Clear(); ts.OnTextChanging(); tb.Selection.BeginUpdate(); for (int i = iLines.Count - 1; i >= 0; i--) { var iLine = iLines[i]; prevText.Add(ts[iLine].Text); //backward ts.RemoveLine(iLine); //ts.OnTextChanged(ranges[i].Start.iLine, ranges[i].End.iLine); } tb.Selection.Start = new Place(0, 0); tb.Selection.EndUpdate(); ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1)); lastSel = new RangeInfo(tb.Selection); }
/// <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); }
public override void Execute() { lastSel = new RangeInfo(ts.CurrentTB.Selection); OnTextChanged(false); }
public UndoableCommand(TextSource ts) { this.ts = ts; sel = new RangeInfo(ts.CurrentTB.Selection); }