コード例 #1
0
ファイル: Commands.cs プロジェクト: the-alex-mark/proglib-cs
 /// <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;
 }
コード例 #2
0
ファイル: Commands.cs プロジェクト: the-alex-mark/proglib-cs
        /// <summary>
        /// Undo operation
        /// </summary>
        public override void Undo()
        {
            var tb = ts.CurrentTB;

            ts.OnTextChanging();

            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();

            ts.NeedRecalc(new TextSource.TextChangedEventArgs(0, 1));
        }
コード例 #3
0
ファイル: Commands.cs プロジェクト: the-alex-mark/proglib-cs
        /// <summary>
        /// Execute operation
        /// </summary>
        public override void Execute()
        {
            var tb = ts.CurrentTB;

            prevText.Clear();

            ts.OnTextChanging();

            tb.Selection.BeginUpdate();
            for (int 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);
        }
コード例 #4
0
ファイル: Commands.cs プロジェクト: the-alex-mark/proglib-cs
        /// <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));
        }