Ansi.StyleSourceTerminal text styles.
Terminal text styles.
A style aggregates foreground color, background color, text attributes, and an optional hyperlink URL into an immutable value. Styles compose with overlay semantics: colors and hyperlinks from the overlay replace those in the base, while attributes are unioned. See merge.
The type for styles. Fields are exposed for pattern matching but cannot be modified directly. Use make or the modifier functions to create new instances.
val make :
?fg:Color.t ->
?bg:Color.t ->
?bold:bool ->
?dim:bool ->
?italic:bool ->
?underline:bool ->
?blink:bool ->
?inverse:bool ->
?hidden:bool ->
?strikethrough:bool ->
?overline:bool ->
?double_underline:bool ->
?framed:bool ->
?encircled:bool ->
?link:string ->
unit ->
tmake ?fg ?bg ... () is a style with the given properties. fg and bg default to None (inherit terminal default). Boolean attributes default to false. link defaults to None.
overlay_attrs s a is s with a unioned into its existing attributes.
with_double_underline b s sets or clears double underline on s.
with_hidden b s sets or clears hidden on s.
with_strikethrough b s sets or clears strikethrough on s.
merge ~base ~overlay is the style combining base and overlay:
overlay takes precedence. If overlay.fg is None, base.fg is kept.base and overlay attributes.overlay takes precedence.equal a b is true iff all colors, attributes, and links are identical.
sgr_sequence ~prev s is the ANSI escape string for to_sgr_codes ~prev s. Returns "" if no transition is needed.
emit ~prev s w writes the minimal SGR codes to w to transition from prev (defaults to default) to s.
Handles shared disable codes correctly (Bold/Dim share 22, Underline/Double_underline share 24, Framed/Encircled share 54).
Note. Emits SGR sequences only. The link field is not emitted here; use Ansi.render for hyperlink support.
styled ~reset s str is str wrapped in the escape codes for s. If reset is true (default false), appends a reset sequence.
pp formats a style for inspection (e.g. "Style\{fg=#FF0000, attrs=[Bold, Underline]\}").