Classes
ThemeStyle
6
▼
A named style mapping to ANSI SGR attributes.
The ``fg`` and ``bg`` fields accept three formats:
…
ThemeStyle
6
▼
A named style mapping to ANSI SGR attributes.
Thefg and bgfields accept three formats:
- Named color (str):
"red","bright_cyan"— basic 16-color ANSI. - 256-color index (int):
33— extended 256-color palette. - Truecolor hex (str):
"#ff6600"— 24-bit RGB color.
Attributes
| Name | Type | Description |
|---|---|---|
fg |
str | int | None
|
— |
bg |
str | int | None
|
— |
bold |
bool
|
— |
dim |
bool
|
— |
italic |
bool
|
— |
Methods
sgr_prefix
0
str
▼
Return the SGR escape prefix for this style (no reset).
sgr_prefix
0
str
▼
def sgr_prefix(self) -> str
Returns
str
ThemeProxy
2
▼
Attribute-access proxy for use as a kida template global.
In templates::
{{ theme.primary }}H…
ThemeProxy
2
▼
Attribute-access proxy for use as a kida template global.
In templates::
{{ theme.primary }}Hello{{ theme.reset }}
{{ theme.error }}Oops{{ theme.reset }}
When color is disabled, all attributes return empty strings.
Methods
Internal Methods 2 ▼
__init__
2
▼
__init__
2
▼
def __init__(self, theme: dict[str, ThemeStyle], *, color: bool = True) -> None
Parameters
| Name | Type | Description |
|---|---|---|
theme |
— |
|
color |
— |
Default:True
|
__getattr__
1
str
▼
__getattr__
1
str
▼
def __getattr__(self, name: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
name |
— |
Returns
str
Functions
_parse_hex
1
tuple[int, int, int]
▼
Parse ``#rrggbb`` into an (r, g, b) tuple.
_parse_hex
1
tuple[int, int, int]
▼
def _parse_hex(color: str) -> tuple[int, int, int]
Parameters
| Name | Type | Description |
|---|---|---|
color |
str |
Returns
tuple[int, int, int]
_color_codes
2
str
▼
Return the SGR parameter string for a foreground or background color.
_color_codes
2
str
▼
def _color_codes(color: str | int, *, ground: str) -> str
Parameters
| Name | Type | Description |
|---|---|---|
color |
str | int |
Named color, 256-color index (int), or |
ground |
str |
|
Returns
str
make_style_filter
2
Any
▼
Create a ``style`` filter closure bound to a theme.
Usage in templates::
…
make_style_filter
2
Any
▼
def make_style_filter(theme: dict[str, ThemeStyle], *, color: bool = True) -> Any
Create astylefilter closure bound to a theme.
Usage in templates::
{{ "Error!" | style("error") }}
{{ count | style("primary") }}
Parameters
| Name | Type | Description |
|---|---|---|
theme |
dict[str, ThemeStyle] |
|
color |
bool |
Default:True
|
Returns
Any