private void BlockUncomment(TextBufferSpan span)
 {
     this._nextHandler.HandleCommand(new TextBufferCommand(7));
     try
     {
         using (TextBufferLocation location = span.Start.Clone())
         {
             while (location.LineIndex <= span.End.LineIndex)
             {
                 int num = 0;
                 TextLine line = location.Line;
                 while ((num < line.Length) && char.IsWhiteSpace(line[num]))
                 {
                     num++;
                 }
                 if ((num < line.Length) && (line[num] == '\''))
                 {
                     location.ColumnIndex = num;
                     this._nextHandler.HandleCommand(new TextBufferCommand(2, location));
                     if ((num < line.Length) && (line[num] == ' '))
                     {
                         this._nextHandler.HandleCommand(new TextBufferCommand(2, location));
                     }
                 }
                 if (location.MoveDown(1) == 0)
                 {
                     return;
                 }
             }
         }
     }
     finally
     {
         this._nextHandler.HandleCommand(new TextBufferCommand(8));
     }
 }
 private void BlockComment(TextBufferSpan span)
 {
     this._nextHandler.HandleCommand(new TextBufferCommand(7));
     try
     {
         using (TextBufferLocation location = span.Start.Clone())
         {
             int lineIndex = span.End.LineIndex;
             if (span.End.ColumnIndex == 0)
             {
                 lineIndex--;
             }
             int num2 = 0x7fffffff;
             while (location.LineIndex <= lineIndex)
             {
                 int num3 = 0;
                 TextLine line = location.Line;
                 while ((num3 < line.Length) && char.IsWhiteSpace(line[num3]))
                 {
                     num3++;
                 }
                 num2 = Math.Min(num2, num3);
                 if (location.MoveDown(1) == 0)
                 {
                     break;
                 }
             }
             location.MoveTo(span.Start);
             while (location.LineIndex <= lineIndex)
             {
                 location.ColumnIndex = num2;
                 this._nextHandler.HandleCommand(new TextBufferCommand(4, location, "' "));
                 if (location.MoveDown(1) == 0)
                 {
                     return;
                 }
             }
         }
     }
     finally
     {
         this._nextHandler.HandleCommand(new TextBufferCommand(8));
     }
 }
Example #3
0
 internal void Select(TextBufferSpan span)
 {
     this._location.MoveTo(span.Start);
     this.ResetSelection();
     this._location.MoveTo(span.End);
     this.UpdateSelection();
     this.SetSmartCursorIndex();
 }
Example #4
0
 private void UpdateSelection()
 {
     int num = -1;
     int lineIndex = -1;
     if (this._selectionExists)
     {
         lineIndex = this._selection.Start.LineIndex;
         num = this._selection.End.LineIndex;
     }
     this._selectionEnd.MoveTo(this._location);
     this._selection = new TextBufferSpan(this._selectionStart, this._selectionEnd);
     if (this._selection.IsEmpty)
     {
         this.ResetSelection();
     }
     else
     {
         if (this._selectionExists)
         {
             int startLineIndex = this._selection.Start.LineIndex;
             int endLineIndex = this._selection.End.LineIndex;
             if ((lineIndex != startLineIndex) && (num != endLineIndex))
             {
                 this.AddDirtyLines(Math.Min(startLineIndex, lineIndex), Math.Max(endLineIndex, num) + 1);
             }
             else if (lineIndex < startLineIndex)
             {
                 this.AddDirtyLines(lineIndex, startLineIndex + 1);
             }
             else if (lineIndex > startLineIndex)
             {
                 this.AddDirtyLines(startLineIndex, lineIndex + 1);
             }
             else if (num < endLineIndex)
             {
                 this.AddDirtyLines(num, endLineIndex + 1);
             }
             else if (num > endLineIndex)
             {
                 this.AddDirtyLines(endLineIndex, num + 1);
             }
             else
             {
                 int top = this._location.LineIndex;
                 this.AddDirtyLines(top, top + 1);
             }
             this._owner.OnViewSelectionChanged(this);
         }
         else
         {
             this.AddDirtyLines(this._selection.Start.LineIndex, this._selection.End.LineIndex + 1);
             this._owner.OnViewSelectionChanged(this);
         }
         this._selectionExists = true;
     }
 }
 private void BlockComment(TextBufferSpan span)
 {
     using (TextBufferSpan span2 = this.ShrinkToText(span))
     {
         this._nextHandler.HandleCommand(new TextBufferCommand(7));
         try
         {
             this._nextHandler.HandleCommand(new TextBufferCommand(4, span2.End, "-->"));
             this._nextHandler.HandleCommand(new TextBufferCommand(4, span2.Start, "<!--"));
             span.Start.MoveTo(span2.Start);
             TextBufferLocation start = span.Start;
             start.ColumnIndex -= 4;
             span.End.MoveTo(span2.End);
             TextBufferLocation end = span.End;
             end.ColumnIndex += 4;
         }
         finally
         {
             this._nextHandler.HandleCommand(new TextBufferCommand(8));
         }
     }
 }
