Beispiel #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);
        }
Beispiel #2
0
        /// <summary>
        ///     Execute operation
        /// </summary>
        public override void Execute()
        {
            Ts.CurrentTb.ExpandBlock(Ts.CurrentTb.Selection.Start.ILine);
            var s = C.ToString();

            Ts.OnTextChanging(ref s);
            if (s.Length == 1)
            {
                C = s[0];
            }

            if (string.IsNullOrEmpty(s))
            {
                throw new ArgumentOutOfRangeException();
            }


            if (Ts.Count == 0)
            {
                InsertLine(Ts);
            }
            InsertChar(C, ref _deletedChar, Ts);

            Ts.NeedRecalc(new TextSource.TextChangedEventArgs(Ts.CurrentTb.Selection.Start.ILine,
                                                              Ts.CurrentTb.Selection.Start.ILine));
            base.Execute();
        }
Beispiel #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));
        }
Beispiel #4
0
 /// <summary>
 ///     Undo operation
 /// </summary>
 public override void Undo()
 {
     Ts.CurrentTb.Selection.Start = Sel.Start;
     Ts.CurrentTb.Selection.End   = LastSel.Start;
     Ts.OnTextChanging();
     ClearSelectedCommand.ClearSelected(Ts);
     base.Undo();
 }
Beispiel #5
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;
 }
Beispiel #6
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);
        }
Beispiel #7
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));
        }
Beispiel #8
0
        /// <summary>
        ///     Undo operation
        /// </summary>
        public override void Undo()
        {
            Ts.OnTextChanging();
            switch (C)
            {
            case '\n':
                MergeLines(Sel.Start.ILine, Ts);
                break;

            case '\r':
                break;

            case '\b':
                Ts.CurrentTb.Selection.Start = LastSel.Start;
                var cc = '\x0';
                if (_deletedChar != '\x0')
                {
                    Ts.CurrentTb.ExpandBlock(Ts.CurrentTb.Selection.Start.ILine);
                    InsertChar(_deletedChar, ref cc, Ts);
                }
                break;

            case '\t':
                Ts.CurrentTb.ExpandBlock(Sel.Start.ILine);
                for (var i = Sel.FromX; i < LastSel.FromX; i++)
                {
                    Ts[Sel.Start.ILine].RemoveAt(Sel.Start.IChar);
                }
                Ts.CurrentTb.Selection.Start = Sel.Start;
                break;

            default:
                Ts.CurrentTb.ExpandBlock(Sel.Start.ILine);
                Ts[Sel.Start.ILine].RemoveAt(Sel.Start.IChar);
                Ts.CurrentTb.Selection.Start = Sel.Start;
                break;
            }

            Ts.NeedRecalc(new TextSource.TextChangedEventArgs(Sel.Start.ILine, Sel.Start.ILine));

            base.Undo();
        }
Beispiel #9
0
        /// <summary>
        ///     Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = Ts.CurrentTb;

            _prevText.Clear();

            Ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            for (var 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);
        }
Beispiel #10
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));
        }
Beispiel #11
0
 /// <summary>
 ///     Execute operation
 /// </summary>
 public override void Execute()
 {
     Ts.OnTextChanging(ref InsertedText);
     InsertText(InsertedText, Ts);
     base.Execute();
 }