Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project/Src/Document/LineManager/LineSegmentTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public Enumerator GetEnumeratorForOffset(int offset)

internal struct RBNode
{
internal LineSegment lineSegment;
internal readonly LineSegment lineSegment;
internal int count;
internal int totalLength;

Expand Down Expand Up @@ -449,4 +449,4 @@ public string GetTreeAsString()
}
#endif
}
}
}
4 changes: 2 additions & 2 deletions Project/Src/Document/MarkerStrategy/TextMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TextMarker(int offset, int length, TextMarkerType textMarkerType) : this(
{
}

public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color)
public TextMarker(int offset, int length, TextMarkerType textMarkerType, in Color color)
{
if (length < 1) length = 1;
this.offset = offset;
Expand All @@ -40,7 +40,7 @@ public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color c
Color = color;
}

public TextMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor)
public TextMarker(int offset, int length, TextMarkerType textMarkerType, in Color color, in Color foreColor)
{
Comment on lines 41 to 44
if (length < 1) length = 1;
this.offset = offset;
Expand Down
21 changes: 11 additions & 10 deletions Project/Src/Document/Selection/SelectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace ICSharpCode.TextEditor.Document
Expand All @@ -21,7 +22,7 @@ public class SelectionManager : IDisposable
private IDocument document;
internal SelectFrom selectFrom = new SelectFrom();

internal List<ISelection> selectionCollection = new List<ISelection>();
internal readonly List<ISelection> selectionCollection = [];
private TextLocation selectionStart;

/// <summary>
Expand Down Expand Up @@ -69,7 +70,7 @@ public bool SelectionIsReadonly
{
if (document.ReadOnly)
return true;
foreach (var sel in selectionCollection)
foreach (ISelection sel in CollectionsMarshal.AsSpan(selectionCollection))
if (SelectionIsReadOnly(document, sel))
return true;
return false;
Expand All @@ -87,7 +88,7 @@ public string SelectedText

// PriorityQueue queue = new PriorityQueue();

foreach (var s in selectionCollection) builder.Append(s.SelectedText);
foreach (ISelection s in CollectionsMarshal.AsSpan(selectionCollection)) builder.Append(s.SelectedText);
// queue.Insert(-s.Offset, s);

// while (queue.Count > 0) {
Expand Down Expand Up @@ -297,7 +298,7 @@ public void RemoveSelectedText()
var offset = -1;
var oneLine = true;
// PriorityQueue queue = new PriorityQueue();
foreach (var s in selectionCollection)
foreach (ISelection s in CollectionsMarshal.AsSpan(selectionCollection))
{
// ISelection s = ((ISelection)queue.Remove());
if (oneLine)
Expand Down Expand Up @@ -325,7 +326,7 @@ public void RemoveSelectedText()
if (offset != -1)
{
if (oneLine)
foreach (var i in lines)
foreach (int i in CollectionsMarshal.AsSpan(lines))
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.SingleLine, i));
else
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
Expand Down Expand Up @@ -358,7 +359,7 @@ public bool IsSelected(int offset)
/// </returns>
public ISelection GetSelectionAt(int offset)
{
foreach (var s in selectionCollection)
foreach (ISelection s in CollectionsMarshal.AsSpan(selectionCollection))
if (s.ContainsOffset(offset))
return s;
return null;
Expand Down Expand Up @@ -408,7 +409,7 @@ internal void Replace(int offset, int length, string text)

public ColumnRange GetSelectionAtLine(int lineNumber)
{
foreach (var selection in selectionCollection)
foreach (ISelection selection in CollectionsMarshal.AsSpan(selectionCollection))
{
var startLine = selection.StartPosition.Y;
var endLine = selection.EndPosition.Y;
Expand Down Expand Up @@ -447,17 +448,17 @@ protected virtual void OnSelectionChanged(EventArgs e)
}

// selection initiated from...
internal class SelectFrom
internal sealed class SelectFrom
{
public int first = WhereFrom.None; // first selection initiator
public int where = WhereFrom.None; // last selection initiator
}

// selection initiated from type...
internal class WhereFrom
internal sealed class WhereFrom
{
public const int None = 0;
public const int Gutter = 1;
public const int TArea = 2;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class GapTextBufferStrategy : ITextBufferStrategy
private const int minGapLength = 128;
private const int maxGapLength = 2048;

private char[] buffer = new char[0];
private char[] buffer = [];
private string cachedContent;

private int gapBeginOffset;
Expand Down Expand Up @@ -181,4 +181,4 @@ private void CheckThread()
}
#endif
}
}
}
4 changes: 2 additions & 2 deletions Project/Src/Gui/AbstractMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ICSharpCode.TextEditor
{
public delegate void MarginMouseEventHandler(AbstractMargin sender, Point mousepos, MouseButtons mouseButtons);

public delegate void MarginPaintEventHandler(AbstractMargin sender, Graphics g, Rectangle rect);
public delegate void MarginPaintEventHandler(AbstractMargin sender, Graphics g, in Rectangle rect);

Comment on lines 15 to 18
/// <summary>
/// This class views the line numbers and folding markers.
Expand Down Expand Up @@ -78,7 +78,7 @@ public virtual void SelectedLineChanged(int line)
textArea.Invalidate();
}

public virtual void Paint(Graphics g, Rectangle rect)
public virtual void Paint(Graphics g, in Rectangle rect)
{
Painted?.Invoke(this, g, rect);
}
Comment on lines +81 to 84
Expand Down
4 changes: 2 additions & 2 deletions Project/Src/Gui/Caret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public virtual void Dispose()
public abstract void Destroy();
}