Example #6
0
 internal void ResetSelection()
 {
     if (this._selectionExists)
     {
         this.AddDirtyLines(this._selection.Start.LineIndex, this._selection.End.LineIndex + 1);
         this._selectionExists = false;
         this._selection = null;
         this._owner.OnViewSelectionChanged(this);
     }
     this._selectionStart.MoveTo(this._location);
     this._selectionEnd.MoveTo(this._location);
 }
 private void BlockUncomment(TextBufferSpan span)
 {
     using (TextBufferSpan span2 = this.ShrinkToText(span))
     {
         this._nextHandler.HandleCommand(new TextBufferCommand(7));
         try
         {
             if (((span2.Start.ColumnIndex < (span2.Start.Line.Length - 3)) && (span2.Start.Line.Substring(span2.Start.ColumnIndex, 4) == "<!--")) && ((span2.End.ColumnIndex > 3) && (span2.End.Line.Substring(span2.End.ColumnIndex - 3, 3) == "-->")))
             {
                 using (TextBufferLocation location = span2.End.Clone())
                 {
                     using (TextBufferLocation location2 = span2.End.Clone())
                     {
                         location.ColumnIndex -= 3;
                         this._nextHandler.HandleCommand(new TextBufferCommand(3, location, location2));
                         span.End.MoveTo(location2);
                         location.MoveTo(span2.Start);
                         location2.MoveTo(span2.Start);
                         location2.ColumnIndex += 4;
                         this._nextHandler.HandleCommand(new TextBufferCommand(3, location, location2));
                         span.Start.MoveTo(location2);
                     }
                 }
             }
         }
         finally
         {
             this._nextHandler.HandleCommand(new TextBufferCommand(8));
         }
     }
 }
 private TextBufferSpan ShrinkToText(TextBufferSpan originalSpan)
 {
     TextBufferSpan span = new TextBufferSpan(originalSpan.Start.Clone(), originalSpan.End.Clone());
     bool flag = true;
     while (flag)
     {
         if (span.Start.ColumnIndex == span.Start.Line.Length)
         {
             if (span.Start.MoveDown(1) != 1)
             {
                 break;
             }
             span.Start.ColumnIndex = 0;
             if (span.IsEmpty)
             {
                 break;
             }
         }
         flag = char.IsWhiteSpace(span.Start.Line[span.Start.ColumnIndex]);
         if (flag)
         {
             TextBufferLocation start = span.Start;
             start.ColumnIndex++;
         }
         if (span.IsEmpty)
         {
             break;
         }
     }
     if (!span.IsEmpty)
     {
         flag = true;
         while (flag)
         {
             if (span.End.ColumnIndex == 0)
             {
                 if (span.End.MoveUp(1) != 1)
                 {
                     break;
                 }
                 span.End.ColumnIndex = span.End.Line.Length;
                 if (span.IsEmpty)
                 {
                     break;
                 }
             }
             if (char.IsWhiteSpace(span.End.Line[span.End.ColumnIndex - 1]))
             {
                 TextBufferLocation end = span.End;
                 end.ColumnIndex--;
             }
             if (span.IsEmpty)
             {
                 break;
             }
         }
     }
     if (span.IsEmpty)
     {
         span.Start.MoveTo(originalSpan.Start);
         span.End.MoveTo(originalSpan.End);
     }
     return span;
 }
