TextMateLib 1.0
Modern C++ implementation of the TextMate syntax highlighting engine
Loading...
Searching...
No Matches

Load and query color schemes (themes) for syntax highlighting. More...

Collaboration diagram for Theme API:

Functions

TML_API TextMateTheme textmate_theme_load_from_file (const char *themePath)
 Load a theme from a JSON file.
 
TML_API TextMateTheme textmate_theme_load_from_json (const char *jsonContent)
 Load a theme from a JSON string.
 
TML_API uint32_t textmate_theme_get_foreground (TextMateTheme theme, const char *scopePath, uint32_t defaultColor)
 Get the foreground color for a scope path.
 
TML_API uint32_t textmate_theme_get_background (TextMateTheme theme, const char *scopePath, uint32_t defaultColor)
 Get the background color for a scope path.
 
TML_API int32_t textmate_theme_get_font_style (TextMateTheme theme, const char *scopePath, int32_t defaultStyle)
 Get the font style flags for a scope path.
 
TML_API uint32_t textmate_theme_get_default_foreground (TextMateTheme theme)
 Get the default/fallback foreground color for the entire theme.
 
TML_API uint32_t textmate_theme_get_default_background (TextMateTheme theme)
 Get the default/fallback background color for the entire theme.
 
TML_API void textmate_theme_dispose (TextMateTheme theme)
 Free a theme object and release resources.
 

Detailed Description

Load and query color schemes (themes) for syntax highlighting.

Theme parsing and scope-to-color mapping.

Themes map scope hierarchies to foreground/background colors and font styles.

Macro Definition Documentation

◆ TEXTMATE_FONT_STYLE_NONE

#define TEXTMATE_FONT_STYLE_NONE   0

Font style flag constants for textmate_theme_get_font_style()

No special styling

Definition at line 155 of file c_api.h.

Function Documentation

◆ textmate_theme_dispose()

TML_API void textmate_theme_dispose ( TextMateTheme  theme)

Free a theme object and release resources.

Parameters
themeValid theme handle (from textmate_theme_load_*), or NULL (no-op)
Warning
Do not use theme after calling this function
Note
Safe to call with NULL

Definition at line 437 of file c_api.cpp.

◆ textmate_theme_get_background()

TML_API uint32_t textmate_theme_get_background ( TextMateTheme  theme,
const char *  scopePath,
uint32_t  defaultColor 
)

Get the background color for a scope path.

Parameters
themeValid theme handle (from textmate_theme_load_*)
scopePathScope path to match
defaultColorColor to return if scope is not found in theme
Returns
RGBA color value (0xRRGGBBAA format)
See also
textmate_theme_get_foreground()

Definition at line 278 of file c_api.cpp.

◆ textmate_theme_get_default_background()

TML_API uint32_t textmate_theme_get_default_background ( TextMateTheme  theme)

Get the default/fallback background color for the entire theme.

Parameters
themeValid theme handle (from textmate_theme_load_*)
Returns
RGBA color value (0xRRGGBBAA format)
Note
Used when no matching scope is found in the theme

Definition at line 416 of file c_api.cpp.

◆ textmate_theme_get_default_foreground()

TML_API uint32_t textmate_theme_get_default_foreground ( TextMateTheme  theme)

Get the default/fallback foreground color for the entire theme.

Parameters
themeValid theme handle (from textmate_theme_load_*)
Returns
RGBA color value (0xRRGGBBAA format)
Note
Used when no matching scope is found in the theme

Definition at line 395 of file c_api.cpp.

◆ textmate_theme_get_font_style()

TML_API int32_t textmate_theme_get_font_style ( TextMateTheme  theme,
const char *  scopePath,
int32_t  defaultStyle 
)

Get the font style flags for a scope path.

Parameters
themeValid theme handle (from textmate_theme_load_*)
scopePathScope path to match
defaultStyleFont style flags to return if scope is not found
Returns
Combination of TEXTMATE_FONT_STYLE_* flags
Note
Flags can be combined with bitwise OR (e.g., BOLD | ITALIC)
See also
textmate_theme_get_foreground()

Definition at line 341 of file c_api.cpp.

◆ textmate_theme_get_foreground()

TML_API uint32_t textmate_theme_get_foreground ( TextMateTheme  theme,
const char *  scopePath,
uint32_t  defaultColor 
)

Get the foreground color for a scope path.

Parameters
themeValid theme handle (from textmate_theme_load_*)
scopePathScope path to match (e.g., "source.js keyword.control", "string.quoted.double")
defaultColorColor to return if scope is not found in theme
Returns
RGBA color value (0xRRGGBBAA format, e.g., 0xFF0000FF for opaque red)
Note
Scope matching uses TextMate's scope selector rules
See also
textmate_theme_get_background(), textmate_theme_get_font_style()

Definition at line 215 of file c_api.cpp.

◆ textmate_theme_load_from_file()

TML_API TextMateTheme textmate_theme_load_from_file ( const char *  themePath)

Load a theme from a JSON file.

Parameters
themePathPath to the theme JSON file (TextMate theme format)
Returns
Opaque theme handle on success, NULL on error (file not found, invalid JSON, etc.)
Note
The returned theme must be disposed with textmate_theme_dispose()

Definition at line 162 of file c_api.cpp.

◆ textmate_theme_load_from_json()

TML_API TextMateTheme textmate_theme_load_from_json ( const char *  jsonContent)

Load a theme from a JSON string.

Parameters
jsonContentTheme JSON content as a null-terminated string
Returns
Opaque theme handle on success, NULL on error (invalid JSON)
Note
The returned theme must be disposed with textmate_theme_dispose()

Definition at line 191 of file c_api.cpp.