Exemplo n.º 1
0
        private void ExecuteInsertTextCommand(ref int iChar, string text)
        {
            var lines = text.Split('\n');
            var iLine = 0;

            foreach (var r in _range.GetSubRanges(true))
            {
                var line        = TextSource.CurrentTextBox[r.Start.Line];
                var lineIsEmpty = r.End < r.Start && line.StartSpacesCount == line.Count;
                if (!lineIsEmpty)
                {
                    var insertedText = lines[iLine % lines.Length];
                    if (r.End < r.Start && insertedText != "")
                    {
                        /* Add forwarding spaces */
                        insertedText = new string(' ', r.Start.Char - r.End.Char) + insertedText;
                        r.Start      = r.End;
                    }
                    TextSource.CurrentTextBox.Selection = r;
                    var c = new InsertTextCommand(TextSource, insertedText);
                    c.Execute();
                    if (TextSource.CurrentTextBox.Selection.End.Char > iChar)
                    {
                        iChar = TextSource.CurrentTextBox.Selection.End.Char;
                    }
                    _commandsByRanges.Add(c);
                }
                iLine++;
            }
        }
Exemplo n.º 2
0
        public override void Undo()
        {
            var tb = TextSource.CurrentTextBox;

            TextSource.OnTextChanging();
            tb.Selection.BeginUpdate();
            for (var i = 0; i < _iLines.Count; i++)
            {
                var iLine = _iLines[i];
                tb.Selection.Start = iLine < TextSource.Count ? new Place(0, iLine) : new Place(TextSource[TextSource.Count - 1].Count, TextSource.Count - 1);
                InsertCharCommand.InsertLine(TextSource);
                tb.Selection.Start = new Place(0, iLine);
                var text = _prevText[_prevText.Count - i - 1];
                InsertTextCommand.InsertText(text, TextSource);
                TextSource[iLine].IsChanged = true;
                if (iLine < TextSource.Count - 1)
                {
                    TextSource[iLine + 1].IsChanged = true;
                }
                else
                {
                    TextSource[iLine - 1].IsChanged = true;
                }
                if (text.Trim() != string.Empty)
                {
                    TextSource.OnTextChanged(iLine, iLine);
                }
            }
            tb.Selection.EndUpdate();
            TextSource.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
Exemplo n.º 3
0
        public override void Execute()
        {
            var tb = TextSource.CurrentTextBox;

            _prevText.Clear();
            TextSource.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(TextSource);
                if (_insertedText != "")
                {
                    InsertTextCommand.InsertText(_insertedText, TextSource);
                }
            }
            if (_ranges.Count > 0)
            {
                TextSource.OnTextChanged(_ranges[0].Start.Line, _ranges[_ranges.Count - 1].End.Line);
            }
            tb.EndUpdate();
            tb.Selection.EndUpdate();
            TextSource.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
            LastSel = new RangeInfo(tb.Selection);
        }
Exemplo n.º 4
0
        public override void Undo()
        {
            var tb = TextSource.CurrentTextBox;

            TextSource.OnTextChanging();
            tb.BeginUpdate();
            tb.Selection.BeginUpdate();
            for (var i = 0; i < _ranges.Count; i++)
            {
                tb.Selection.Start = _ranges[i].Start;
                var j = 0;
                while (j < _insertedText.Length)
                {
                    tb.Selection.GoRight(true);
                    j++;
                }
                ClearSelected(TextSource);
                InsertTextCommand.InsertText(_prevText[_prevText.Count - i - 1], TextSource);
            }
            tb.Selection.EndUpdate();
            tb.EndUpdate();
            if (_ranges.Count > 0)
            {
                TextSource.OnTextChanged(_ranges[0].Start.Line, _ranges[_ranges.Count - 1].End.Line);
            }
            TextSource.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
Exemplo n.º 5
0
 public override void Undo()
 {
     TextSource.CurrentTextBox.Selection.Start = new Place(Sel.FromX, Math.Min(Sel.Start.Line, Sel.End.Line));
     TextSource.OnTextChanging();
     InsertTextCommand.InsertText(_deletedText, TextSource);
     TextSource.OnTextChanged(Sel.Start.Line, Sel.End.Line);
     TextSource.CurrentTextBox.Selection.Start = Sel.Start;
     TextSource.CurrentTextBox.Selection.End   = Sel.End;
 }
Exemplo n.º 6
0
        public override void Undo()
        {
            var tb = TextSource.CurrentTextBox;

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