Inheritance: ICollection, IList, IEnumerable, ICloneable
        // Operations (type-safe ICloneable)
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public UndoBlockCollection Clone()
        {
            var tc = new UndoBlockCollection();

            tc.AddRange(this);
            tc.Capacity  = m_array.Length;
            tc.m_version = m_version;
            return(tc);
        }
        // Public helpers (just to mimic some nice features of ArrayList)

        /// <summary>
        ///
        /// </summary>
        /// <param name="collection"></param>
        public void AddRange(UndoBlockCollection collection)
        {
            // for (int i=0; i < collection.Count; ++i) Add(collection[i]);

            ++m_version;

            Capacity += collection.Count;
            Array.Copy(collection.m_array, 0, m_array, m_count, collection.m_count);
            m_count += collection.Count;
        }
Beispiel #3
0
 /// <summary>
 /// Starts an Undo Capture.
 /// This method can be called if you with to collect multiple text operations into one undo action
 /// </summary>
 public void StartUndoCapture()
 {
     captureMode = true;
     captureBlock = new UndoBlockCollection();
 }
Beispiel #4
0
 /// <summary>
 /// Add an action to the undo stack
 /// </summary>
 /// <param name="ActionGroup">action to add</param>
 public void AddToUndoList(UndoBlockCollection ActionGroup)
 {
     UndoBuffer.ClearFrom(UndoStep);
     UndoBuffer.Add(ActionGroup);
     UndoStep++;
     OnUndoBufferChanged();
 }
Beispiel #5
0
        public void AddToUndoList(UndoBlock undo)
        {
            //store the undo action in a actiongroup
            var ActionGroup = new UndoBlockCollection {undo};

            AddToUndoList(ActionGroup);
        }
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index      = -1;
                m_version    = tc.m_version;
            }
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="collection"></param>
 public UndoBlockCollection(UndoBlockCollection collection)
 {
     AddRange(collection);
 }
Beispiel #9
0
        private void InsertText(string text)
        {
            Caret.CropPosition();
            if (Selection.IsValid)
            {
                Selection.DeleteSelection();
                InsertText(text);
            }
            else
            {
                if (!_OverWrite || text.Length > 1)
                {
                    TextPoint p = Document.InsertText(text, Caret.Position.X,
                                                      Caret.Position.Y);
                    Caret.CurrentRow.Parse(true);
                    if (text.Length == 1)
                    {
                        Caret.SetPos(p);
                        Caret.CaretMoved(false);
                    }
                    else
                    {
                        //Document.i = true;

                        Document.ResetVisibleRows();
                        Caret.SetPos(p);
                        Caret.CaretMoved(false);
                    }
                }
                else
                {
                    var r = new TextRange
                            {
                                FirstColumn = Caret.Position.X,
                                FirstRow = Caret.Position.Y,
                                LastColumn = (Caret.Position.X + 1),
                                LastRow = Caret.Position.Y
                            };
                    var ag = new UndoBlockCollection();
                    var b = new UndoBlock
                                  {
                                      Action = UndoAction.DeleteRange,
                                      Text = Document.GetRange(r),
                                      Position = Caret.Position
                                  };
                    ag.Add(b);
                    Document.DeleteRange(r, false);
                    b = new UndoBlock
                        {
                            Action = UndoAction.InsertRange
                        };
                    string NewChar = text;
                    b.Text = NewChar;
                    b.Position = Caret.Position;
                    ag.Add(b);
                    Document.AddToUndoList(ag);
                    Document.InsertText(NewChar, Caret.Position.X, Caret.Position.Y,
                                        false);
                    Caret.CurrentRow.Parse(true);

                    Caret.MoveRight(false);
                }
            }
            //	this.ScrollIntoView ();
        }
            // Construction

            public Enumerator(UndoBlockCollection tc)
            {
                m_collection = tc;
                m_index = - 1;
                m_version = tc.m_version;
            }
        // Public helpers (just to mimic some nice features of ArrayList)

        /// <summary>
        /// 
        /// </summary>
        /// <param name="collection"></param>
        public void AddRange(UndoBlockCollection collection)
        {
            // for (int i=0; i < collection.Count; ++i) Add(collection[i]);

            ++m_version;

            Capacity += collection.Count;
            Array.Copy(collection.m_array, 0, m_array, m_count, collection.m_count);
            m_count += collection.Count;
        }
 // Operations (type-safe ICloneable)
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public UndoBlockCollection Clone()
 {
     var tc = new UndoBlockCollection();
     tc.AddRange(this);
     tc.Capacity = m_array.Length;
     tc.m_version = m_version;
     return tc;
 }
Beispiel #13
0
        /// <summary>
        /// Outdent the active selection one step
        /// </summary>
        public void Outdent(string Pattern)
        {
            if (!IsValid)
                return;

            Row xtr = null;
            var ActionGroup = new UndoBlockCollection();
            for (int i = LogicalBounds.FirstRow;
                 i <=
                 LogicalBounds.LastRow;
                 i++)
            {
                xtr = Control.Document[i];
                var b = new UndoBlock();
                b.Action = UndoAction.DeleteRange;
                b.Position.X = 0;
                b.Position.Y = i;
                ActionGroup.Add(b);
                string s = xtr.Text;
                if (s.StartsWith(Pattern))
                {
                    b.Text = s.Substring(0, Pattern.Length);
                    s = s.Substring(Pattern.Length);
                }
                xtr.Text = s;
            }
            if (ActionGroup.Count > 0)
                Control.Document.AddToUndoList(ActionGroup);
            Bounds = LogicalBounds;
            Bounds.FirstColumn = 0;
            Bounds.LastColumn = xtr.Text.Length;
            Control.Caret.Position.X = LogicalBounds.LastColumn;
            Control.Caret.Position.Y = LogicalBounds.LastRow;
        }
Beispiel #14
0
        public void Indent(string Pattern)
        {
            if (!IsValid)
                return;

            Row xtr = null;
            var ActionGroup = new UndoBlockCollection();
            for (int i = LogicalBounds.FirstRow;
                 i <=
                 LogicalBounds.LastRow;
                 i++)
            {
                xtr = Control.Document[i];
                xtr.Text = Pattern + xtr.Text;
                var b = new UndoBlock();
                b.Action = UndoAction.InsertRange;
                b.Text = Pattern;
                b.Position.X = 0;
                b.Position.Y = i;
                ActionGroup.Add(b);
            }
            if (ActionGroup.Count > 0)
                Control.Document.AddToUndoList(ActionGroup);
            Bounds = LogicalBounds;
            Bounds.FirstColumn = 0;
            Bounds.LastColumn = xtr.Text.Length;
            Control.Caret.Position.X = LogicalBounds.LastColumn;
            Control.Caret.Position.Y = LogicalBounds.LastRow;
        }