Visual attributes for a rendered cell.
%Harlock.Render.Style{fg: :cyan, bold: true}
%Harlock.Render.Style{reverse: true}
%Harlock.Render.Style{bg: {:rgb, 30, 30, 40}}Fields:
:fg/:bg— foreground / background colour. Atoms for the 16 standard colours (:red,:bright_blue, …),{:color256, n}for 256-color,{:rgb, r, g, b}for truecolor, or:defaultfor "no override.":bold/:dim/:italic/:underline/:reverse— boolean attributes, allfalseby default.
Construct with the struct directly, or with from/1 for keyword/map
input. merge/2 layers one style on top of another — useful for
applying a theme :focus token to a user-set element style without
losing fg/bg.
Compared by value, hashed by value — used as a key into the renderer's internal style table.
Summary
Functions
Map a color to what the given terminal depth can actually emit.
Exposed for tests; the renderer uses it implicitly via to_sgr/1.
Layer over on top of under. Non-default colors in over win;
boolean attributes OR (any true wins). Used to apply theme tokens on
top of element-provided styles without losing user-set fg/bg.
Emit an SGR escape sequence that fully sets the cell's attributes. Starts
with \e[0m so the previous style doesn't bleed through. The diff renderer
emits this once per style transition; we don't try to be clever about
diffing individual attribute changes — terminals process SGR fast enough
that the extra bytes are cheaper than the bookkeeping.
Types
@type color() ::
:default
| :black
| :red
| :green
| :yellow
| :blue
| :magenta
| :cyan
| :white
| :bright_black
| :bright_red
| :bright_green
| :bright_yellow
| :bright_blue
| :bright_magenta
| :bright_cyan
| :bright_white
| {:color256, 0..255}
| {:rgb, 0..255, 0..255, 0..255}
@type depth() :: :mono | :ansi16 | :ansi256 | :truecolor
Color depth the terminal can display; mirrors the internal caps type.
Functions
@spec default() :: t()
Map a color to what the given terminal depth can actually emit.
Exposed for tests; the renderer uses it implicitly via to_sgr/1.
Layer over on top of under. Non-default colors in over win;
boolean attributes OR (any true wins). Used to apply theme tokens on
top of element-provided styles without losing user-set fg/bg.
Emit an SGR escape sequence that fully sets the cell's attributes. Starts
with \e[0m so the previous style doesn't bleed through. The diff renderer
emits this once per style transition; we don't try to be clever about
diffing individual attribute changes — terminals process SGR fast enough
that the extra bytes are cheaper than the bookkeeping.
Reads the active terminal color depth from the renderer's process- dictionary context (installed by the runtime around each frame) and downgrades colors that the terminal can't display:
:mono— fg/bg become:default(no color SGR emitted):ansi16—{:rgb, …}and{:color256, …}collapse to the nearest standard ANSI color:ansi256—{:rgb, …}collapses into the 256-color cube:truecolor— colors pass through unchanged
When no caps are installed (e.g. tests rendering through the test
backend) the default is :truecolor, matching v0.3 behaviour exactly.