Exemplo n.º 1
0
 public ReplaceTextCommand(TextSource textSource, List <Range> ranges, string insertedText) : base(textSource)
 {
     /* Sort ranges by place */
     ranges.Sort(
         (r1, r2) =>
         r1.Start.Line == r2.Start.Line
             ? r1.Start.Char.CompareTo(r2.Start.Char)
             : r1.Start.Line.CompareTo(r2.Start.Line));
     _ranges       = ranges;
     _insertedText = insertedText;
     LastSel       = Sel = new RangeInfo(textSource.CurrentTextBox.Selection);
 }
Exemplo n.º 2
0
 public ReplaceMultipleTextCommand(TextSource textSource, List <ReplaceRange> ranges) : base(textSource)
 {
     /* Sort ranges by place */
     ranges.Sort((r1, r2) =>
     {
         if (r1.ReplacedRange.Start.Line == r2.ReplacedRange.Start.Line)
         {
             return(r1.ReplacedRange.Start.Char.CompareTo(r2.ReplacedRange.Start.Char));
         }
         return(r1.ReplacedRange.Start.Line.CompareTo(r2.ReplacedRange.Start.Line));
     });
     _ranges = ranges;
     LastSel = Sel = new RangeInfo(textSource.CurrentTextBox.Selection);
 }
Exemplo n.º 3
0
        public override void Execute()
        {
            var    tb   = TextSource.CurrentTextBox;
            string temp = null;

            TextSource.OnTextChanging(ref temp);
            if (temp == "")
            {
                throw new ArgumentOutOfRangeException();
            }
            _deletedText = tb.Selection.Text;
            ClearSelected(TextSource);
            LastSel = new RangeInfo(tb.Selection);
            TextSource.OnTextChanged(LastSel.Start.Line, LastSel.Start.Line);
        }
Exemplo n.º 4
0
        public override void Execute()
        {
            var tb = TextSource.CurrentTextBox;

            _prevText.Clear();
            TextSource.OnTextChanging();
            tb.Selection.BeginUpdate();
            for (var i = _iLines.Count - 1; i >= 0; i--)
            {
                var iLine = _iLines[i];
                _prevText.Add(TextSource[iLine].Text); /* Backward */
                TextSource.RemoveLine(iLine);
            }
            tb.Selection.Start = new Place(0, 0);
            tb.Selection.EndUpdate();
            TextSource.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            LastSel = new RangeInfo(tb.Selection);
        }
Exemplo n.º 5
0
        public override void Execute()
        {
            var tb = TextSource.CurrentTextBox;

            _prevText.Clear();
            TextSource.OnTextChanging();
            tb.Selection.BeginUpdate();
            for (var 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(TextSource);
                InsertTextCommand.InsertText(_ranges[i].ReplaceText, TextSource);
                TextSource.OnTextChanged(_ranges[i].ReplacedRange.Start.Line, _ranges[i].ReplacedRange.End.Line);
            }
            tb.Selection.EndUpdate();
            TextSource.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            LastSel = new RangeInfo(tb.Selection);
        }
Exemplo n.º 6
0
 public override void Execute()
 {
     LastSel = new RangeInfo(TextSource.CurrentTextBox.Selection);
     OnTextChanged(false);
 }
Exemplo n.º 7
0
 protected UndoableCommand(TextSource textSource)
 {
     TextSource = textSource;
     Sel        = new RangeInfo(textSource.CurrentTextBox.Selection);
 }
Exemplo n.º 8
0
 public override void Execute()
 {
     /* Remember selection */
     LastSel = new RangeInfo(TextSource.CurrentTextBox.Selection);
 }