Browse Source

fixed warnings and added missing documentation

pull/23/head
Siegfried Pammer 14 years ago
parent
commit
b7bfda0539
  1. 6
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs
  2. 8
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs
  3. 9
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs
  4. 23
      src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

6
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs

@ -102,7 +102,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -102,7 +102,7 @@ namespace ICSharpCode.AvalonEdit.Editing
/// </summary>
public TextLocation Location {
get {
return position;
return position.Location;
}
set {
this.Position = new TextViewPosition(value);
@ -174,7 +174,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -174,7 +174,7 @@ namespace ICSharpCode.AvalonEdit.Editing
if (document == null) {
return 0;
} else {
return document.GetOffset(position);
return document.GetOffset(position.Location);
}
}
set {
@ -279,7 +279,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -279,7 +279,7 @@ namespace ICSharpCode.AvalonEdit.Editing
// mark column as validated
visualColumnValid = true;
int caretOffset = textView.Document.GetOffset(position);
int caretOffset = textView.Document.GetOffset(position.Location);
int firstDocumentLineOffset = visualLine.FirstDocumentLine.Offset;
position.VisualColumn = visualLine.ValidateVisualColumn(position, textArea.Selection.EnableVirtualSpace);

8
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/RectangleSelection.cs

@ -45,8 +45,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -45,8 +45,8 @@ namespace ICSharpCode.AvalonEdit.Editing
this.endLine = end.Line;
this.startXPos = GetXPos(textArea, start);
this.endXPos = GetXPos(textArea, end);
this.startOffset = document.GetOffset(start);
this.endOffset = document.GetOffset(end);
this.startOffset = document.GetOffset(start.Location);
this.endOffset = document.GetOffset(end.Location);
CalculateSegments();
}
@ -59,7 +59,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -59,7 +59,7 @@ namespace ICSharpCode.AvalonEdit.Editing
this.startXPos = startXPos;
this.endXPos = GetXPos(textArea, end);
this.startOffset = startOffset;
this.endOffset = document.GetOffset(end);
this.endOffset = document.GetOffset(end.Location);
CalculateSegments();
}
@ -71,7 +71,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -71,7 +71,7 @@ namespace ICSharpCode.AvalonEdit.Editing
this.endLine = endLine;
this.startXPos = GetXPos(textArea, start);
this.endXPos = endXPos;
this.startOffset = document.GetOffset(start);
this.startOffset = document.GetOffset(start.Location);
this.endOffset = endOffset;
CalculateSegments();
}

9
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Selection.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -35,7 +35,7 @@ namespace ICSharpCode.AvalonEdit.Editing
{
if (textArea == null)
throw new ArgumentNullException("textArea");
if (textArea.Document.GetOffset(start) == textArea.Document.GetOffset(end) && start.VisualColumn == end.VisualColumn)
if (textArea.Document.GetOffset(start.Location) == textArea.Document.GetOffset(end.Location) && start.VisualColumn == end.VisualColumn)
return textArea.emptySelection;
else
return new SimpleSelection(textArea, start, end);
@ -112,6 +112,9 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -112,6 +112,9 @@ namespace ICSharpCode.AvalonEdit.Editing
get { return Length == 0; }
}
/// <summary>
/// Gets whether virtual space is enabled for this selection.
/// </summary>
public virtual bool EnableVirtualSpace {
get { return textArea.Options.EnableVirtualSpace; }
}
@ -128,8 +131,8 @@ namespace ICSharpCode.AvalonEdit.Editing @@ -128,8 +131,8 @@ namespace ICSharpCode.AvalonEdit.Editing
public abstract Selection SetEndpoint(TextViewPosition endPosition);
/// <summary>
/// If this selection is empty, starts a new selection from <paramref name="startOffset"/> to
/// <paramref name="newEndOffset"/>, otherwise, changes the endpoint of this selection.
/// If this selection is empty, starts a new selection from <paramref name="startPosition"/> to
/// <paramref name="endPosition"/>, otherwise, changes the endpoint of this selection.
/// </summary>
public abstract Selection StartSelectionOrSetEndpoint(TextViewPosition startPosition, TextViewPosition endPosition);

23
src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Rendering/VisualLine.cs

@ -65,6 +65,9 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -65,6 +65,9 @@ namespace ICSharpCode.AvalonEdit.Rendering
/// </summary>
public int VisualLength { get; private set; }
/// <summary>
/// Length in visual line coordinates including the end of line marker, if TextEditorOptions.ShowEndOfLine is enabled.
/// </summary>
public int VisualLengthWithEndOfLineMarker {
get {
int length = VisualLength;
@ -346,11 +349,19 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -346,11 +349,19 @@ namespace ICSharpCode.AvalonEdit.Rendering
return GetVisualColumn(point, textView.Options.EnableVirtualSpace);
}
/// <summary>
/// Gets the visual column from a document position (relative to top left of the document).
/// If the user clicks between two visual columns, rounds to the nearest column.
/// </summary>
public int GetVisualColumn(Point point, bool allowVirtualSpace)
{
return GetVisualColumn(GetTextLineByVisualYPosition(point.Y), point.X, allowVirtualSpace);
}
/// <summary>
/// Gets the visual column from a document position (relative to top left of the document).
/// If the user clicks between two visual columns, rounds to the nearest column.
/// </summary>
public int GetVisualColumn(TextLine textLine, double xPos, bool allowVirtualSpace)
{
if (xPos > textLine.WidthIncludingTrailingWhitespace) {
@ -363,11 +374,17 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -363,11 +374,17 @@ namespace ICSharpCode.AvalonEdit.Rendering
return ch.FirstCharacterIndex + ch.TrailingLength;
}
/// <summary>
/// Validates the visual column and returns the correct one.
/// </summary>
public int ValidateVisualColumn(TextViewPosition position, bool allowVirtualSpace)
{
return ValidateVisualColumn(Document.GetOffset(position), position.VisualColumn, allowVirtualSpace);
return ValidateVisualColumn(Document.GetOffset(position.Location), position.VisualColumn, allowVirtualSpace);
}
/// <summary>
/// Validates the visual column and returns the correct one.
/// </summary>
public int ValidateVisualColumn(int offset, int visualColumn, bool allowVirtualSpace)
{
int firstDocumentLineOffset = this.FirstDocumentLine.Offset;
@ -396,6 +413,10 @@ namespace ICSharpCode.AvalonEdit.Rendering @@ -396,6 +413,10 @@ namespace ICSharpCode.AvalonEdit.Rendering
return GetVisualColumnFloor(point, textView.Options.EnableVirtualSpace);
}
/// <summary>
/// Gets the visual column from a document position (relative to top left of the document).
/// If the user clicks between two visual columns, returns the first of those columns.
/// </summary>
public int GetVisualColumnFloor(Point point, bool allowVirtualSpace)
{
TextLine textLine = GetTextLineByVisualYPosition(point.Y);

Loading…
Cancel
Save