private class ManagedCaret : CaretImplementation
private sealed class ManagedCaret : CaretImplementation
{
private readonly Caret parentCaret;
private readonly TextArea textArea;
Expand Down Expand Up @@ -467,7 +467,7 @@ public override void Dispose()
}
}

private class Win32Caret : CaretImplementation
private sealed class Win32Caret : CaretImplementation
{
private readonly TextArea textArea;

Expand Down
2 changes: 1 addition & 1 deletion Project/Src/Gui/DrawableLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public float MeasureWidth(Graphics g, float xPos)
return xPos;
}

private class SimpleTextWord
private sealed class SimpleTextWord
{
internal static readonly SimpleTextWord Space = new SimpleTextWord(TextWordType.Space, " ", Bold: false, SystemColors.WindowText);
internal static readonly SimpleTextWord Tab = new SimpleTextWord(TextWordType.Tab, "\t", Bold: false, SystemColors.WindowText);
Expand Down
4 changes: 2 additions & 2 deletions Project/Src/Gui/FoldMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public FoldMargin(TextArea textArea) : base(textArea)

public override bool IsVisible => textArea.TextEditorProperties.EnableFolding;

public override void Paint(Graphics g, Rectangle rect)
public override void Paint(Graphics g, in Rectangle rect)
{
if (rect.Width <= 0 || rect.Height <= 0)
return;
Expand Down Expand Up @@ -229,7 +229,7 @@ public override void HandleMouseLeave(EventArgs e)

#region Drawing functions

private void DrawFoldMarker(Graphics g, RectangleF rectangle, bool isOpened, bool isSelected)
private void DrawFoldMarker(Graphics g, in RectangleF rectangle, bool isOpened, bool isSelected)
{
var foldMarkerColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldMarker");
var foldLineColor = textArea.Document.HighlightingStrategy.GetColorFor("FoldLine");
Expand Down
2 changes: 1 addition & 1 deletion Project/Src/Gui/GutterMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void Dispose()
numberStringFormat.Dispose();
}

public override void Paint(Graphics g, Rectangle rect)
public override void Paint(Graphics g, in Rectangle rect)
{
if (rect.Width <= 0 || rect.Height <= 0)
return;
Expand Down
2 changes: 1 addition & 1 deletion Project/Src/Gui/IconBarMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public IconBarMargin(TextArea textArea) : base(textArea)

public override bool IsVisible => textArea.TextEditorProperties.IsIconBarVisible;

public override void Paint(Graphics g, Rectangle rect)
public override void Paint(Graphics g, in Rectangle rect)
{
if (rect.Width <= 0 || rect.Height <= 0)
return;
Expand Down
12 changes: 6 additions & 6 deletions Project/Src/Gui/Ime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ICSharpCode.TextEditor
/// <summary>
/// Used internally, not for own use.
/// </summary>
internal class Ime
internal sealed class Ime
{
private const int WM_IME_CONTROL = 0x0283;

Expand Down Expand Up @@ -147,22 +147,22 @@ private static void Handle(Exception ex)
}

[StructLayout(LayoutKind.Sequential)]
private class COMPOSITIONFORM
private sealed class COMPOSITIONFORM
{
public int dwStyle;
public POINT ptCurrentPos;
public RECT rcArea;
}

[StructLayout(LayoutKind.Sequential)]
private class POINT
private sealed class POINT
{
public int x;
public int y;
}

[StructLayout(LayoutKind.Sequential)]
private class RECT
private sealed class RECT
{
public int bottom = 0;
public int left = 0;
Expand All @@ -171,7 +171,7 @@ private class RECT
}

[StructLayout(LayoutKind.Sequential)]
private class LOGFONT
private sealed class LOGFONT
{
public byte lfCharSet = 0;
public byte lfClipPrecision = 0;
Expand All @@ -192,4 +192,4 @@ private class LOGFONT
public int lfWidth = 0;
}
}
}
}
4 changes: 2 additions & 2 deletions Project/Src/Gui/InsightWindow/InsightWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private void CloseCurrentDataProvider()
Refresh();
}

