InsertText() static private method

static private InsertText ( string insertedText, TextSource ts ) : void
insertedText string
ts TextSource
return void
Exemplo n.º 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 (int 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = ts.CurrentTB;

            ts.OnTextChanging();
            tb.BeginUpdate();

            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);
                }
                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));
        }
Exemplo n.º 3
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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = ts.CurrentTB;

            ts.OnTextChanging();

            var insertedRange = new Range(tb, 0, iLines[0], 0, iLines[iLines.Count - 1] + 1);

            tb.Selection.BeginUpdate();
            //tb.BeginUpdate();
            for (int 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();

            tb.OnTextInserted(insertedRange);

            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Execute operation
        /// </summary>
        public override void Execute()
        {
            tb.OnTextChanging(ref insertedText);

            this.prevText = tb.Text;

            tb.Selection.BeginUpdate();
            for (int i = ranges.Count - 1; i >= 0; i--)
            {
                tb.Selection.Start = ranges[i].Start;
                tb.Selection.End   = ranges[i].End;
                ClearSelectedCommand.ClearSelected(tb);
                InsertTextCommand.InsertText(insertedText, tb);
            }
            tb.Selection.SelectAll();
            tb.Selection.EndUpdate();
            tb.needRecalc = true;

            lastSel = tb.Selection.Clone();
            tb.OnTextChanged(lastSel.Start.iLine, lastSel.End.iLine);
            //base.Execute();
        }
Exemplo n.º 8
0
        /// <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].ReplacedRange.Start;
                for (int 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));
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = Ts.CurrentTb;

            _prevText.Clear();

            Ts.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(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);
        }
Exemplo n.º 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));
        }