Exemple #1
0
        /// <summary>
        ///     Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = Ts.CurrentTb;

            _prevText.Clear();

            Ts.OnTextChanging(ref _insertedText);

            tb.Selection.BeginUpdate();
            tb.BeginUpdate();
            for (var i = _ranges.Count - 1; i >= 0; i--)
            {
                tb.Selection.Start = _ranges[i].Start;
                tb.Selection.End   = _ranges[i].End;
                _prevText.Add(tb.Selection.Text);
                ClearSelected(Ts);
                if (_insertedText != "")
                {
                    InsertTextCommand.InsertText(_insertedText, Ts);
                }
            }
            if (_ranges.Count > 0)
            {
                Ts.OnTextChanged(_ranges[0].Start.ILine, _ranges[_ranges.Count - 1].End.ILine);
            }
            tb.EndUpdate();
            tb.Selection.EndUpdate();
            Ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));

            LastSel = new RangeInfo(tb.Selection);
        }
        protected virtual void OnTextChanged(bool invert)
        {
            var b = Sel.Start.ILine < LastSel.Start.ILine;

            if (invert)
            {
                if (b)
                {
                    Ts.OnTextChanged(Sel.Start.ILine, Sel.Start.ILine);
                }
                else
                {
                    Ts.OnTextChanged(Sel.Start.ILine, LastSel.Start.ILine);
                }
            }
            else
            {
                if (b)
                {
                    Ts.OnTextChanged(Sel.Start.ILine, LastSel.Start.ILine);
                }
                else
                {
                    Ts.OnTextChanged(LastSel.Start.ILine, LastSel.Start.ILine);
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///     Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = Ts.CurrentTb;

            Ts.OnTextChanging();
            tb.BeginUpdate();

            tb.Selection.BeginUpdate();
            for (var i = 0; i < _ranges.Count; i++)
            {
                tb.Selection.Start = _ranges[i].Start;
                for (var j = 0; j < _insertedText.Length; j++)
                {
                    tb.Selection.GoRight(true);
                }
                ClearSelected(Ts);
                InsertTextCommand.InsertText(_prevText[_prevText.Count - i - 1], Ts);
            }
            tb.Selection.EndUpdate();
            tb.EndUpdate();

            if (_ranges.Count > 0)
            {
                Ts.OnTextChanged(_ranges[0].Start.ILine, _ranges[_ranges.Count - 1].End.ILine);
            }

            Ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
Exemple #4
0
 /// <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;
 }
Exemple #5
0
        /// <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);
        }
Exemple #6
0
        /// <summary>
        ///     Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = Ts.CurrentTb;

            Ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            //tb.BeginUpdate();
            for (var i = 0; i < _iLines.Count; i++)
            {
                var 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);
                var 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));
        }
Exemple #7
0
        /// <summary>
        ///     Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = Ts.CurrentTb;

            Ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            for (var i = 0; i < _ranges.Count; i++)
            {
                tb.Selection.Start = _ranges[i].ReplacedRange.Start;
                for (var j = 0; j < _ranges[i].ReplaceText.Length; j++)
                {
                    tb.Selection.GoRight(true);
                }
                ClearSelectedCommand.ClearSelected(Ts);
                var prevTextIndex = _ranges.Count - 1 - i;
                InsertTextCommand.InsertText(_prevText[prevTextIndex], Ts);
                Ts.OnTextChanged(_ranges[i].ReplacedRange.Start.ILine, _ranges[i].ReplacedRange.Start.ILine);
            }
            tb.Selection.EndUpdate();

            Ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }