TextView Class
Represents a base class that can be used to implement an ITextView.
public abstract class TextView : UIElement, IInputElement, IUIElement, ILogicalTreeNode, IDpiAwareElement, IDisposable, ITextView
- Inheritance:
- object MarshalByRefObject MarshalByRefDisposableObject LogicalTreeNodeBase UIElement object
- Derived:
- EditorView
Constructors
TextView(SyntaxEditor, ITextSnapshot)
Initializes an instance of the class.
protected TextView(SyntaxEditor syntaxEditor, ITextSnapshot initialSnapshot)
| Parameter | Type | Description |
|---|---|---|
| syntaxEditor | SyntaxEditor | The SyntaxEditor that owns the object. |
| initialSnapshot | ITextSnapshot | The initial ITextSnapshot. |
Properties
ArePartiallyVisibleViewLinesAllowed
Indicates whether partially-visible view lines are allowed, other than the first visible view line.
protected virtual bool ArePartiallyVisibleViewLinesAllowed { get; }
Property Value
- bool:
trueif partially-visible view lines are allowed; otherwise,false.
ClassificationTagAggregator
The IClassificationTag aggregator for the view.
protected abstract ITagAggregator<IClassificationTag>? ClassificationTagAggregator { get; }
Property Value
CollapsedRegionManager
An ICollapsedRegionManager that provides information about collapsed regions in the view.
public abstract ICollapsedRegionManager? CollapsedRegionManager { get; }
Property Value
CurrentSnapshot
The ITextSnapshot that currently is used to populate the view.
DefaultBackgroundColor
The default background color.
DefaultCharacterWidth
The width of an average default font character in the view.
DefaultFontFamilyName
The default font family name.
DefaultFontSize
The default font size.
DefaultFontStyle
The default font style.
DefaultFontWeight
The default font weight.
DefaultForegroundColor
The default foreground color.
DefaultLineHeight
The default line height.
DefaultSpaceWidth
The width of a default font space character in the view.
HighlightingStyleRegistry
The IHighlightingStyleRegistry used by this view.
public abstract IHighlightingStyleRegistry HighlightingStyleRegistry { get; }
Property Value
IntraLineSpacerTagAggregator
The IIntraLineSpacerTag aggregator for the view.
protected abstract ITagAggregator<IIntraLineSpacerTag>? IntraLineSpacerTagAggregator { get; }
Property Value
IntraTextSpacerTagAggregator
The IIntraTextSpacerTag aggregator for the view.
protected abstract ITagAggregator<IIntraTextSpacerTag>? IntraTextSpacerTagAggregator { get; }
Property Value
IsDefaultBackgroundColorLight
Indicates whether the default background color of the editor is light.
public bool IsDefaultBackgroundColorLight { get; }
Property Value
- bool:
trueif the background color of the editor is light; otherwise,false.
IsWhitespaceVisible
Indicates whether whitespace (spaces and tabs) is visible.
public abstract bool IsWhitespaceVisible { get; }
Property Value
- bool:
trueif whitespace (spaces and tabs) is visible; otherwise,false.
Properties
The dictionary containing custom properties for this object.
RenderableTextRange
The text range that can be rendered.
protected virtual TextRange? RenderableTextRange { get; }
Property Value
Remarks
A value of null means no text range limitation.
ScrollState
The view's current scroll state.
ScrollableContentHostBounds
A Rectangle indicating the bounds of scrollable content host, relative to view coordinates.
SquiggleTagAggregator
The ISquiggleTag aggregator for the view.
protected virtual ITagAggregator<ISquiggleTag>? SquiggleTagAggregator { get; }
Property Value
SyntaxEditor
The SyntaxEditor that contains the view.
TextAreaPadding
The padding thickness around the text area content.
TextAreaSize
The size of the text area in text area coordinates.
TextAreaViewportBounds
A Rectangle indicating the bounds of visible portion of the text area, relative to view coordinates.
UniqueId
The Guid that uniquely identifies the view.
UnusedRegionTagAggregator
The IUnusedRegionTag aggregator for the view.
protected abstract ITagAggregator<IUnusedRegionTag>? UnusedRegionTagAggregator { get; }
Property Value
UseSyntaxEditorDisplayItemProperties
Indicates whether to use SyntaxEditor display item properties.
protected abstract bool UseSyntaxEditorDisplayItemProperties { get; }
Property Value
- bool:
trueif SyntaxEditor display item properties should be used; otherwise,false.
VisibleViewLines
The collection of ITextViewLine objects that are currently visible within the view.
public ITextViewLineCollection VisibleViewLines { get; }
Property Value
Remarks
The ITextViewLine items in this collection are sorted in their display order, top to bottom.
VisualElement
The IUIElement that represents the view.
WordWrapMode
A WordWrapMode value indicating the type of word wrapping that is performed.
WrappedLineIndentAmount
The number of characters to indent any wrapped lines beyond the original indent level of the primary line.
protected virtual int WrappedLineIndentAmount { get; }
Property Value
- int:
The default value is
2.
Remarks
A value of 2 will indent wrapped lines to the original indent level of the primary line, plus 2 additional character widths.
A value of 0 will indent wrapped lines to the original indent level of the primary line.
A value of -1 will not indent wrapped lines at all, and will simply align them to the left edge of the view.
The indent amount may be limited or altogether disabled if there is not enough available width in the view to support proper indentation.
ZoomLevel
A percentage value indicating the zoom level.
public int ZoomLevel { get; }
Property Value
- int:
A percentage value indicating the zoom level. The default value is
1.0, meaning100%.
Methods
Close()
Closes the view.
protected abstract void Close()
CreateTagAggregator<T>()
Creates a new ITagAggregator<T> that collects the tag results from all ITagger<T> instances associated with this view.
public abstract ITagAggregator<T> CreateTagAggregator<T>() where T : ITag
- Type Parameters:
-
T-The type of ITag associated with this aggregator.
Returns
GetAdornmentLayer(AdornmentLayerDefinition)
Returns an IAdornmentLayer for the view with the specified definition.
public abstract IAdornmentLayer GetAdornmentLayer(AdornmentLayerDefinition layerDefinition)
| Parameter | Type | Description |
|---|---|---|
| layerDefinition | AdornmentLayerDefinition | The layer definition. |
Returns
Remarks
If no IAdornmentLayer already exists with the specified name, one is created.
GetViewLine(TextPosition)
Returns an ITextViewLine that contains the specified TextPosition.
public ITextViewLine GetViewLine(TextPosition position)
| Parameter | Type | Description |
|---|---|---|
| position | TextPosition | The TextPosition for which to retrieve an ITextViewLine. |
Returns
GetViewLine(ITextViewLine, int, bool)
Returns the ITextViewLine that is relative to the specified ITextViewLine.
public ITextViewLine GetViewLine(ITextViewLine viewLine, int lineDelta, bool forceVirtualSpace = false)
| Parameter | Type | Description |
|---|---|---|
| viewLine | ITextViewLine | The source ITextViewLine. |
| lineDelta | int | The number of lines to traverse (can be negative). |
| forceVirtualSpace | bool | Whether to force virtual line space to be used as needed (for block selections). The default value is |
Returns
GetViewLine(int, bool)
Returns an ITextViewLine that contains the specified offset.
public ITextViewLine GetViewLine(int offset, bool hasFarAffinity = false)
| Parameter | Type | Description |
|---|---|---|
| offset | int | The offset for which to retrieve an ITextViewLine. |
| hasFarAffinity | bool | Whether the offset has affinity for the far side, which is used when the offset is where a view line is wrapped to a second view line.
The default value is |
Returns
InvalidateRender()
Invalidates and repaints the view's canvas.
public void InvalidateRender()
OffsetToPosition(int)
Returns the TextPosition that represents the specified offset within the view lines.
public TextPosition OffsetToPosition(int offset)
| Parameter | Type | Description |
|---|---|---|
| offset | int | The offset of a character within the document. |
Returns
OnClosed(EventArgs)
Occurs when the view's margins need to be destroyed.
protected virtual void OnClosed(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnMarginsDestroyed(EventArgs)
Occurs when the view's margins need to be destroyed.
protected virtual void OnMarginsDestroyed(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnPropertyChanged(PropertyChangedEventArgs)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | PropertyChangedEventArgs | The event data. |
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected void OnPropertyChanged(string? propertyName = null)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | (Optional) The name of the property that changed. |
OnRendered()
Occurs when rendering of the view is complete.
protected virtual void OnRendered()
OnScrollBarUpdateRequested(EventArgs)
Occurs when a scrollbar update is requested.
protected virtual void OnScrollBarUpdateRequested(EventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | The event data. |
OnScrollStatePropertyChanged(TextViewScrollState, TextViewScrollState)
Occurs when the ScrollState property is changed.
protected virtual void OnScrollStatePropertyChanged(TextViewScrollState oldValue, TextViewScrollState newValue)
| Parameter | Type | Description |
|---|---|---|
| oldValue | TextViewScrollState | The old value. |
| newValue | TextViewScrollState | The new value. |
OnTextAreaLayout(TextViewTextAreaLayoutEventArgs)
Occurs when the layout of the lines in the text area has been updated.
protected virtual void OnTextAreaLayout(TextViewTextAreaLayoutEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | TextViewTextAreaLayoutEventArgs | The event data. |
PerformLayout()
Ensures that the text area is updated with arranged view lines based on the current viewport size and scroll state.
public void PerformLayout()
PositionToOffset(TextPosition)
Returns the offset for the specified TextPosition within the view lines.
public int PositionToOffset(TextPosition position)
| Parameter | Type | Description |
|---|---|---|
| position | TextPosition | The TextPosition of a character within the view lines. |
Returns
SetProperty<T>(ref T, T, string?)
Called from a property setter to change the backing field's value and raise PropertyChanged notification events if the new value is not equal to the current value.
protected bool SetProperty<T>(ref T field, T newValue, string? propertyName = null)
- Type Parameters:
-
T-The type of the property that changed.
| Parameter | Type | Description |
|---|---|---|
| field | T | The backing field that holds the property's value, which may be updated. |
| newValue | T | The new property value. |
| propertyName | string | (Optional) The name of the property that changed. |
Returns
- bool:
trueif the property was changed; otherwise,false.
TransformFromTextArea(Point)
Transforms the specified Point in text area-relative coordinates to view-relative coordinates.
public abstract Point TransformFromTextArea(Point location)
| Parameter | Type | Description |
|---|---|---|
| location | Point | The Point to transform. |
Returns
TransformFromTextArea(Rectangle)
Transforms the specified Rectangle in text area-relative coordinates to view-relative coordinates.
public abstract Rectangle TransformFromTextArea(Rectangle bounds)
| Parameter | Type | Description |
|---|---|---|
| bounds | Rectangle | The Rectangle to transform. |
Returns
TransformToTextArea(Point)
Transforms the specified Point in view-relative coordinates to text area-relative coordinates.
public abstract Point TransformToTextArea(Point location)
| Parameter | Type | Description |
|---|---|---|
| location | Point | The Point to transform. |
Returns
TransformToTextArea(Rectangle)
Transforms the specified Rectangle in view-relative coordinates to text area-relative coordinates.
public abstract Rectangle TransformToTextArea(Rectangle bounds)
| Parameter | Type | Description |
|---|---|---|
| bounds | Rectangle | The Rectangle to transform. |
Returns
Events
Closed
Occurs when the view is closed.
MarginsDestroyed
Occurs when the view's margins need to be destroyed.
PropertyChanged
Occurs when a property value changes.
ScrollBarUpdateRequested
Occurs when a scrollbar update is requested.
TextAreaLayout
Occurs when the layout of the lines in the text area has been updated.
public event EventHandler<TextViewTextAreaLayoutEventArgs>? TextAreaLayout
Event Type
Inherited Members
- UIElement.Dispose(bool)
- UIElement.AddPendingGraphicsInversion(Rectangle)
- UIElement.AddPendingScrollOperation(Rectangle, Orientation, int)
- UIElement.AddPendingScrollOperation(Rectangle, int, int)
- UIElement.Arrange(Rectangle)
- UIElement.ArrangeOverride(Size)
- UIElement.CaptureMouse()
- UIElement.ContainsLocation(Point)
- UIElement.CreateGraphics()
- UIElement.DpiScaleChanged(SizeF)
- UIElement.GetCursor(Point)
- UIElement.GetDrawState()
- UIElement.Invalidate()
- UIElement.Invalidate(Rectangle)
- UIElement.Invalidate(InvalidationLevels, InvalidationTypes)
- UIElement.InvalidateArrange()
- UIElement.InvalidateMeasure()
- UIElement.Measure(Graphics, Size)
- UIElement.MeasureOverride(Graphics, Size)
- UIElement.OnClick(MouseEventArgs)
- UIElement.OnDoubleClick(MouseEventArgs)
- UIElement.OnMouseCaptureLost(EventArgs)
- UIElement.OnMouseDown(MouseEventArgs)
- UIElement.OnMouseEnter(MouseEventArgs)
- UIElement.OnMouseHover(MouseEventArgs)
- UIElement.OnMouseLeave(MouseEventArgs)
- UIElement.OnMouseMove(MouseEventArgs)
- UIElement.OnMouseUp(MouseEventArgs)
- UIElement.OnMouseWheel(MouseEventArgs)
- UIElement.OnParentChanged()
- UIElement.OnRender(PaintEventArgs)
- UIElement.OnRenderChildElements(PaintEventArgs)
- UIElement.OnResize(EventArgs)
- UIElement.PostArrangeOverride()
- UIElement.ReleaseMouseCapture()
- UIElement.Render(PaintEventArgs)
- UIElement.TransformToAncestor(IUIElement)
- UIElement.TransformToDescendant(IUIElement)
- UIElement.UpdateLayout()
- UIElement.ActualHeight
- UIElement.ActualWidth
- UIElement.Bounds
- UIElement.CaptureMouseWhenPressed
- UIElement.ClipBounds
- UIElement.DesiredSize
- UIElement.DpiScaleFactor
- UIElement.InvalidateOnMouseEvents
- UIElement.IsArrangeValid
- UIElement.IsMeasureValid
- UIElement.IsMouseCaptured
- UIElement.IsMouseDirectlyOver
- UIElement.IsRightToLeft
- UIElement.Size
- UIElement.VisualOffset
- UIElement.Click
- UIElement.DoubleClick
- UIElement.MouseCaptureLost
- UIElement.MouseDown
- UIElement.MouseEnter
- UIElement.MouseHover
- UIElement.MouseLeave
- UIElement.MouseMove
- UIElement.MouseUp
- UIElement.MouseWheel
- UIElement.Resize
- LogicalTreeNodeBase.CreateChildren()
- MarshalByRefDisposableObject.Dispose()
- MarshalByRefDisposableObject.VerifyNotDisposed()
- MarshalByRefDisposableObject.IsDisposed
- MarshalByRefDisposableObject.Disposed
- MarshalByRefObject.GetLifetimeService()
- MarshalByRefObject.InitializeLifetimeService()
- MarshalByRefObject.MemberwiseClone(bool)
- object.GetType()
- object.MemberwiseClone()
- object.ToString()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()