package miaou-core

  1. Overview
  2. Docs
Miaou core/widgets (no drivers, no SDL)

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.5.2.tar.gz
md5=60a3b9f181f24572a06a9492532bfdda
sha512=fcc35a275066be2900e6201782faf47503076fa4640f08cf78067835a6f447b74613009e55b2ac799adb7ca46f1bffa261fc5971753f2cc3c6bef327511c7ef6

doc/miaou-core.style/Miaou_style/Theme/index.html

Module Miaou_style.ThemeSource

Theme definition with semantic styles and CSS-like widget styling rules.

A theme consists of:

  • Semantic styles (primary, error, text, etc.) for consistent appearance
  • Widget rules using CSS-like selectors for targeted styling

Example theme JSON:

{
  "name": "dark",
  "primary": { "fg": 75, "bold": true },
  "error": { "fg": 196 },
  "text": { "fg": 252 },
  "border": { "fg": 240 },
  "rules": {
    "table:focus": { "style": { "border_fg": 75 } },
    "flex_layout > :nth-child(even)": { "style": { "bg": 236 } },
    "modal .button": { "style": { "fg": 255, "bold": true } }
  }
}
Sourcetype widget_style = {
  1. style : Style.t;
    (*

    Base style (colors, text attributes)

    *)
  2. border_style : Border.style option;
    (*

    Optional border style override

    *)
  3. border_fg : Style.color option;
    (*

    Optional border foreground color

    *)
  4. border_bg : Style.color option;
    (*

    Optional border background color

    *)
}

Widget style with optional border configuration

Sourceval widget_style_to_yojson : widget_style -> Yojson.Safe.t

JSON encoding/decoding for widget styles (tolerant of missing fields).

Sourceval widget_style_of_yojson : Yojson.Safe.t -> (widget_style, string) result
Sourcetype rule = {
  1. selector : Selector.t;
  2. widget_style : widget_style;
}

A style rule: selector -> widget style

Sourcetype t = {
  1. name : string;
    (*

    Theme name (e.g., "dark", "light")

    *)
  2. dark_mode : bool;
    (*

    Whether this is a dark theme (affects color resolution for Adaptive colors)

    *)
  3. primary : Style.t;
    (*

    Primary accent color

    *)
  4. secondary : Style.t;
    (*

    Secondary color

    *)
  5. accent : Style.t;
    (*

    Accent/highlight color

    *)
  6. error : Style.t;
    (*

    Error/danger

    *)
  7. warning : Style.t;
    (*

    Warning

    *)
  8. success : Style.t;
    (*

    Success/positive

    *)
  9. info : Style.t;
    (*

    Information

    *)
  10. text : Style.t;
    (*

    Normal text

    *)
  11. text_muted : Style.t;
    (*

    Muted/secondary text

    *)
  12. text_emphasized : Style.t;
    (*

    Emphasized text

    *)
  13. background : Style.t;
    (*

    Main background

    *)
  14. background_secondary : Style.t;
    (*

    Secondary/panel background

    *)
  15. border : Style.t;
    (*

    Default border

    *)
  16. border_focused : Style.t;
    (*

    Focused border

    *)
  17. border_dim : Style.t;
    (*

    Dimmed border

    *)
  18. selection : Style.t;
    (*

    Selected item

    *)
  19. default_border_style : Border.style;
  20. rules : rule list;
}

Theme definition

Default theme

Sourceval empty_widget_style : widget_style

Empty widget style (inherits everything)

Sourceval default : t

Default theme with sensible colors for dark terminals

Style resolution

Sourceval matching_rules : t -> Selector.match_context -> rule list

Find all rules matching a context, ordered by specificity (most specific last)

Sourceval resolve_style : t -> Selector.match_context -> widget_style

Resolve the complete style for a widget context. Merges semantic styles with matching rules, respecting specificity.

Sourceval get_semantic_style : t -> string -> Style.t option

Get semantic style by name (e.g., "primary", "error", "text")

Validation

Sourceval validate : ?contrast:float -> ?dark_mode:bool -> t -> string list

Validate theme styles for low-contrast fg/bg combinations. Returns a list of human-readable warnings.

Theme merging

Sourceval merge : base:t -> overlay:t -> t

Merge two themes. Values from overlay take precedence when set.

JSON serialization

Sourceval to_yojson : t -> Yojson.Safe.t

Convert theme to JSON

Sourceval of_yojson : Yojson.Safe.t -> (t, string) result

Parse theme from JSON