Repository navigation
API turboframe.ui.themes
Source: turboframe/ui/themes.py. Generated from the code of TurboFrame 0.3.0 by tools/wiki_api.py.
Colour themes: every colour a Turbo Vision desktop draws, in one place.
A theme (Palette) has four parts:
-
ansi: its 16 colours, by the names of the BIOS text-mode slots (black, blue, ... yellow, white). File marks and the Borland themes speak in slots. -
chrome: the Textual theme of textual-vision's widgets (menus, dialogs, buttons, frames, status line). The Borland themes are textual-vision's own. -
ui: the roles of the desktop's windows (desktop, editor, output, debug and help windows, lists, progress bar, shadow...). Each is a slot name or a#RRGGBB; the CSS sees them as$tf-<role>and the code askspalette.colour(role). -
syntax: the colours of the syntax roles (keyword, variable, string...).TOKENSsays which role, and which attributes, each token kind takes, the same in every theme: a theme only chooses colours.
TurboFrame registers only the token kinds it draws itself (diagnostics and diffs). An application registers its own with token() when it starts (its lexer's or tree-sitter's names), and its phosphor attributes in PHOSPHOR_ATTRS. An application whose CSS says $myapp-<role> calls add_css_alias("myapp") and keeps it.
Colours are written in full RGB; Textual (through Rich) sends them as the terminal can show them: true colour, the 256-colour cube or the 16 ANSI colours (set_ansi16), by what the terminal says it supports.
CGA, CSS_PREFIX, DEFAULT, DEPTHS, DEPTH_LABELS, PHOSPHORS, PHOSPHOR_ATTRS, SLOTS, SYNTAX_ROLES, THEMES, TOKENS, UI_ROLES, Palette, Phosphor, add_css_alias, ansi16, current, get, recolour, set_ansi16, token, treesitter_tokens, use
dict (16 entries)
'tf'
'turbo-pascal'
{'auto': 'auto', 'truecolor': 'truecolor', '256': '256', '16': 'standard'}
dict (4 entries)
dict (5 entries)
{'diag.error': {'bold': True}, 'diag.warning': {'underline': True}, 'diff.del': {'strike': True}}
tuple (16 entries)
tuple (41 entries)
dict (9 entries)
dict (7 entries)
tuple (67 entries)
class Palette
Palette(name: str, label: str, description: str, ansi: Mapping[str, str], chrome: Theme, ui: Mapping[str, str], syntax: Mapping[str, str], ansi16_slots: tuple[str, ...] | None = None, token_attrs: Mapping[str, Mapping[str, bool]] = <factory>, marks: bool = False, menu_active: str | None = None, hotkey_style: str = 'none', _styles: dict = <factory>)Palette(name: 'str', label: 'str', description: 'str', ansi: 'Mapping[str, str]', chrome: 'Theme', ui: 'Mapping[str, str]', syntax: 'Mapping[str, str]', ansi16_slots: 'tuple[str, ...] | None' = None, token_attrs: 'Mapping[str, Mapping[str, bool]]' = , marks: 'bool' = False, menu_active: 'str | None' = None, hotkey_style: 'str' = 'none', _styles: 'dict' = )
-
hex(colour: str) -> str: A slot name or a#RRGGBB, as#RRGGBB(as the terminal's 16 colours, when that is all it has: seeset_ansi16). -
slot_of(value: str) -> str: The slot of this palette a#RRGGBBis, or is nearest to. -
slot16_of(value: str) -> str: The slotvaluebecomes with 16 colours: its own (slot_of), or for a monochrome theme the nearest of the few it may use, by light (so it stays one hue, never another). -
snap(value: str) -> str:valueas its slot's CGA colour: Rich sends exactly that ANSI colour. -
colour(role: str) -> str: The#RRGGBBof a UI role (or a syntax role). -
style(fg: str | None = None, bg: str | None = None, **attrs: bool) -> Style: A Rich style from roles. -
token_styles() -> dict[str, Style]: Token kind -> style, for the editor and everything that shows code. -
textual_theme() -> Theme: The chrome, with the roles as$tf-<role>variables (and as$<alias>-<role>, for eachadd_css_alias).
class Phosphor
Phosphor(bg: str, panel: str, raised: str, mid: str, dim: str, text: str, bright: str, max: str, slots16: tuple[str, ...])Phosphor(bg: 'str', panel: 'str', raised: 'str', mid: 'str', dim: 'str', text: 'str', bright: 'str', max: 'str', slots16: 'tuple[str, ...]')
def add_css_alias(prefix: str) -> NoneThe roles are $<prefix>-<role> too, for an application whose CSS already says so.
def ansi16() -> booldef current() -> PaletteThe palette of the running app (one app runs at a time).
def get(name: str | None) -> Palettedef recolour(theme: Theme, table: Mapping[str, str], name: str) -> Themetheme (in CGA colours) with each CGA colour replaced by its slot in table.
def set_ansi16(only16: bool) -> NoneWith 16 colours, each colour goes to the slot it stands for in its palette (Campbell's light green stays light green, modern-dark's surfaces black), not to the ANSI colour nearest in RGB, which loses what it meant.
def token(fg: str | None, *kinds: str, bg: str | None = None, **attrs: bool) -> NoneEach of kinds takes the syntax role fg (and bg) and attrs (bold, italic...).
def treesitter_tokens(prefix: str = '') -> NoneRegister the capture names of Textual's tree-sitter highlight queries (Python, XML, HTML, JavaScript, CSS, JSON, YAML, TOML, Markdown, SQL, Bash...) as token kinds, each with its syntax role, prefix before each name (an application whose own highlighter renames them: "ts."). turboframe.ui.editor registers them without a prefix.
def use(name: str) -> PaletteTurboFrame · part of Divengine · GPL-3.0-or-later · report an issue
Tutorial
Examples
The desktop
- The Desktop
- Application Mixins
- Windows and Lists
- Dialogs
- Histories
- Progress
- Themes and Colors
- Glyphs
- Settings and Recent Files
- Command Palette
Editing
Tasks
Languages
Running
Reference
Links