# `Harlock.Render.Style`
[🔗](https://github.com/thatsme/harlock/blob/v0.2.0/lib/harlock/render/style.ex#L1)

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 `:default` for
    "no override."
  * `:bold` / `:dim` / `:italic` / `:underline` / `:reverse` — boolean
    attributes, all `false` by 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.

# `color`

```elixir
@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}
```

# `t`

```elixir
@type t() :: %Harlock.Render.Style{
  bg: color(),
  bold: boolean(),
  dim: boolean(),
  fg: color(),
  italic: boolean(),
  reverse: boolean(),
  underline: boolean()
}
```

# `default`

```elixir
@spec default() :: t()
```

# `from`

```elixir
@spec from(keyword() | map() | t()) :: t()
```

# `merge`

```elixir
@spec merge(t(), t()) :: t()
```

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.

# `to_sgr`

```elixir
@spec to_sgr(t()) :: iodata()
```

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