Example #9
0
 public void Select(TextBufferSpan span)
 {
     if (span == null)
     {
         throw new ArgumentNullException("span");
     }
     if (this.ActiveView != null)
     {
         this.ActiveView.Select(span);
     }
 }
Example #10
0
 public bool Contains(TextBufferSpan span)
 {
     return (this.Contains(span.Start) && this.Contains(span.End));
 }
Example #11
0
 private void DeleteText(TextBufferSpan span, bool addToUndo)
 {
     if (!this._undoing)
     {
         this.RedoStack.Clear();
     }
     TextBufferLocation start = span.Start;
     TextBufferLocation end = span.End;
     TextLine line = start.Line;
     TextLine line2 = end.Line;
     ArrayList data = new ArrayList((end.LineIndex - start.LineIndex) + 1);
     int lineIndex = start.LineIndex;
     int columnIndex = start.ColumnIndex;
     int endLine = end.LineIndex;
     int endIndex = end.ColumnIndex;
     if (line == line2)
     {
         int length = end.ColumnIndex - start.ColumnIndex;
         if (length > 0)
         {
             data.Add(line.ToCharArray(start.ColumnIndex, length));
             if (end.ColumnIndex == line.Length)
             {
                 line.Delete(start.ColumnIndex);
             }
             else
             {
                 line.Delete(start.ColumnIndex, length);
             }
             if (line == this._last.Line)
             {
                 this._last.ColumnIndex = this._last.Line.Length;
             }
         }
     }
     else
     {
         int num6 = line.Length - start.ColumnIndex;
         data.Add(line.ToCharArray(start.ColumnIndex, num6));
         TextLine next = line.Next;
         int num7 = 0;
         while (next != line2)
         {
             data.Add(next.ToCharArray());
             next = next.Next;
             num7++;
         }
         data.Add(line2.ToCharArray(0, end.ColumnIndex));
         line.Delete(start.ColumnIndex);
         line.Next = next;
         line2.Previous = line;
         if (end.ColumnIndex > 0)
         {
             line2.Delete(0, end.ColumnIndex);
             if (line2 == this._last.Line)
             {
                 this._last.ColumnIndex = this._last.Line.Length;
             }
         }
         if (num7 > 0)
         {
             this.FixLocationLineNumbers(start.LineIndex, -num7, start.Line, start.LineIndex, start.ColumnIndex);
         }
         this.MergeWithNextLine(start);
         this._lineCount -= num7;
     }
     if (addToUndo && (data.Count > 0))
     {
         this.AddUndo(3, lineIndex, columnIndex, endLine, endIndex, data);
     }
     this.OnTextBufferChanged(new TextBufferEventArgs(lineIndex, columnIndex, endLine, endIndex, lineIndex, columnIndex));
     end.SetLine(start.Line, start.LineIndex);
     end.ColumnIndex = start.ColumnIndex;
 }
Example #12
0
 public bool ReplaceText(TextBufferSpan span, ArrayList textList)
 {
     this.BeginBatchUndo();
     try
     {
         if (span.IsEmpty)
         {
             this.DeleteText(span, true);
         }
         if (textList.Count > 0)
         {
             this.InsertText(span.Start, textList, true);
         }
     }
     finally
     {
         this.EndBatchUndo();
     }
     return true;
 }
Example #13
0
 public void DeleteText(TextBufferSpan span)
 {
     this.DeleteText(span, true);
 }