Ansi.AttrSourceText attribute flags.
Text attribute flags.
A compact bit-flag representation for text attributes (bold, italic, underline, etc.). Attributes are stored as a 12-bit integer bitmask, enabling fast set operations and minimal memory usage.
Terminal support varies. Bold, underline, and inverse are widely supported. Blink, framed, and encircled have limited support; unsupported attributes simply have no visible effect.
type flag = | BoldIncreased weight/brightness (SGR 1).
*)| DimDecreased brightness (SGR 2).
*)| ItalicSlanted text (SGR 3).
*)| UnderlineSingle underline (SGR 4).
*)| Double_underlineDouble underline (SGR 21).
*)| BlinkBlinking text (SGR 5).
*)| InverseSwap foreground/background (SGR 7).
*)| HiddenInvisible text (SGR 8).
*)| StrikethroughLine through text (SGR 9).
*)| OverlineLine above text (SGR 53).
*)| FramedFramed text (SGR 51).
*)| EncircledEncircled text (SGR 52).
*)The type for individual text attribute flags.
flag_to_sgr_disable_code f is the SGR code to disable f.
Note. Some flags share disable codes: Bold and Dim both use 22, Underline and Double_underline both use 24, Framed and Encircled both use 54.
The type for attribute sets. Internally a 12-bit integer bitmask.
with_flag f enabled s adds f if enabled is true, removes it otherwise.
to_list s is the flags in s as a list. Order is deterministic but unspecified.
val combine :
?bold:bool ->
?dim:bool ->
?italic:bool ->
?underline:bool ->
?double_underline:bool ->
?blink:bool ->
?inverse:bool ->
?hidden:bool ->
?strikethrough:bool ->
?overline:bool ->
?framed:bool ->
?encircled:bool ->
unit ->
tcombine ?bold ?dim ... () is a set from labelled arguments. Each parameter defaults to false.
to_sgr_codes s is the SGR enable codes for s. Use iter_sgr_codes or fold_sgr_codes to avoid allocation.
iter_sgr_codes f s calls f code for each SGR enable code in s.
iter_sgr_disable_codes f s calls f code for each SGR disable code in s. Shared codes are deduplicated (e.g. if both Bold and Dim are in s, code 22 is emitted once).
fold_sgr_codes f s init folds f over SGR enable codes of s.
pp formats an attribute set for inspection (e.g. "[Bold, Italic]").