Module: reefvision.theme

Source: ./reefvision/theme.reef


Overview

reefvision.theme — semantic palette, box glyphs, TOML load, RGB quantizers

Logical colors are always RGB (cell.Color). Emit maps them down by term.ColorDepth (design §7.2 palette roles, §8.3 down-conversion).

Themes are loadable from one TOML file per theme under reefvision/themes/ and swappable at runtime via app.set_theme. Frames are mode-only (single | double | ascii) — no custom border code points. desktop_fill is a decimal Unicode scalar for the canvas texture.

Usage: let th = theme.theme_by_name("cobalt") let th2 = theme.theme_load_file("reef-stdlib/reefvision/themes/green.toml") app.set_theme(th) // F2 / app.cycle_theme() / theme_builtin_at cycles the 12 built-in palettes

Converters are pure and stable. cell.reef keeps private twins for flush (avoid import cycle).


Types

FrameMode (enum)

Code points for a rectangular window frame + title bar caps. Title is drawn as: <title_cap_l>TITLE<title_cap_r> e.g. light "┤ TITLE ├" double "╣ TITLE ╠" ascii "+ TITLE +" Frame modes: single (light), double, ascii — no custom per-corner glyphs.

Variants:

  • Single
  • Double
  • Ascii

BoxGlyphs

Code points for a rectangular window frame + title caps + scroll gutters. Scroll gutter caps (owner design): top=┴/╩ opens gutter; bottom=┬/╦ closes.

Fields:

Name Type
tl int
t int
tr int
v int
bl int
b int
br int
title_cap_l int
title_cap_r int
scroll_top int
scroll_bot int

Theme

Palette roles for widgets / desktop + frame glyphs + chrome bars.

Fields:

Name Type
name string
desktop_bg cell.Style
desktop_fill int
window_frame cell.Style
window_title_active cell.Style
window_title_inactive cell.Style
label cell.Style
button_normal cell.Style
button_focused cell.Style
button_pressed cell.Style
input_normal cell.Style
input_focused cell.Style
dialog_frame cell.Style
menubar cell.Style
menubar_selected cell.Style
status cell.Style
scrollbar cell.Style
frame_mode FrameMode
box BoxGlyphs

Functions

fn theme_parse_ok(): bool

fn box_glyphs_ascii(): BoxGlyphs

fn box_glyphs_unicode_light(): BoxGlyphs

fn box_glyphs_unicode_double(): BoxGlyphs

fn theme_name(th: Theme): string

fn theme_box(th: Theme): BoxGlyphs

fn theme_desktop_fill(th: Theme): int

fn desktop_fill_preset_count(): int

Single-width texture pack (wcwidth 1). Order: solid → stipple → shade → hatch → solid block. Avoid CJK/hexagrams (double-width) and glyphs that mis-render on common fonts (half-block stripe, braille).

0 space U+0020 1 · U+00B7 2 ░ U+2591 3 ▒ U+2592 4 ▓ U+2593 5 ╱ U+2571 6 ╳ U+2573 7 █ U+2588

fn desktop_fill_preset_at(idx: int): int

fn desktop_fill_preset_name(idx: int): string

fn desktop_fill_preset_index(ch: int): int

Index of a fill code point in the F3 pack, or -1 if not a preset.

fn theme_classic(): Theme

Classic TUI defaults (TurboVision-ish blue/cyan) + Unicode light frames.

fn default_theme(): Theme

ReefVision default identity: cobalt palette + cross_hatch canvas fill.

fn theme_cobalt(): Theme

Deep cobalt panels, sky accents — modern IDE-ish (also the package default).

fn theme_ocean_blue(): Theme

Ocean blue — teal water, foam highlights.

fn theme_monochrome(): Theme

Greyscale only — high-contrast mono TUI.

fn theme_amber(): Theme

CRT amber phosphor.

fn theme_green(): Theme

Green phosphor (matrix / terminal green).

fn theme_paper(): Theme

Paper — light background, dark ink (day mode).

fn theme_nord(): Theme

Nord-inspired cool slate / frost.

fn theme_sunset(): Theme

Sunset — dusk purple and warm orange.

fn theme_rose(): Theme

Rose — soft rose / mauve panels.

fn theme_ascii(): Theme

Classic colors, ASCII frames (minimal consoles / fonts).

fn theme_double(): Theme

Classic colors + double-line Unicode frames.

fn theme_builtin_count(): int

Catalog order used by F2 and theme_builtin_at.

fn theme_builtin_name(idx: int): string

fn theme_builtin_at(idx: int): Theme

fn theme_by_name(name: string): Theme

fn clamp_rgb(v: int): int

fn parse_int_or(s: string, fallback: int): int

fn toml_rgb(doc: toml.TomlDoc, key: string, fallback: cell.Color): cell.Color

Read RGB array under key "colors.SLOT.fg" → three ints or fallback.

fn toml_style(doc: toml.TomlDoc, slot: string, fallback: cell.Style): cell.Style

fn toml_glyph(doc: toml.TomlDoc, key: string, fallback: int): int

fn box_from_preset(preset: string): BoxGlyphs

fn frame_mode_from_preset(preset: string): FrameMode

fn theme_frame_mode(th: Theme): FrameMode

fn theme_scrollbar(th: Theme): cell.Style

fn theme_parse(toml_text: string): Theme

fn theme_load_file(path: string): Theme

fn clamp_byte(v: int): int

fn rgb_cube_level(v: int): int

Map a channel 0..255 onto cube level 0..5 (see thresholds above).

fn rgb_to_256(r: int, g: int, b: int): int

xterm 256 index for an RGB triple.

fn ansi16_r(i: int): int

VGA-ish 16-color palette channels (matches cell private tables).

fn ansi16_g(i: int): int

fn ansi16_b(i: int): int

fn rgb_to_ansi16(r: int, g: int, b: int): int

Nearest ANSI/VGA index 0..15.


Procedures

proc emit_style(t: term.Term, st: cell.Style)

Full SGR reset then attrs + colors. Safe no-op when term is closed (term emitters check is_open).


Generated by reefc doc