Skip to content

DocumentCursor

Namespace: Hex1b.Documents

Assembly: Hex1b.dll

Represents a cursor position in a document with optional selection.

csharp
public class DocumentCursor

Inheritance

ObjectDocumentCursor

Properties

HasSelection

Returns: Boolean

csharp
public bool HasSelection { get; }

Position

The cursor position as an absolute document offset.

Returns: DocumentOffset

csharp
public DocumentOffset Position { get; set; }

SelectionAnchor

The selection anchor. When non-null, text between anchor and position is selected.

Returns: Nullable<DocumentOffset>

csharp
public DocumentOffset? SelectionAnchor { get; set; }

SelectionEnd

Returns: DocumentOffset

csharp
public DocumentOffset SelectionEnd { get; }

SelectionRange

Returns: DocumentRange

csharp
public DocumentRange SelectionRange { get; }

SelectionStart

Returns: DocumentOffset

csharp
public DocumentOffset SelectionStart { get; }

Methods

Clamp(int)

Clamp cursor and anchor to valid range.

Parameters:

csharp
public void Clamp(int documentLength)

ClearSelection()

csharp
public void ClearSelection()

EnsureSelectionAnchor()

Sets the selection anchor to the current position if not already set. Used by the extend pattern: first Shift+move sets anchor, subsequent moves extend.

csharp
public void EnsureSelectionAnchor()

Released under the MIT License.