Skip to content

API index

The public symbols of sparkles:base, by module.

sparkles.base

Package module re-exporting lifetime, logger, prettyprint, smallbuffer, source_uri, styled_template, term_color, term_style, and text.

sparkles.base.smallbuffer

SymbolDescription
SmallBuffer!(T, N)Stack-first append buffer that grows with pureMalloc if needed.
checkToString / checkWriter@nogc unit-test helpers for output-range rendering assertions.

sparkles.base.lifetime

SymbolDescription
recycledInstance!T(args)Reinitialises one thread-local static instance of T.
recycledErrorInstance!T(...)Builds an Error subclass in recycled storage for @nogc throw paths.

sparkles.base.text

Importing the package pulls in every module below.

ModuleDescription
sparkles.base.text.writersInteger (any radix 2–36), float, duration, byte, hex (writeHexByte), escape, and value writers.
sparkles.base.text.readersSlice-advance parsers (readInteger at any radix 2–36, readUntil) plus hex predicates isHexDigit / hexNibble.
sparkles.base.text.base_codecsRFC 4648 Base16/32/64 and relatives, driven by an Alphabet value — see Base codecs.
sparkles.base.text.percentRFC 3986 percent-encoding and x-www-form-urlencoded — see Percent-encoding.
sparkles.base.text.enumsEnum text helpers such as StringRepresentation.
sparkles.base.text.errorsParseErrorCode, ParseError, and ParseExpected!T.
sparkles.base.text.float_convExact decimal ⇄ double: correctly-rounded readDecimalFloat, shortest round-trip formatShortestDouble (spec).
sparkles.base.text.case_styleCaseStyle and convertCase (camel/pascal/snake/kebab/…).
sparkles.base.text.htmlHTML entity escaping.
sparkles.base.text.ansiANSI escape-sequence scanning.
sparkles.base.text.utf@nogc UTF-8 decoding.
sparkles.base.text.utf8UTF-8 well-formedness: indexOfInvalidUtf8, validateUtf8.
sparkles.base.text.graphemeGrapheme-cluster segmentation.
sparkles.base.text.widthTerminal cell width, field alignment, and truncation.
sparkles.base.text.wrapStyle-aware prose wrapping by terminal cell width.

sparkles.base.term_style

SymbolDescription
StyleANSI foreground, background, and attribute [open, close] code table.
TermStyleResolved style: fg/bg/underlineColor, attrs, underline.
TextAttrAttribute bitflag struct (bold/dim/italic/strikethrough/inverse/hidden) with typed |/&/~ and .has().
UnderlineStyleUnderline shape: none/single/double_/curly/dotted/dashed.
writeStyleTransitionDifferential ANSI encoder: minimal merged ESC[…m diff between two TermStyles at a ColorDepth.
stylizeWrap text in one ANSI style.
stylizedTextBuilderCTFE-friendly chained styling builder.
styleName / styleSampleStyle names and sample strings.

sparkles.base.term_color

SymbolDescription
ColorFour-case color: unset / default_ / palette / rgb.
RgbColor24-bit RGB triple.
ColorChannelSGR channel: foreground (38/39) / background (48/49) / underline (58/59).
writeSgrColorEmit the SGR color parameters for a Color on a channel, depth-folded.
parseHexColorParse #RGB/#RRGGBB/#RRGGBBAA (bat alpha convention) → Color.
ansi256FromRgb / ansi16FromRgbFold an RGB value to the nearest 256-/16-palette index.
xterm256ToRgbThe RGB behind an xterm-256 palette index.
ColorDepthTerminal color tiers: none / ansi16 / ansi256 / trueColor.
classifyColorDepth(colorterm, term)Pure, CTFE-able tier classifier over $COLORTERM/$TERM values.
detectColorDepth()Environment-reading wrapper over classifyColorDepth.

sparkles.base.styled_template

SymbolDescription
writeStyledWrites styled IES to an output range (optional leading ColorDepth).
styledTextAllocating styled string conversion (optional leading ColorDepth).
plainTextAllocating conversion with style markup stripped.
styledWrite*stdout/stderr helpers for styled IES (optional leading ColorDepth).
styleFromNameRuntime lookup for style names used by the parser.

sparkles.base.logger

SymbolDescription
CoreLoggerstd.logger.Logger base class with a Sparkles @nogc log path.
CoreLogEntryMetadata captured for Sparkles log calls.
DeltaTimeLoggerstderr logger with wall-clock and monotonic delta prefixes.
sharedCoreLogAtomic process-wide Sparkles logger.
coreGlobalLogLevelAtomic process-wide Sparkles log-level filter.
CoreFatalHandler / coreFatalHandlerFatal policy hook and global accessor.
throwingFatalHandlerThrows recycled FatalLogError.
assertingFatalHandlerFails with assert(0, message).
abortingFatalHandlerCalls abort().
log, trace, info, warning, error, critical, fatalStyled IES logging wrappers.
initLoggerInstalls DeltaTimeLogger for Phobos and Sparkles globals.

sparkles.base.prettyprint

SymbolDescription
PrettyPrintOptionsConfiguration for structural indentation and syntax highlighting.
prettyPrintPretty-prints any D value to a writer or returns a string.

sparkles.base.source_uri

SymbolDescription
resolveSourcePathResolves relative source path to absolute path.
FileUriHookDefault hook that formats source locations as file:// URIs.
SchemeHookHook that formats source locations using custom editor schemes.
EditorDetectHookRuntime detector using $VISUAL/$EDITOR environment variables.