theme

index

Overview

Themes: one palette of semantic colour roles, and the style sheets (rss tables) every themed section builds from it.

A theme comes from one of two sources: a LILPACK registers it at runtime, or the bundled theme.catalog carries it. A LILPACK theme shadows a bundled theme of the same name. The name default always means the built-in palette, whatever is registered.

Functions

NameSignature
setset(name) -> ok, err
currentcurrent() -> name
listlist() -> themes
getget(section, extra_overrides) -> rss
subscribesubscribe(section, sub_key) -> getter
palettepalette() -> palette
register_sectionregister_section(name, builder_fn)
register_themeregister_theme(name, data)

set(name) -> ok, err

Activate a named theme

Looks the name up in the LILPACK themes first, then in the bundled catalog. The theme's palette merges over the default palette, and every section rebuilds from the result. Every subscriber sees the new theme on its next call.

Re-registering the active theme changes nothing until set runs again.

current() -> name

Name the active theme

list() -> themes

List every theme set can load

Each entry is { name = string, source = "lilpack" | "bundled" }, sorted by name. A name in both sources lists once, as "lilpack", since that is the theme set loads.

default is not listed unless a LILPACK registers that name, and set("default") still loads the built-in palette then.

get(section, extra_overrides) -> rss

Build the style sheet of a section

Merges the palette-derived defaults, the active theme's overrides and extra_overrides, in that order. The result is a fresh copy: the caller may change it. An unknown section yields an empty table.

subscribe(section, sub_key) -> getter

Make a getter that tracks the active theme

The getter returns a term.tss object for the section, or for its sub_key subtable. It rebuilds the object only after set or register_section has run, so a caller can call it on every draw.

palette() -> palette

Copy the active palette

register_section(name, builder_fn)

Add a themed section

builder_fn(palette) returns the section's default rss table. It runs at once against the active palette, and again on every set. A name already taken, built-in sections included, is replaced.

register_theme(name, data)

Add a theme from a LILPACK

data has the shape of a bundled catalog entry: a palette table and optional per-section override tables. It shadows a bundled theme of the same name. A registered theme cannot be removed.