Skip to content

gole.theme

gole.theme ๐Ÿ”—

from_theme(theme: Theme) -> TextAreaTheme ๐Ÿ”—

Convert application theme into a TextAreaTheme.

Source code in gole/theme.py
def from_theme(theme: Theme) -> TextAreaTheme:
    """Convert application theme into a TextAreaTheme."""
    primary = theme.primary
    secondary = theme.secondary
    accent = theme.accent
    error = theme.error
    success = theme.success
    foreground = theme.foreground
    background = theme.background
    surface = theme.surface
    panel = theme.panel

    return TextAreaTheme(
        name=theme.name,
        base_style=Style(color=foreground, bgcolor=background),
        gutter_style=Style(color=foreground, bgcolor=background),
        cursor_style=Style(color=panel, bgcolor=secondary),
        cursor_line_style=Style(bgcolor=surface),
        cursor_line_gutter_style=Style(color=background, bgcolor=panel),
        bracket_matching_style=Style(bgcolor=panel, bold=True),
        selection_style=Style(bgcolor=panel),
        syntax_styles={
            'string': Style(color=accent),
            'string.documentation': Style(color=accent),
            'comment': Style(color=foreground),
            'heading.marker': Style(color=success),
            'keyword': Style(color=success),
            'operator': Style(color=error),
            'repeat': Style(color=error),
            'exception': Style(color=error),
            'include': Style(color=success),
            'keyword.function': Style(color=success),
            'keyword.return': Style(color=error),
            'keyword.operator': Style(color=error),
            'conditional': Style(color=success),
            'number': Style(color=accent),
            'float': Style(color=accent),
            'class': Style(color=error),
            'type': Style(color=accent),
            'type.class': Style(color=error),
            'type.builtin': Style(color=accent),
            'variable.builtin': Style(color=foreground),
            'function': Style(color=primary),
            'function.call': Style(color=primary),
            'method': Style(color=primary),
            'method.call': Style(color=primary),
            'boolean': Style(color=error, italic=True),
            'constant.builtin': Style(color=error, italic=True),
            'json.null': Style(color=error, italic=True),
            'regex.punctuation.bracket': Style(color=error),
            'regex.operator': Style(color=error),
            'html.end_tag_error': Style(color=error, underline=True),
            'tag': Style(color=accent),
            'yaml.field': Style(color=error, bold=True),
            'json.label': Style(color=error, bold=True),
            'toml.type': Style(color=success),
            'toml.datetime': Style(color=success),
            'css.property': Style(color=success),
            'heading': Style(color=foreground, bold=True),
            'bold': Style(bold=True),
            'italic': Style(italic=True),
            'strikethrough': Style(strike=True),
            'link.label': Style(color=error),
            'link.uri': Style(color=primary, underline=True),
            'list.marker': Style(color=accent),
            'inline_code': Style(color=accent),
            'punctuation.bracket': Style(color=error),
            'punctuation.delimiter': Style(color=accent),
            'punctuation.special': Style(color=error),
        },
    )

add_catppuccin(flavor, *, rosewater, flamingo, pink, mauve, red, maroon, peach, yellow, green, teal, sky, sapphire, blue, lavender, text, subtext_1, subtext_0, overlay_2, overlay_1, overlay_0, surface_2, surface_1, surface_0, base, mantle, crust, dark=True) ๐Ÿ”—

Add catppuccin.

Source code in gole/theme.py
def add_catppuccin(
    flavor,
    *,
    rosewater,
    flamingo,
    pink,
    mauve,
    red,
    maroon,  #
    peach,
    yellow,
    green,
    teal,  #
    sky,
    sapphire,
    blue,
    lavender,  #
    text,
    subtext_1,
    subtext_0,
    overlay_2,
    overlay_1,  #
    overlay_0,  #
    surface_2,
    surface_1,
    surface_0,
    base,
    mantle,  #
    crust,
    dark=True,
):
    """Add catppuccin."""
    name = f'catppuccin-{flavor}'
    BUILTIN_THEMES[name] = Theme(
        name=name,
        primary=pink,
        secondary=mauve,
        warning=yellow,
        error=red,
        success=green,
        accent=peach,
        foreground=text,
        background=mantle,
        surface=surface_0,
        panel=surface_1,
        dark=dark,
        variables={
            'input-cursor-foreground': crust,
            'input-cursor-background': rosewater,
            'input-selection-background': f'{overlay_2} 30%',
            'border': lavender,
            'border-blurred': surface_2,
            'footer-background': surface_1,
            'block-cursor-foreground': base,
            'block-cursor-text-style': 'none',
            'button-color-foreground': mantle,
        },
    )

    TEXT_THEMES[name] = TextAreaTheme(
        name=name,
        base_style=Style(color=text, bgcolor=base),
        gutter_style=Style(color=rosewater, bgcolor=base),
        cursor_style=Style(color=overlay_2, bgcolor=rosewater),
        cursor_line_style=Style(bgcolor=surface_0),
        cursor_line_gutter_style=Style(color=subtext_1, bgcolor=surface_1),
        bracket_matching_style=Style(bgcolor=crust, bold=True),
        selection_style=Style(bgcolor=surface_1),
        syntax_styles={
            'string': Style(color=green),
            'string.documentation': Style(color=green),
            'comment': Style(color=subtext_0),
            'heading.marker': Style(color=green),
            'keyword': Style(color=mauve),
            'operator': Style(color=sky),
            'repeat': Style(color=sky),
            'exception': Style(color=red),
            'include': Style(color=mauve),
            'keyword.function': Style(color=mauve),
            'keyword.return': Style(color=mauve),
            'keyword.operator': Style(color=mauve),
            'conditional': Style(color=mauve),
            'number': Style(color=red),
            'float': Style(color=red),
            'class': Style(color=mauve),
            'type': Style(color=mauve),
            'type.class': Style(color=yellow),
            'type.builtin': Style(color=text),
            'function': Style(color=blue),
            'function.call': Style(color=blue),
            'method': Style(color=blue),
            'method.call': Style(color=blue),
            'boolean': Style(color=peach, italic=True),
            'constant.builtin': Style(color=peach, italic=True),
            'json.null': Style(color=peach, italic=True),
            'regex.punctuation.bracket': Style(color=red),
            'regex.operator': Style(color=sky),
            'html.end_tag_error': Style(color=red, underline=True),
            'tag': Style(color=mauve),
            'yaml.field': Style(color=red, bold=True),
            'json.label': Style(color=red, bold=True),
            'toml.type': Style(color=mauve),
            'toml.datetime': Style(color=mauve),
            'css.property': Style(color=mauve),
            'heading': Style(color=sapphire, bold=True),
            'bold': Style(bold=True),
            'italic': Style(italic=True),
            'strikethrough': Style(strike=True),
            'link.label': Style(color=red),
            'link.uri': Style(color=pink, underline=True),
            'list.marker': Style(color=yellow),
            'inline_code': Style(color=yellow),
            'punctuation.bracket': Style(color=red),
            'punctuation.delimiter': Style(color=rosewater),
            'punctuation.special': Style(color=red),
        },
    )