AsciinemaFileWorkloadAdapter
Namespace: Hex1b
Assembly: Hex1b.dll
A workload adapter that plays back an asciinema (.cast) recording file.
public sealed class AsciinemaFileWorkloadAdapter : IHex1bTerminalWorkloadAdapter, IAsyncDisposableInheritance
Object → AsciinemaFileWorkloadAdapter
Implements
Constructors
AsciinemaFileWorkloadAdapter(string)
Creates a new asciinema file workload adapter.
Parameters:
filePath(String): Path to the .cast file to play back.
public AsciinemaFileWorkloadAdapter(string filePath)Properties
Height
Gets the height from the asciinema header, or 0 if not yet read.
Returns: Int32
public int Height { get; }SpeedMultiplier
Gets or sets the playback speed multiplier. Default is 1.0 (normal speed). Set to 2.0 for 2x speed, 0.5 for half speed, etc.
Returns: Double
public double SpeedMultiplier { get; set; }Width
Gets the width from the asciinema header, or 0 if not yet read.
Returns: Int32
public int Width { get; }Methods
DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Returns: ValueTask
A task that represents the asynchronous dispose operation.
public ValueTask DisposeAsync()ReadOutputAsync(CancellationToken)
Read output FROM the workload (ANSI sequences to display). The terminal calls this to get data to parse and send to presentation. Returns empty when workload has no more output (should be called in a loop).
Parameters:
ct(CancellationToken):
Returns: ValueTask<Byte>>
public ValueTask<ReadOnlyMemory<byte>> ReadOutputAsync(CancellationToken ct = default)ResizeAsync(int, int, CancellationToken)
Notify workload of terminal resize.
Parameters:
width(Int32):height(Int32):ct(CancellationToken):
Returns: ValueTask
public ValueTask ResizeAsync(int width, int height, CancellationToken ct = default)StartAsync(CancellationToken)
Starts playback of the asciinema file.
Parameters:
ct(CancellationToken):
Returns: Task
public Task StartAsync(CancellationToken ct = default)WriteInputAsync(ReadOnlyMemory<byte>, CancellationToken)
Write input TO the workload (raw bytes from keyboard/mouse). The terminal calls this when it receives input from the presentation layer.
Parameters:
data(ReadOnlyMemory<Byte>):ct(CancellationToken):
Returns: ValueTask
public ValueTask WriteInputAsync(ReadOnlyMemory<byte> data, CancellationToken ct = default)Events
Disconnected
Raised when workload has disconnected/exited.
Returns: Action
public event Action? DisconnectedRemarks
This adapter reads asciicast v2 format files and replays the terminal output with proper timing. It's useful for:
Playing back recorded terminal sessionsCreating demos and tutorials from recordingsTesting terminal rendering with real-world dataConverting asciinema files to other formats
The adapter reads events from the file and streams them at the appropriate times based on the timestamps in the recording. Output events ("o" type) are converted to bytes and returned via . Resize events ("r" type) trigger the callback.
Examples
await using var terminal = Hex1bTerminal.CreateBuilder()
.WithAsciinemaPlayback("recording.cast")
.Build();
await terminal.RunAsync();