private class InsightDataProviderStackElement
private sealed class InsightDataProviderStackElement
{
public readonly IInsightDataProvider dataProvider;
public int currentData;
Expand All @@ -206,4 +206,4 @@ public InsightDataProviderStackElement(IInsightDataProvider dataProvider)

#endregion
}
}
}
4 changes: 2 additions & 2 deletions Project/Src/Gui/TextEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private float MeasurePrintingHeight(Graphics g, LineSegment line, float maxWidth
return yPos + fontHeight;
}

private void DrawLine(Graphics g, LineSegment line, float yPos, RectangleF margin)
private void DrawLine(Graphics g, LineSegment line, float yPos, in RectangleF margin)
{
float xPos = 0;
var fontHeight = Font.GetHeight(g);
Expand Down Expand Up @@ -377,4 +377,4 @@ private void PrintPage(object sender, PrintPageEventArgs ev)

#endregion
}
}
}
12 changes: 6 additions & 6 deletions Project/Src/Gui/TextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void OptionsChanged()

#region Paint functions

public override void Paint(Graphics g, Rectangle rect)
public override void Paint(Graphics g, in Rectangle rect)
{
if (rect.Width <= 0 || rect.Height <= 0)
return;
Expand Down Expand Up @@ -117,7 +117,7 @@ public override void Paint(Graphics g, Rectangle rect)
{
// var fvl = textArea.Document.GetVisibleLine(FirstVisibleLine);
var currentLine = textArea.Document.GetFirstLogicalLine(textArea.Document.GetVisibleLine(FirstVisibleLine) + y);
PaintDocumentLine(g, currentLine, lineRectangle);
PaintDocumentLine(g, currentLine, in lineRectangle);
}
}

Expand All @@ -128,7 +128,7 @@ public override void Paint(Graphics g, Rectangle rect)
textArea.Caret.PaintCaret(g);
}

private void PaintDocumentLine(Graphics g, int lineNumber, Rectangle lineRectangle)
private void PaintDocumentLine(Graphics g, int lineNumber, in Rectangle lineRectangle)
{
Debug.Assert(lineNumber >= 0);
var bgColorBrush = GetBgColorBrush(lineNumber);
Expand Down Expand Up @@ -268,7 +268,7 @@ private readonly struct MarkerToDraw
internal readonly TextMarker marker;
internal readonly RectangleF drawingRect;

public MarkerToDraw(TextMarker marker, RectangleF drawingRect)
public MarkerToDraw(TextMarker marker, in RectangleF drawingRect)
{
this.marker = marker;
this.drawingRect = drawingRect;
Expand All @@ -277,7 +277,7 @@ public MarkerToDraw(TextMarker marker, RectangleF drawingRect)

private readonly List<MarkerToDraw> markersToDraw = new List<MarkerToDraw>();

private void DrawMarker(TextMarker marker, RectangleF drawingRect)
private void DrawMarker(TextMarker marker, in RectangleF drawingRect)
{
// draw markers later so they can overdraw the following text
markersToDraw.Add(new MarkerToDraw(marker, drawingRect));
Expand Down Expand Up @@ -1092,7 +1092,7 @@ private int DrawEOLMarker(Graphics g, Brush backBrush, int x, int y, EolMarker e
return eolMarkerWidth;
}

private void DrawVerticalRuler(Graphics g, Rectangle lineRectangle)
private void DrawVerticalRuler(Graphics g, in Rectangle lineRectangle)
{
var xpos = WideSpaceWidth*TextEditorProperties.VerticalRulerRow - textArea.VirtualTop.X;
if (xpos <= 0)
Expand Down
4 changes: 2 additions & 2 deletions Project/Src/Undo/UndoStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected void OnActionRedone()
ActionRedone?.Invoke(sender: null, e: null);
}

private class UndoableSetCaretPosition : IUndoableOperation
private sealed class UndoableSetCaretPosition : IUndoableOperation
{
private readonly TextLocation pos;
private readonly UndoStack stack;
Expand Down Expand Up @@ -217,4 +217,4 @@ public OperationEventArgs(IUndoableOperation op)
}

public delegate void OperationEventHandler(object sender, OperationEventArgs e);
}
}
4 changes: 2 additions & 2 deletions Project/Src/Util/LookupTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public object this[string keyword]
}
}

private class Node
private sealed class Node
{
private Node[] children;
public object color;
Expand All @@ -151,4 +151,4 @@ public Node this[int index]
}
}
}
}
}
Loading