コード例 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(UndoBlock item)
 {
     for (int i = 0; i < m_count; ++i)
     {
         if (m_array[i] == (item))
         {
             return(i);
         }
     }
     return(-1);
 }
コード例 #2
0
        // Operations (type-safe IList)

        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add(UndoBlock item)
        {
            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            m_array[m_count] = item;

            return(m_count++);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        public void Remove(UndoBlock item)
        {
            int index = IndexOf(item);

            if (index < 0)
            {
                throw new ArgumentException(
                          "Cannot remove the specified item because it was not found in the specified Collection.");
            }

            RemoveAt(index);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="position"></param>
        /// <param name="item"></param>
        public void Insert(int position, UndoBlock item)
        {
            ValidateIndex(position, true); // throws

            if (NeedsGrowth())
            {
                Grow();
            }

            ++m_version;
            // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1];
            Array.Copy(m_array, position, m_array, position + 1, m_count - position);

            m_array[position] = item;
            m_count++;
        }
コード例 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UndoBlock item)
 {
     return((IndexOf(item) == -1) ? false : true);
 }
コード例 #6
0
ファイル: EditViewControl.cs プロジェクト: westybsa/MP.LSharp
        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 ();
        }
コード例 #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="array"></param>
 public UndoBlockCollection(UndoBlock[] array)
 {
     AddRange(array);
 }
コード例 #8
0
ファイル: Selection.cs プロジェクト: vchelaru/FlatRedBall
        /// <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;
        }
コード例 #9
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
        public void AddToUndoList(UndoBlock undo)
        {
            //store the undo action in a actiongroup
            var ActionGroup = new UndoBlockCollection {undo};

            AddToUndoList(ActionGroup);
        }
コード例 #10
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int IndexOf(UndoBlock item)
 {
     for (int i = 0; i < m_count; ++i)
         if (m_array[i] == (item))
             return i;
     return - 1;
 }
コード例 #11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Contains(UndoBlock item)
 {
     return ((IndexOf(item) == - 1) ? false : true);
 }
コード例 #12
0
        // Operations (type-safe IList)

        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Add(UndoBlock item)
        {
            if (NeedsGrowth())
                Grow();

            ++m_version;
            m_array[m_count] = item;

            return m_count++;
        }
コード例 #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        /// <param name="start"></param>
        public void CopyTo(UndoBlock[] array, int start)
        {
            if (m_count > array.GetUpperBound(0) + 1 - start)
                throw new ArgumentException("Destination array was not long enough.");

            // for (int i=0; i < m_count; ++i) array[start+i] = m_array[i];
            Array.Copy(m_array, 0, array, start, m_count);
        }
コード例 #14
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="array"></param>
 public void CopyTo(UndoBlock[] array)
 {
     CopyTo(array, 0);
 }
コード例 #15
0
ファイル: SyntaxDocument.cs プロジェクト: attila3453/alsing
        public void PushUndoBlock(UndoAction Action, string Text, int x, int y, RowRevisionMark mark)
        {
            var undo = new UndoBlock();
            undo.Action = Action;
            undo.Text = Text;
            undo.Position.Y = y;
            undo.Position.X = x;
            undo.RowModified = (mark != RowRevisionMark.Unchanged);
            //AddToUndoList(undo);

            if (captureMode)
            {
                captureBlock.Add(undo);
            }
            else
            {
                AddToUndoList(undo);
            }
        }
コード例 #16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position"></param>
        /// <param name="item"></param>
        public void Insert(int position, UndoBlock item)
        {
            ValidateIndex(position, true); // throws

            if (NeedsGrowth())
                Grow();

            ++m_version;
            // for (int i=m_count; i > position; --i) m_array[i] = m_array[i-1];
            Array.Copy(m_array, position, m_array, position + 1, m_count - position);

            m_array[position] = item;
            m_count++;
        }
コード例 #17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="item"></param>
        public void Remove(UndoBlock item)
        {
            int index = IndexOf(item);
            if (index < 0)
                throw new ArgumentException(
                    "Cannot remove the specified item because it was not found in the specified Collection.");

            RemoveAt(index);
        }
コード例 #18
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
        public void PushUndoBlock(UndoAction Action, string text, int x, int y)
        {
            var undo = new UndoBlock {
                           Action = Action,
                           Text = text
                       };

            undo.Position.Y = y;
            undo.Position.X = x;
            //AddToUndoList(undo);

            if (captureMode)
            {
                captureBlock.Add(undo);
            }
            else
            {
                AddToUndoList(undo);
            }
        }
コード例 #19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="array"></param>
        public void AddRange(UndoBlock[] array)
        {
            // for (int i=0; i < array.Length; ++i) Add(array[i]);

            ++m_version;

            Capacity += array.Length;
            Array.Copy(array, 0, m_array, m_count, array.Length);
            m_count += array.Length;
        }
コード例 #20
0
ファイル: SyntaxDocument.cs プロジェクト: rogerluiz/devotion
        /// <summary>
        /// Insert a text at the specified row index
        /// </summary>
        /// <param name="text">Text to insert</param>
        /// <param name="index">Row index where the text should be inserted</param>
        /// <param name="storeUndo">true if and undo action should be added to the undo stack</param>
        /// <returns>The row that was inserted</returns>
        public Row Insert(string text, int index, bool storeUndo)
        {
            var xtl = new Row {Document = this};
            rows.Insert(index, xtl);
            xtl.Text = text;
            if (storeUndo)
            {
                var undo = new UndoBlock {
                               Text = text,
                               
                           };

                undo.Position.Y = IndexOf(xtl);
                AddToUndoList(undo);
            }

            //this.ResetVisibleRows ();
            return xtl;
        }
コード例 #21
0
ファイル: Selection.cs プロジェクト: vchelaru/FlatRedBall
        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;
        }