1#ifndef TEXTMATELIB_C_API_H
2#define TEXTMATELIB_C_API_H
21#include "tml_export.h"
117 const char* themePath
125 const char* jsonContent
137 const char* scopePath,
138 uint32_t defaultColor
149 const char* scopePath,
150 uint32_t defaultColor
155#define TEXTMATE_FONT_STYLE_NONE 0
156#define TEXTMATE_FONT_STYLE_ITALIC 1
157#define TEXTMATE_FONT_STYLE_BOLD 2
158#define TEXTMATE_FONT_STYLE_UNDERLINE 4
170 const char* scopePath,
227 const char* grammarPath
238 const char* jsonContent
250 const char* scopeName,
251 const char** injections,
252 int32_t injectionCount
264 const char* scopeName
290 const char* lineText,
304 const char* lineText,
358 const char* lineText,
371 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_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 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_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_tokenize_result2(TextMateTokenizeResult2 *result)
Free an encoded line tokenization result.
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.
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.
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.