package miaou-core
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6
doc/miaou-core.style/Miaou_style/Style/index.html
Module Miaou_style.StyleSource
Core style type for terminal rendering.
A style defines visual attributes for text rendering: colors, text decorations (bold, dim, underline, etc.), and can be combined through patching/merging.
All fields are option to support inheritance: None means "inherit from parent", Some v means "use this value".
type adaptive_color = {light : int;(*Color value for light terminal backgrounds
*)dark : int;(*Color value for dark terminal backgrounds
*)
}Adaptive color that can have different values for light and dark terminals
val adaptive_color_of_yojson :
Yojson.Safe.t ->
adaptive_color Ppx_deriving_yojson_runtime.error_ortype color = | Fixed of int(*Fixed 256-color value
*)| Adaptive of adaptive_color(*Adapts to terminal background
*)
Color specification: either a fixed color or adaptive
JSON encoding/decoding for colors. Accepts multiple formats for backwards compatibility:
"Fixed": 75"Fixed", 75- 75 (interpreted as Fixed)
"Adaptive": {"light": 15, "dark": 231
}
"Adaptive", {"light": 15, "dark": 231}
type t = {fg : color option;(*Foreground color (256-color palette or adaptive)
*)bg : color option;(*Background color
*)bold : bool option;(*Bold text
*)dim : bool option;(*Dim/faint text
*)italic : bool option;(*Italic text
*)underline : bool option;(*Underlined text
*)reverse : bool option;(*Reverse video (swap fg/bg)
*)strikethrough : bool option;(*Strikethrough text
*)
}Core style record.
All fields are optional to support style inheritance/cascade. None means "inherit from parent/default", Some v means "explicitly set".
JSON encoding/decoding for styles (tolerant of missing fields).
Backward-compatible aliases expected by other modules.
Constructors
val make :
?fg:color ->
?bg:color ->
?bold:bool ->
?dim:bool ->
?italic:bool ->
?underline:bool ->
?reverse:bool ->
?strikethrough:bool ->
unit ->
tCreate a style with specified attributes. Unspecified attributes are None.
Combining styles
patch ~base ~overlay merges two styles. Values from overlay take precedence when they are Some. This is like CSS cascade: more specific rules override general ones.
resolve ~default style collapses all None values using default. Returns a style where all fields are Some.
ANSI rendering
type resolved = {r_fg : int;r_bg : int;r_bold : bool;r_dim : bool;r_italic : bool;r_underline : bool;r_reverse : bool;r_strikethrough : bool;
}Resolved style with all concrete values (no Options)
Resolve a color for the current terminal (dark mode assumed by default)
ANSI escape code fragment for a foreground color index. Colors 0-15 use basic ANSI codes (respects terminal color scheme). Colors 16-255 use 256-color extended codes. Returns "" for negative values (no color).
Same as fg_ansi_code but for background colors.
Convert resolved style to ANSI reset sequence
Apply a resolved style to a string (wrap with ANSI codes)