Exemple #1
0
 private void InsertText(TextBufferLocation location, ArrayList textList, bool addToUndo, bool loading)
 {
     if (!this._undoing)
     {
         this.RedoStack.Clear();
     }
     int count = textList.Count;
     if (count >= 1)
     {
         TextLine line = location.Line;
         int lineIndex = location.LineIndex;
         int columnIndex = location.ColumnIndex;
         TextLine next = line;
         int lineNum = lineIndex;
         int index = columnIndex;
         int lineIndexDelta = 0;
         bool flag = columnIndex < line.Length;
         for (int i = 0; i < count; i++)
         {
             char[] chars = (char[]) textList[i];
             int length = chars.Length;
             int num9 = 0;
             if (i > 0)
             {
                 next = next.Next;
                 lineNum++;
             }
             if (length > 0)
             {
                 next.Insert(index, chars, 0, length);
                 if (next == this._last.Line)
                 {
                     this._last.ColumnIndex = next.Length;
                 }
                 num9 = next.Length;
                 if (num9 > this._maxLineLength)
                 {
                     this._maxLineLength = num9;
                     this._maxLine = next;
                 }
                 index += length;
             }
             if (i < (count - 1))
             {
                 if (flag)
                 {
                     this.SplitLine(next, lineNum, index, true);
                 }
                 else
                 {
                     this.InsertLine(next, lineNum, true);
                 }
                 lineIndexDelta++;
                 index = 0;
             }
         }
         this.FixLocationLineNumbers(lineIndex, lineIndexDelta, next, lineNum, index);
         this._lineCount += lineIndexDelta;
         this._last.MoveDown(lineIndexDelta);
         this._last.ColumnIndex = this._last.Line.Length;
         if (addToUndo)
         {
             this.AddUndo(4, lineIndex, columnIndex, lineNum, index, textList);
         }
         if (!loading)
         {
             this.OnTextBufferChanged(new TextBufferEventArgs(lineIndex, columnIndex, lineIndex, columnIndex, lineNum, index));
         }
         location.SetLine(next, lineNum);
         location.ColumnIndex = index;
     }
 }
Exemple #2
0
        private void ProcessUndoUnit(UndoUnit unit, TextBufferLocation location)
        {
            TextBufferLocation location2 = this.CreateTextBufferLocation();
            location2.GotoLine(unit.StartLineNum);
            location2.ColumnIndex = unit.StartIndex;
            switch (unit.Command)
            {
                case 1:
                    this.DeleteChar(location2, false);
                    break;

                case 2:
                    this.InsertChar(location2, (char) unit.Data, false);
                    break;

                case 3:
                    this.InsertText(location2, (ArrayList) unit.Data, false);
                    break;

                case 4:
                {
                    TextBufferLocation end = this.CreateTextBufferLocation();
                    end.GotoLine(unit.EndLineNum);
                    end.ColumnIndex = unit.EndIndex;
                    this.DeleteText(new TextBufferSpan(location2, end), false);
                    end.Dispose();
                    break;
                }
            }
            if (location != null)
            {
                location.SetLine(location2.Line, location2.LineIndex);
                location.ColumnIndex = location2.ColumnIndex;
            }
            location2.Dispose();
        }
Exemple #3
0
 private bool DeleteLine(TextBufferLocation location)
 {
     TextLine line = location.Line;
     if (line == null)
     {
         return false;
     }
     TextLine previous = line.Previous;
     TextLine next = line.Next;
     bool flag = true;
     if (previous != null)
     {
         previous.Next = line.Next;
         if (next != null)
         {
             next.Previous = previous;
         }
         else
         {
             this._last.SetLine(previous, this._last.LineIndex - 1);
             this._last.ColumnIndex = this._last.Line.Length;
         }
         location.SetLine(previous, location.LineIndex - 1);
         this._lineCount--;
     }
     else if (next != null)
     {
         next.Previous = null;
         this._first.SetLine(next, 0);
         location.SetLine(next, 0);
         this._lineCount--;
     }
     else
     {
         line.Clear();
         flag = false;
     }
     if (flag)
     {
         this.FixLocationLineNumbers(location.LineIndex, -1, location.Line, location.LineIndex, location.ColumnIndex);
     }
     return true;
 }