nimterm/theme
This page is generated from the module’s exported API and ## documentation comments.
Small TUI palette: named tokens → SGR strings, compiled once per apply.
Built-in themes compile once per terminal color depth. Custom themes are JSON under the configured global and workspace roots. No hot reload, no OSC queries, no per-frame color math.
ColorDepth
Section titled “ColorDepth”ColorDepth = enum cdNone, cd16, cd256, cdTrueThemeSpec
Section titled “ThemeSpec”ThemeSpec = object name*: string accent*, success*, error*, warning*, code*, muted*, dim*, text*: string heading*, model*, panelBg*, selectedBg*, selectedFg*: stringTheme = object name*: string accent*, success*, error*, warning*, code*, muted*, dim*, text*: string heading*, model*, panelBg*, selectedBg*, selectedFg*: string boldAccent*, boldError*: string reset*: stringConstants
Section titled “Constants”Dark256
Section titled “Dark256”Dark256 = (name: "dark", accent: "\e[36m", success: "\e[32m", error: "\e[31m", warning: "\e[33m", code: "\e[38;5;179m", muted: "\e[90m", dim: "\e[2m", text: "\e[37m", heading: "\e[1;34m", model: "\e[35m", panelBg: "\e[48;5;236m", selectedBg: "\e[48;5;81m", selectedFg: "\e[30m", boldAccent: "\e[1;36m", boldError: "\e[1;31m", reset: "\e[0m")DarkSpec
Section titled “DarkSpec”DarkSpec = (name: "dark", accent: "#00afaf", success: "#00af00", error: "#af0000", warning: "#afaf00", code: "#d7af5f", muted: "242", dim: "dim", text: "#c6c6c6", heading: "#5f87ff", model: "#af00af", panelBg: "#303030", selectedBg: "#5fd7ff", selectedFg: "#000000")LightSpec
Section titled “LightSpec”LightSpec = (name: "light", accent: "#005f87", success: "#008700", error: "#af0000", warning: "#af5f00", code: "#875f00", muted: "245", dim: "dim", text: "#262626", heading: "#5f00af", model: "#8700af", panelBg: "#e4e4e4", selectedBg: "#0087af", selectedFg: "#ffffff")Variables
Section titled “Variables”currentTheme
Section titled “currentTheme”currentTheme = Dark256themeRevision
Section titled “themeRevision”themeRevision = 0Procedures
Section titled “Procedures”clearThemeNameCache
Section titled “clearThemeNameCache”proc clearThemeNameCache() {.raises: [], tags: [], forbids: [].}colorsOn
Section titled “colorsOn”proc colorsOn(t: Theme): bool {.raises: [], tags: [], forbids: [].}Returns: bool.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
proc paint(t: Theme; code, text: string): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
|
code |
string |
|
text |
string |
styleFromSgr
Section titled “styleFromSgr”Convert a compiled theme token back into Nimterm’s semantic style. Theme tokens are still serialized for the plain console path, while widgets consume semantic cells.
proc styleFromSgr(code: string): nimstyle.Style {.raises: [], tags: [], forbids: [].}Returns: nimstyle.Style.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
code |
string |
themedStyle
Section titled “themedStyle”proc themedStyle(t: Theme; foreground = ""; background = ""; attributes: set[nimstyle.TextAttribute] = {}): nimstyle.Style {. raises: [], tags: [], forbids: [].}Returns: nimstyle.Style.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
|
foreground |
inferred |
"" |
background |
inferred |
"" |
attributes |
set[nimstyle.TextAttribute] |
{} |
italicHeading
Section titled “italicHeading”Prefer a single SGR for an italic heading; else prefix italic.
proc italicHeading(t: Theme): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
detectDepth
Section titled “detectDepth”proc detectDepth(): ColorDepth {.raises: [], tags: [ReadEnvEffect], forbids: [].}Returns: ColorDepth.
compileTheme
Section titled “compileTheme”proc compileTheme(spec: ThemeSpec; depth: ColorDepth): Theme {.raises: [], tags: [], forbids: [].}Returns: Theme.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
spec |
ThemeSpec |
|
depth |
ColorDepth |
parseThemeJson
Section titled “parseThemeJson”proc parseThemeJson(doc: JsonNode): tuple[ok: bool, spec: ThemeSpec, err: string] {. raises: [KeyError], tags: [], forbids: [].}Returns: tuple[ok: bool, spec: ThemeSpec, err: string].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
doc |
JsonNode |
listThemeNames
Section titled “listThemeNames”proc listThemeNames(workspace = ""; appDir = ".nimterm"; globalDir = ""): seq[ string] {.raises: [OSError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect], forbids: [].}Returns: seq[string].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
workspace |
inferred |
"" |
appDir |
inferred |
".nimterm" |
globalDir |
inferred |
"" |
findUserTheme
Section titled “findUserTheme”proc findUserTheme(name, workspace: string; appDir = ".nimterm"; globalDir = ""): tuple[ ok: bool, spec: ThemeSpec, err: string] {.raises: [OSError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect], forbids: [].}Returns: tuple[ok: bool, spec: ThemeSpec, err: string].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
name |
string |
|
workspace |
string |
|
appDir |
inferred |
".nimterm" |
globalDir |
inferred |
"" |
compileNamedTheme
Section titled “compileNamedTheme”proc compileNamedTheme(name: string; depth: ColorDepth; workspace = ""; appDir = ".nimterm"; globalDir = ""): tuple[ok: bool, theme: Theme, err: string] {.raises: [OSError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect], forbids: [].}Returns: tuple[ok: bool, theme: Theme, err: string].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
name |
string |
|
depth |
ColorDepth |
|
workspace |
inferred |
"" |
appDir |
inferred |
".nimterm" |
globalDir |
inferred |
"" |
applyTheme
Section titled “applyTheme”Compile and install currentTheme. Returns “” or an error message.
Depth defaults to activeDepth so /theme|/new|/resume keep the startup
capability (tests stay on cd256; non-TTY detectDepth would wipe colors).
proc applyTheme(name: string; depth = activeDepth; workspace = ""; appDir = ".nimterm"; globalDir = ""): string {. raises: [OSError], tags: [ReadEnvEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
name |
string |
|
depth |
inferred |
activeDepth |
workspace |
inferred |
"" |
appDir |
inferred |
".nimterm" |
globalDir |
inferred |
"" |
userRail
Section titled “userRail”Accent rail + optional panel background (OpenCode-style).
proc userRail(t: Theme = currentTheme): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
currentTheme |
toolRail
Section titled “toolRail”proc toolRail(t: Theme; isError: bool): string {.raises: [], tags: [], forbids: [].}Returns: string.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
t |
Theme |
|
isError |
bool |