1#ifndef TEXTMATELIB_C_API_H
2#define TEXTMATELIB_C_API_H
21#include "tml_export.h"
141 const char* themePath
149 const char* jsonContent
161 const char* scopePath,
162 uint32_t defaultColor
173 const char* scopePath,
174 uint32_t defaultColor
179#define TEXTMATE_FONT_STYLE_NONE 0
180#define TEXTMATE_FONT_STYLE_ITALIC 1
181#define TEXTMATE_FONT_STYLE_BOLD 2
182#define TEXTMATE_FONT_STYLE_UNDERLINE 4
194 const char* scopePath,
251 const char* grammarPath
262 const char* jsonContent
274 const char* scopeName,
275 const char** injections,
276 int32_t injectionCount
287 const char* themeJsonContent
307 const char* scopeName
333 const char* lineText,
347 const char* lineText,
430 const char* lineText,
443 const char* lineText,
void * TextMateGrammar
Handle to a grammar definition for a specific language.
void * TextMateTheme
Handle to a theme object containing color schemes.
void * TextMateRegistry
Handle to the grammar registry managing loaded grammars and themes.
void * TextMateStateStack
Handle to a parsing state stack (immutable, used for incremental tokenization)
void * TextMateOnigLib
Handle to the Oniguruma regex library instance.
TML_API int textmate_registry_set_theme(TextMateRegistry registry, const char *themeJsonContent)
Set the color theme on the registry.
TML_API int textmate_registry_add_grammar_from_json(TextMateRegistry registry, const char *jsonContent)
Register a grammar from a JSON string.
TML_API TextMateOnigLib textmate_oniglib_create()
Initialize the Oniguruma regular expression library.
TML_API void textmate_registry_dispose(TextMateRegistry registry)
Free a registry and all its resources.
TML_API int textmate_registry_add_grammar_from_file(TextMateRegistry registry, const char *grammarPath)
Register a grammar from a JSON file.
TML_API TextMateRegistry textmate_registry_create(TextMateOnigLib onigLib)
Create a new grammar registry.
TML_API TextMateColorMap * textmate_registry_get_color_map(TextMateRegistry registry)
Get the color map from the registry after setting a theme.
TML_API TextMateGrammar textmate_registry_load_grammar(TextMateRegistry registry, const char *scopeName)
Load a grammar by scope name.
TML_API void textmate_registry_set_injections(TextMateRegistry registry, const char *scopeName, const char **injections, int32_t injectionCount)
Set grammar injection rules for a scope.
TML_API uint32_t textmate_theme_get_default_background(TextMateTheme theme)
Get the default/fallback background color for the entire theme.
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 void textmate_theme_dispose(TextMateTheme theme)
Free a theme object and release resources.
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 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 TextMateTheme textmate_theme_load_from_json(const char *jsonContent)
Load a theme from a JSON string.
TML_API TextMateTheme textmate_theme_load_from_file(const char *themePath)
Load a theme from a JSON file.
TML_API void textmate_free_tokenize_result(TextMateTokenizeResult *result)
Free a line tokenization result.
TML_API const char * textmate_grammar_get_scope_name(TextMateGrammar grammar)
Get the scope name (language identifier) of a grammar.
TML_API TextMateTokenizeMultiLinesResult * textmate_tokenize_lines(TextMateGrammar grammar, const char **lines, int32_t lineCount, TextMateStateStack initialState)
Tokenize multiple lines in a single call.
TML_API void textmate_oniglib_dispose(TextMateOnigLib onigLib)
Free the Oniguruma library.
TML_API TextMateStateStack textmate_get_initial_state()
Get the initial parsing state.
TML_API TextMateTokenizeResult2 * textmate_tokenize_line2(TextMateGrammar grammar, const char *lineText, TextMateStateStack prevState)
Tokenize a single line of text with encoded tokens (more efficient)
TML_API void textmate_free_tokenize_lines_result2(TextMateTokenizeMultiLinesResult2 *result)
Free a batch encoded tokenization result.
TML_API void textmate_free_tokenize_lines_result(TextMateTokenizeMultiLinesResult *result)
Free a batch tokenization result.
TML_API TextMateTokenizeResult * textmate_tokenize_line(TextMateGrammar grammar, const char *lineText, TextMateStateStack prevState)
Tokenize a single line of text with decoded scopes.
TML_API void textmate_free_color_map(TextMateColorMap *colorMap)
Free a color map.
TML_API void textmate_free_tokenize_result2(TextMateTokenizeResult2 *result)
Free an encoded line tokenization result.
TML_API TextMateTokenizeMultiLinesResult2 * textmate_tokenize_lines2(TextMateGrammar grammar, const char **lines, int32_t lineCount, TextMateStateStack initialState)
Tokenize multiple lines with encoded tokens in a single call.
TML_API TextMateTokenizeMultiLinesResult2 * textmate_tokenize_lines2_utf16(TextMateGrammar grammar, const char **lines, int32_t lineCount, TextMateStateStack initialState)
Tokenize multiple lines with encoded tokens, returning UTF-16 indices.
TML_API TextMateTokenizeMultiLinesResult * textmate_tokenize_lines_utf16(TextMateGrammar grammar, const char **lines, int32_t lineCount, TextMateStateStack initialState)
Tokenize multiple lines in a single call, returning UTF-16 indices.
TML_API TextMateTokenizeResult2 * textmate_tokenize_line2_utf16(TextMateGrammar grammar, const char *lineText, TextMateStateStack prevState)
Tokenize a single line with encoded tokens, returning UTF-16 indices.
TML_API TextMateTokenizeResult * textmate_tokenize_line_utf16(TextMateGrammar grammar, const char *lineText, TextMateStateStack prevState)
Tokenize a single line with decoded scopes, returning UTF-16 indices.
Theme color map returned by textmate_registry_get_color_map()
char ** colors
Array of hex color strings (e.g., "#RRGGBB" or "#RRGGBBAA")
int32_t colorCount
Number of colors in the array.
Represents a single token in tokenized text.
int32_t startIndex
Start position in the line (0-based)
int32_t endIndex
End position (exclusive)
char ** scopes
Array of scope strings (e.g., "keyword.control", "string.quoted.double")
int32_t scopeDepth
Number of scopes in the scope hierarchy.
Result from batch tokenizing multiple lines with encoded tokens.
TextMateTokenizeResult2 ** lineResults
Array of encoded results, one per line.
int32_t lineCount
Number of lines tokenized.
Result from batch tokenizing multiple lines.
int32_t lineCount
Number of lines tokenized.
TextMateTokenizeResult ** lineResults
Array of results, one per line.
Result from tokenizing a single line with encoded tokens.
int32_t tokenCount
Number of tokens in the array.
TextMateStateStack ruleStack
State at end of line (pass to next line's tokenization)
uint32_t * tokens
Array of encoded tokens.
int32_t stoppedEarly
Non-zero if tokenization stopped before end (time limit hit)
Result from tokenizing a single line with decoded tokens.
int32_t stoppedEarly
Non-zero if tokenization stopped before end (time limit hit)
TextMateStateStack ruleStack
State at end of line (pass to next line's tokenization)
TextMateToken * tokens
Array of tokens found in this line.
int32_t tokenCount
Number of tokens in the array.