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.
public class EditorStateInheritance
Object → EditorState
Constructors
EditorState(IHex1bDocument)
Parameters:
document(IHex1bDocument):
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>
public int? ByteCursorOffset { get; set; }Cursor
The primary cursor. Alias for Cursors.Primary.
Returns: DocumentCursor
public DocumentCursor Cursor { get; }Cursors
All cursors (sorted, non-overlapping). Use for multi-cursor access.
Returns: CursorSet
public CursorSet Cursors { get; }Document
Returns: IHex1bDocument
public IHex1bDocument Document { get; }History
Undo/redo history.
Returns: EditHistory
public EditHistory History { get; }IsReadOnly
Returns: Boolean
public bool IsReadOnly { get; set; }TabSize
Returns: Int32
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.
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:
offset(DocumentOffset):
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.
public void ClampAllCursors()CollapseToSingleCursor()
Collapse all cursors to just the primary.
public void CollapseToSingleCursor()DeleteBackward()
Delete the character before each cursor (Backspace).
public void DeleteBackward()DeleteForward()
Delete the character after each cursor (Delete key).
public void DeleteForward()DeleteLine()
Delete the entire current line for each cursor (Ctrl+Shift+K).
public void DeleteLine()DeleteWordBackward()
Delete the word before each cursor (Ctrl+Backspace).
public void DeleteWordBackward()DeleteWordForward()
Delete the word after each cursor (Ctrl+Delete).
public void DeleteWordForward()InsertText(string)
Insert text at all cursor positions, replacing any selections.
Parameters:
text(String):
public void InsertText(string text)MoveCursor(CursorDirection, bool)
Move all cursors in a direction. With extend, selection is extended.
Parameters:
direction(CursorDirection):extend(Boolean):
public void MoveCursor(CursorDirection direction, bool extend = false)MovePageDown(int, bool)
Move all cursors down by viewport height (PageDown).
Parameters:
public void MovePageDown(int viewportLines, bool extend = false)MovePageUp(int, bool)
Move all cursors up by viewport height (PageUp).
Parameters:
public void MovePageUp(int viewportLines, bool extend = false)MoveToDocumentEnd(bool)
Move all cursors to end of document (Ctrl+End).
Parameters:
extend(Boolean):
public void MoveToDocumentEnd(bool extend = false)MoveToDocumentStart(bool)
Move all cursors to start of document (Ctrl+Home).
Parameters:
extend(Boolean):
public void MoveToDocumentStart(bool extend = false)MoveToLineEnd(bool)
Move all cursors to end of their current line (End).
Parameters:
extend(Boolean):
public void MoveToLineEnd(bool extend = false)MoveToLineStart(bool)
Move all cursors to start of their current line (Home).
Parameters:
extend(Boolean):
public void MoveToLineStart(bool extend = false)MoveWordLeft(bool)
Move all cursors to previous word boundary (Ctrl+Left).
Parameters:
extend(Boolean):
public void MoveWordLeft(bool extend = false)MoveWordRight(bool)
Move all cursors to next word boundary (Ctrl+Right).
Parameters:
extend(Boolean):
public void MoveWordRight(bool extend = false)Redo()
Redo the last undone edit group. Restores cursors to post-edit positions.
public void Redo()SelectAll()
Select all text in the document (Ctrl+A). Collapses to single cursor.
public void SelectAll()SelectLineAt(DocumentOffset)
Select the entire line at the given document offset. Collapses to single cursor. Used for mouse triple-click.
Parameters:
offset(DocumentOffset):
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:
offset(DocumentOffset):
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:
offset(DocumentOffset):extend(Boolean):
public void SetCursorPosition(DocumentOffset offset, bool extend = false)Undo()
Undo the last edit group. Restores cursors to pre-edit positions.
public void Undo()