Skip to content

API Overview

All public types are re-exported from the root module: @import("loaders").

Types

TypeDescription
ProgressBar / ProgressBarConfigAnimated bar with percent, count, ETA, elapsed, speed.
Spinner / SpinnerConfigAnimated spinner with any frame sequence.
BlockProgressBar / BlockBarConfigBar with partial block fills (▏▎▍▌▋▊▉).
Indeterminate / IndeterminateConfigSliding-segment bar for unknown progress.
MultiBar / MultiBarConfigMultiple bars/spinners rendered together.
BatchRunner / BatchConfigProcess items with per-item and overall bars.
StepSequence / StepSequenceConfigOrdered steps, each backed by a bar or spinner.
CustomBarStyle, BlockBarStyle, IndeterminateStyleCharacter styles.
ProgressState, SpinnerState, IndeterminateStateSnapshot state structs.
Status.pending | .running | .paused | .finished | .failed.
ThreadMode.none | .auto | .external.
Direction.incremental | .decremental.
FinishConfig{ clear, final_text, newline }.
FormatterSet, TemplateValuesTemplate formatters and values (see Templates).
FontStyleBold, dim, italic, underline, blink, reverse, strikethrough, concealed.
TerminalSize{ rows, cols }.
Colortint.zig Color union (ANSI 4-bit, 256, RGB, Hex).
Styletint.zig Style with fg, bg, underline_color, bold, italic, etc.
NamedCSS named colors (red, green, blue, etc.).

Functions

FunctionDescription
loaders.sleepMs(io, ms)Sleep the current thread.
loaders.formatNs(buf, ns)Format nanoseconds as MM:SS / HH:MM:SS.
loaders.formatRate(buf, per_sec)Format a rate as 123.4/s.
loaders.renderTemplate(...)Render a template with TemplateValues.
loaders.validateTemplate(template, formatters)Validate a template; returns error.MissingFormatter.
loaders.stdoutWriter(io)Get the shared stdout writer (returns a pointer).
loaders.eraseLine(io), moveUp(io, n), moveDown(io, n), moveRight(io, n), moveLeft(io, n)ANSI cursor/line helpers.
loaders.hideCursor(io), showCursor(io)Hide/show the terminal cursor.
loaders.getTerminalSize()Current terminal { rows, cols }.
loaders.ensureTerminal()Enable VT processing + UTF-8 output (Windows).

Color Helpers

FunctionDescription
loaders.makeRgb(r, g, b)Create RGB color from 0-255 values.
loaders.makeHex(0xRRGGBB)Create color from hex integer.
loaders.makeAnsi256(index)Create 256-color palette color.
loaders.makeHsl(h, s, l)Create HSL color.
loaders.makeNamed("red")Create CSS named color.
loaders.fg(color)Get foreground ANSI escape string.
loaders.bg(color)Get background ANSI escape string.
loaders.fgRgb(r, g, b)Get RGB foreground ANSI string.
loaders.bgRgb(r, g, b)Get RGB background ANSI string.
loaders.fgHex(0xRRGGBB)Get hex foreground ANSI string.
loaders.fg256(index)Get 256-color foreground ANSI string.

Common Method Names

All four widget types share the same method conventions:

MethodProgressBarSpinnerBlockBarIndeterminate
initinit(allocator, io, config)samesamesame
startstart() !voidstart() !voidstart() !voidstart() !void
updatetick() / setProgress(v)tickFrame()tick() / setProgress(v)tickFrame()
pausepause()pause()pause()pause()
resumecontinue_()continue_()continue_()continue_()
finishfinish(FinishConfig)stop(FinishConfig)finish(FinishConfig)stop(FinishConfig)
failfail(message)fail(message)fail(message)fail(message)
statestate() ProgressStatestate() SpinnerStatestate() BlockStatestate() IndeterminateState
statusgetStatus()getStatus()getStatus()getStatus()
runtime textsetText(s)setText(s)setText(s)setText(s)
runtime colorsetColor(?[]const u8)setColor(?[]const u8)setColor(?[]const u8)setColor(?[]const u8)
runtime templatesetTemplate(s) !voidsetTemplate(s) !voidsetTemplate(s) !voidsetTemplate(s) !void

Next

Released under the MIT License.