Table of Contents

Class Typewriter

Namespace
Retro.Crt
Assembly
Retro.Crt.dll

Reveals text one character at a time. Optional fake cursor between characters and optional Alpha fade-in (brightness ramp on the final glyph). The trailing cursor, if any, is always erased before Type(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?) returns.

Assumes one terminal cell per char: surrogate pairs (emoji), combining marks, and wide CJK glyphs break the cursor-overwrite tracking used by cursor mode and alpha fade. Stick to BMP single-cell characters for animated reveals.

public static class Typewriter
Inheritance
Typewriter
Inherited Members

Methods

Sit at the current cursor position and blink a fake cursor for totalMs milliseconds — useful for the Matrix- style "pause before the next phrase" beats. The glyph is erased before this method returns, so the next write starts on a clean cell. Without ANSI support the call is a plain Sleep(int).

public static void Blink(int totalMs, TypewriterCursor cursor = TypewriterCursor.MatrixBlock, Color? fg = null, int blinkRateMs = 500)

Parameters

totalMs int

How long to blink, in total. Values ≤0 return immediately.

cursor TypewriterCursor

Glyph to blink. None just sleeps.

fg Color?

Optional color for the cursor.

blinkRateMs int

Half-period of the blink — time the cursor stays in each on/off state.

BlinkAsync(int, TypewriterCursor, Color?, int, CancellationToken)

Async variant of Blink(int, TypewriterCursor, Color?, int) with cancellation support.

public static Task BlinkAsync(int totalMs, TypewriterCursor cursor = TypewriterCursor.MatrixBlock, Color? fg = null, int blinkRateMs = 500, CancellationToken cancellationToken = default)

Parameters

totalMs int
cursor TypewriterCursor
fg Color?
blinkRateMs int
cancellationToken CancellationToken

Returns

Task

Type(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?)

Reveal text character-by-character. Blocks the calling thread between characters via Sleep(int).

public static void Type(string text, int msPerChar = 30, Color? fg = null, TypewriterCursor cursor = TypewriterCursor.None, TypewriterFade fade = TypewriterFade.None, (Color from, Color to)? gradient = null)

Parameters

text string

Text to reveal.

msPerChar int

Time budget per character. Zero writes the whole string instantly.

fg Color?

Static foreground color. Ignored when gradient is set.

cursor TypewriterCursor

Cursor glyph shown while waiting for the next char.

fade TypewriterFade

How each character appears.

gradient (Color from, Color to)?

If set, color is interpolated across the string. Both endpoints must be truecolor.

TypeAsync(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?, CancellationToken)

Async variant of Type(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?). Pauses with Delay(int, CancellationToken), so cancellation aborts the reveal immediately and the finally block restores the cursor and color before propagating OperationCanceledException.

public static Task TypeAsync(string text, int msPerChar = 30, Color? fg = null, TypewriterCursor cursor = TypewriterCursor.None, TypewriterFade fade = TypewriterFade.None, (Color from, Color to)? gradient = null, CancellationToken cancellationToken = default)

Parameters

text string
msPerChar int
fg Color?
cursor TypewriterCursor
fade TypewriterFade
gradient (Color from, Color to)?
cancellationToken CancellationToken

Returns

Task

TypeLine(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?)

public static void TypeLine(string text, int msPerChar = 30, Color? fg = null, TypewriterCursor cursor = TypewriterCursor.None, TypewriterFade fade = TypewriterFade.None, (Color from, Color to)? gradient = null)

Parameters

text string
msPerChar int
fg Color?
cursor TypewriterCursor
fade TypewriterFade
gradient (Color from, Color to)?

TypeLineAsync(string, int, Color?, TypewriterCursor, TypewriterFade, (Color from, Color to)?, CancellationToken)

public static Task TypeLineAsync(string text, int msPerChar = 30, Color? fg = null, TypewriterCursor cursor = TypewriterCursor.None, TypewriterFade fade = TypewriterFade.None, (Color from, Color to)? gradient = null, CancellationToken cancellationToken = default)

Parameters

text string
msPerChar int
fg Color?
cursor TypewriterCursor
fade TypewriterFade
gradient (Color from, Color to)?
cancellationToken CancellationToken

Returns

Task