HexEditorViewRenderer
Namespace: Hex1b
Assembly: Hex1b.dll
Renders document content as a hex dump with offset, hex bytes, and ASCII columns. Format per row: "XXXXXXXX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX ................"
public sealed class HexEditorViewRenderer : IEditorViewRendererInheritance
Object → HexEditorViewRenderer
Implements
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
public bool HandlesCharInput { get; }HighlightMultiByteChars
When enabled, bytes that belong to multi-byte UTF-8 characters are rendered with a distinct background color to visually indicate character boundaries. The focused byte within a multi-byte group uses the cursor color; the other bytes in the same character use the multi-byte highlight color.
Returns: Boolean
public bool HighlightMultiByteChars { get; init; }Instance
Shared singleton instance with default settings (fluid layout, 1–16 bytes/row, ASCII enabled).
Returns: HexEditorViewRenderer
public static HexEditorViewRenderer Instance { get; }MaxBytesPerRow
Maximum bytes per row (default 16). The layout never exceeds this.
Returns: Int32
public int MaxBytesPerRow { get; init; }MinBytesPerRow
Minimum bytes per row (default 1). The layout never goes below this.
Returns: Int32
public int MinBytesPerRow { get; init; }PowerOfTwoSnaps
Well-known snap points: power-of-two breakpoints (1, 2, 4, 8, 16).
Returns: Int32[]
public static int[] PowerOfTwoSnaps { get; }ShowAscii
Whether to show the ASCII representation column on the right.
Returns: Boolean
public bool ShowAscii { get; init; }SnapPoints
Optional snap points that control how many bytes per row are used at each width breakpoint. When set, the renderer rounds down to the largest snap point that fits. When null the renderer is fully fluid — any byte count between and may be used.
Values must be in ascending order (e.g. [1, 8, 16]).
Returns: Int32[]
public int[]? SnapPoints { get; init; }StandardSnaps
Well-known snap points: standard hex-dump breakpoints (1, 8, 16).
Returns: Int32[]
public static int[] StandardSnaps { 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:
document(IHex1bDocument):scrollOffset(Int32):viewportLines(Int32):viewportColumns(Int32):
Returns: Int32
public 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
public 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:
c(Char):state(EditorState):pendingNibble(Nullable<Char>):viewportColumns(Int32):
Returns: Boolean
public 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
public 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>
public 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.
public 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)