Skip to content

IEditorViewRenderer

Namespace: Hex1b

Assembly: Hex1b.dll

Renders a view of a document within an editor viewport. Implementations define how document content is visualized (text, hex, etc.). The EditorNode delegates rendering and hit testing to the active renderer.

csharp
public interface IEditorViewRenderer

Properties

HandlesCharInput

Whether this renderer intercepts character input (e.g., hex byte editing). When true, is called instead of the default text insertion for printable characters.

Returns: Boolean

csharp
bool HandlesCharInput { get; }

Methods

GetMaxLineWidth(IHex1bDocument, int, int, int)

Returns the maximum visual width (in columns) needed for any line. Used for horizontal scroll calculations. For text view, this is the longest line length. For hex view, this is the computed row width (always ≤ viewport, so no horizontal scroll).

Parameters:

Returns: Int32

csharp
int GetMaxLineWidth(IHex1bDocument document, int scrollOffset, int viewportLines, int viewportColumns)

GetTotalLines(IHex1bDocument, int)

Returns the total number of visual lines this renderer needs for the document. For text view, this equals the document line count. For hex view, this depends on bytes per row (which may adapt to viewport width).

Parameters:

  • document (IHex1bDocument): The document being rendered.
  • viewportColumns (Int32): Available width in columns. Responsive renderers use this to adapt layout.

Returns: Int32

csharp
int GetTotalLines(IHex1bDocument document, int viewportColumns)

HandleCharInput(char, EditorState, ref char?, int)

Processes a printable character for renderers that intercept input. Returns true if the input was consumed (including storing a partial value like a hex nibble). The pendingNibble ref parameter holds per-editor-instance state managed by the caller.

Parameters:

Returns: Boolean

csharp
bool HandleCharInput(char c, EditorState state, ref char? pendingNibble, int viewportColumns)

HandleNavigation(CursorDirection, EditorState, bool, int)

Handles cursor navigation for this renderer. Returns true if the renderer handled the navigation (e.g., byte-level movement in hex mode), in which case the default character-level navigation is skipped.

Parameters:

  • direction (CursorDirection): The cursor direction.
  • state (EditorState): The editor state.
  • extend (Boolean): Whether to extend the selection.
  • viewportColumns (Int32): Available width in columns for responsive layout.

Returns: Boolean

csharp
bool HandleNavigation(CursorDirection direction, EditorState state, bool extend, int viewportColumns)

HitTest(int, int, EditorState, int, int, int, int)

Converts screen-local coordinates (relative to viewport origin) to a document offset. Returns null if the position doesn't map to a valid document location.

Parameters:

  • localX (Int32): X coordinate relative to viewport left edge.
  • localY (Int32): Y coordinate relative to viewport top edge.
  • state (EditorState): The editor state (document).
  • viewportColumns (Int32): Number of visible columns.
  • viewportLines (Int32): Number of visible lines.
  • scrollOffset (Int32): First visible line (1-based).
  • horizontalScrollOffset (Int32): First visible column (0-based).

Returns: Nullable<DocumentOffset>

csharp
DocumentOffset? HitTest(int localX, int localY, EditorState state, int viewportColumns, int viewportLines, int scrollOffset, int horizontalScrollOffset)

Render(Hex1bRenderContext, EditorState, Rect, int, int, bool, char?, IReadOnlyList<ITextDecorationProvider>?, IReadOnlyList<InlineHint>?, bool, IReadOnlyList<FoldingRegion>?)

Renders the document content into the given viewport area.

Parameters:

  • context (Hex1bRenderContext): The render context and theme.
  • state (EditorState): The editor state (document, cursors, selections).
  • viewport (Rect): The screen area to render into.
  • scrollOffset (Int32): First visible line (1-based).
  • horizontalScrollOffset (Int32): First visible column (0-based).
  • isFocused (Boolean): Whether the editor is currently focused.
  • pendingNibble (Nullable<Char>): For hex renderers, the first nibble of a partially-entered byte (null if none).
  • decorationProviders (IReadOnlyList<ITextDecorationProvider>): Optional text decoration providers for syntax highlighting and diagnostics.
  • inlineHints (IReadOnlyList<InlineHint>): Optional inline hints (virtual text) to render at document positions.
  • wordWrap (Boolean): Whether soft line wrapping is enabled.
  • foldingRegions (IReadOnlyList<FoldingRegion>): Optional folding regions for collapsible code sections.
csharp
void Render(Hex1bRenderContext context, EditorState state, Rect viewport, int scrollOffset, int horizontalScrollOffset, bool isFocused, char? pendingNibble = null, IReadOnlyList<ITextDecorationProvider>? decorationProviders = null, IReadOnlyList<InlineHint>? inlineHints = null, bool wordWrap = false, IReadOnlyList<FoldingRegion>? foldingRegions = null)

Released under the MIT License.