SixelWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
Displays a Sixel image when the effective presentation supports Sixel, otherwise displays a fallback widget.
[Experimental("HEX1B_SIXEL", UrlFormat = "https://github.com/hex1b/hex1b/blob/main/docs/experimental/sixel.md")]
public sealed record SixelWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SixelWidget>Inheritance
Object → Hex1bWidget → SixelWidget
Implements
Constructors
SixelWidget(SixelPixelBuffer, Hex1bWidget)
Creates a widget from structured RGBA pixels.
Parameters:
pixels(SixelPixelBuffer): The pixels to encode and display.fallback(Hex1bWidget): The widget displayed when Sixel is unavailable.
public SixelWidget(SixelPixelBuffer pixels, Hex1bWidget fallback)SixelWidget(string, Hex1bWidget, int?, int?)
Creates a widget from validated pre-encoded Sixel data.
Parameters:
imageData(String): A complete Sixel DCS sequence, or the Sixel body without its DCS framing.fallback(Hex1bWidget): The widget displayed when Sixel is unavailable.width(Nullable<Int32>): Optional display width in terminal cells. When specified, it must match the payload's natural width under the active Sixel protocol metrics.height(Nullable<Int32>): Optional display height in terminal cells. When specified, it must match the payload's natural height under the active Sixel protocol metrics.
public SixelWidget(string imageData, Hex1bWidget fallback, int? width = null, int? height = null)Properties
Fallback
Gets the widget displayed when Sixel is unavailable.
Returns: Hex1bWidget
public Hex1bWidget Fallback { get; init; }Height
Gets the optional display height in terminal cells.
Returns: Nullable<Int32>
public int? Height { get; init; }ImageData
Gets the validated, fully framed Sixel sequence for pre-encoded content.
Returns: String
public string? ImageData { get; }Pixels
Gets the structured pixels supplied to the widget.
Returns: SixelPixelBuffer
public SixelPixelBuffer? Pixels { get; }Width
Gets the optional display width in terminal cells.
Returns: Nullable<Int32>
public int? Width { get; init; }Remarks
Structured input is the preferred path. Explicit cell dimensions resample structured pixels to the corresponding Sixel protocol raster. Pre-encoded input is retained for compatibility and is validated and normalized to a complete 7-bit DCS sequence, but cannot be resampled.
Examples
#pragma warning disable HEX1B_SIXEL
using Hex1b;
using Hex1b.Surfaces;
var pixels = new SixelPixelBuffer(80, 40);
for (var y = 0; y
ctx.Sixel(pixels, fallback => fallback.Text("Sixel unavailable"))
.Width(16)
.Height(4))
.Build();
await terminal.RunAsync();