Skip to content

EditorState

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

User-owned mutable state for an editor widget. Multiple EditorWidgets can share the same EditorState for synced cursors. Multiple EditorStates can share the same IHex1bDocument for independent views.

csharp
public class EditorState

Inheritance

ObjectEditorState

Constructors

EditorState(IHex1bDocument)

Parameters:

csharp
public EditorState(IHex1bDocument document)

Properties

ByteCursorOffset

Byte-level cursor offset for renderers that navigate at byte granularity (e.g., hex editor). When non-null, this takes priority over the char-based cursor position for byte-oriented operations. Reset to null when cursor is moved by non-byte-aware operations.

Returns: Nullable<Int32>

csharp
public int? ByteCursorOffset { get; set; }

Cursor

The primary cursor. Alias for Cursors.Primary.

Returns: DocumentCursor

csharp
public DocumentCursor Cursor { get; }

Cursors

All cursors (sorted, non-overlapping). Use for multi-cursor access.

Returns: CursorSet

csharp
public CursorSet Cursors { get; }

Document

Returns: IHex1bDocument

csharp
public IHex1bDocument Document { get; }

History

Undo/redo history.

Returns: EditHistory

csharp
public EditHistory History { get; }

IsReadOnly

Returns: Boolean

csharp
public bool IsReadOnly { get; set; }

TabSize

Returns: Int32

csharp
public int TabSize { get; set; }

Methods

AddCursorAtNextMatch()

Add a cursor at the next occurrence of the currently selected text (Ctrl+D). If no text is selected, selects the word under the primary cursor.

csharp
public void AddCursorAtNextMatch()

AddCursorAtPosition(DocumentOffset)

Add a new cursor at the given document offset (Ctrl+Click). If a cursor already exists at this position, it is removed instead (toggle behavior).

Parameters:

csharp
public void AddCursorAtPosition(DocumentOffset offset)

ClampAllCursors()

Clamps all cursor and selection positions to the current document length. Call after an external edit (from another editor sharing the same document) that may have shrunk the document.

csharp
public void ClampAllCursors()

CollapseToSingleCursor()

Collapse all cursors to just the primary.

csharp
public void CollapseToSingleCursor()

DeleteBackward()

Delete the character before each cursor (Backspace).

csharp
public void DeleteBackward()

DeleteForward()

Delete the character after each cursor (Delete key).

csharp
public void DeleteForward()

DeleteLine()

Delete the entire current line for each cursor (Ctrl+Shift+K).

csharp
public void DeleteLine()

DeleteWordBackward()

Delete the word before each cursor (Ctrl+Backspace).

csharp
public void DeleteWordBackward()

DeleteWordForward()

Delete the word after each cursor (Ctrl+Delete).

csharp
public void DeleteWordForward()

InsertText(string)

Insert text at all cursor positions, replacing any selections.

Parameters:

csharp
public void InsertText(string text)

MoveCursor(CursorDirection, bool)

Move all cursors in a direction. With extend, selection is extended.

Parameters:

csharp
public void MoveCursor(CursorDirection direction, bool extend = false)

MovePageDown(int, bool)

Move all cursors down by viewport height (PageDown).

Parameters:

csharp
public void MovePageDown(int viewportLines, bool extend = false)

MovePageUp(int, bool)

Move all cursors up by viewport height (PageUp).

Parameters:

csharp
public void MovePageUp(int viewportLines, bool extend = false)

MoveToDocumentEnd(bool)

Move all cursors to end of document (Ctrl+End).

Parameters:

csharp
public void MoveToDocumentEnd(bool extend = false)

MoveToDocumentStart(bool)

Move all cursors to start of document (Ctrl+Home).

Parameters:

csharp
public void MoveToDocumentStart(bool extend = false)

MoveToLineEnd(bool)

Move all cursors to end of their current line (End).

Parameters:

csharp
public void MoveToLineEnd(bool extend = false)

MoveToLineStart(bool)

Move all cursors to start of their current line (Home).

Parameters:

csharp
public void MoveToLineStart(bool extend = false)

MoveWordLeft(bool)

Move all cursors to previous word boundary (Ctrl+Left).

Parameters:

csharp
public void MoveWordLeft(bool extend = false)

MoveWordRight(bool)

Move all cursors to next word boundary (Ctrl+Right).

Parameters:

csharp
public void MoveWordRight(bool extend = false)

Redo()

Redo the last undone edit group. Restores cursors to post-edit positions.

csharp
public void Redo()

SelectAll()

Select all text in the document (Ctrl+A). Collapses to single cursor.

csharp
public void SelectAll()

SelectLineAt(DocumentOffset)

Select the entire line at the given document offset. Collapses to single cursor. Used for mouse triple-click.

Parameters:

csharp
public void SelectLineAt(DocumentOffset offset)

SelectWordAt(DocumentOffset)

Select the word at the given document offset. Collapses to single cursor. Used for mouse double-click.

Parameters:

csharp
public void SelectWordAt(DocumentOffset offset)

SetCursorPosition(DocumentOffset, bool)

Set the primary cursor to a specific document offset, clearing selection and collapsing multi-cursors. Used for mouse click positioning.

Parameters:

csharp
public void SetCursorPosition(DocumentOffset offset, bool extend = false)

Undo()

Undo the last edit group. Restores cursors to pre-edit positions.

csharp
public void Undo()

Released under the MIT License.