14 #ifndef T3_HIGHLIGHT_H
15 #define T3_HIGHLIGHT_H
17 #include <t3config/config.h>
18 #include <t3highlight/highlight_api.h>
41 #define T3_HIGHLIGHT_VERSION 0
46 #define T3_ERR_INVALID_FORMAT (-96)
48 #define T3_ERR_INVALID_REGEX (-95)
50 #define T3_ERR_NO_SYNTAX (-94)
52 #define T3_ERR_UNDEFINED_USE (-93)
54 #define T3_ERR_INVALID_NAME (-92)
56 #define T3_ERR_EMPTY_START_CYCLE (-91)
58 #define T3_ERR_USE_CYCLE (-90)
64 #define T3_HIGHLIGHT_UTF8 (1<<0)
75 #define T3_HIGHLIGHT_UTF8_NOCHECK (1<<1)
77 #define T3_HIGHLIGHT_USE_PATH (1<<2)
79 #define T3_HIGHLIGHT_VERBOSE_ERROR (1<<3)
140 int (*map_style)(
void *,
const char *),
void *map_style_data,
int flags,
t3_highlight_error_t *error);
155 int (*map_style)(
void *,
const char *),
void *map_style_data,
int flags,
t3_highlight_error_t *error);
168 int (*map_style)(
void *,
const char *),
void *map_style_data,
int flags,
t3_highlight_error_t *error);
182 int (*map_style)(
void *,
const char *),
void *map_style_data,
int flags,
t3_highlight_error_t *error);
197 int (*map_style)(
void *,
const char *),
void *map_style_data,
int flags,
t3_highlight_error_t *error);
void t3_highlight_free_match(t3_highlight_match_t *match)
Free t3_highlight_match_t structure.
Definition: match.c:303
t3_highlight_t * t3_highlight_load(const char *name, int(*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error)
Load a highlighting pattern, using a language file name.
Definition: io.c:239
char * t3_highlight_detect(const char *line, size_t line_length, t3_bool first, int flags, t3_highlight_error_t *error)
Detect the language of a file from line data.
Definition: io.c:322
int t3_highlight_get_match_attr(t3_highlight_match_t *match)
Get the attribute for the match section of the result.
Definition: match.c:327
int line_number
Line number where the error occured, but only if T3_HIGHLIGHT_VERBOSE_ERROR is set.
Definition: highlight.h:106
char * file_name
File name in which the error occured or NULL, but only if T3_HIGHLIGHT_VERBOSE_ERROR is set...
Definition: highlight.h:107
t3_highlight_t * t3_highlight_new(t3_config_t *syntax, int(*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error)
Create a highlighting pattern from a previously created configuration.
Definition: highlight.c:39
void t3_highlight_free(t3_highlight_t *highlight)
Free all memory associated with a highlighting pattern.
Definition: highlight.c:503
t3_highlight_t * t3_highlight_load_by_filename(const char *name, int(*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error)
Load a highlighting pattern, using a source file name.
Definition: io.c:227
t3_highlight_t * t3_highlight_load_by_langname(const char *name, int(*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error)
Load a highlighting pattern, using a language name.
Definition: io.c:233
int t3_highlight_get_state(t3_highlight_match_t *match)
Get the state represented by match.
Definition: match.c:331
An opaque struct representing a match and current state during highlighting.
Definition: internal.h:102
t3_bool t3_highlight_utf8check(const char *line, size_t size)
Check that a string is valid UTF8.
Definition: utf8.c:17
An opaque struct representing a highlighting pattern.
Definition: internal.h:83
const char * t3_highlight_get_langfile(const t3_highlight_t *highlight)
Get the language file associated with this highlighting pattern.
Definition: io.c:311
t3_highlight_match_t * t3_highlight_new_match(const t3_highlight_t *highlight)
Allocate and initialize a new t3_highlight_match_t structure.
Definition: match.c:277
long t3_highlight_get_version(void)
Get the value of T3_HIGHLIGHT_VERSION corresponding to the actual used library.
Definition: highlight.c:551
t3_highlight_lang_t * t3_highlight_list(int flags, t3_highlight_error_t *error)
List the known languages.
Definition: io.c:129
char t3_bool
A boolean type that does not clash with C++ or C99 bool.
Definition: highlight_api.h:47
A struct representing a display name/language file name tuple.
Definition: highlight.h:95
char * lang_file
Name of the language file, to be used with t3_highlight_load.
Definition: highlight.h:97
size_t t3_highlight_get_end(t3_highlight_match_t *match)
Get the end of the match.
Definition: match.c:319
void t3_highlight_reset(t3_highlight_match_t *match, int state)
Reset a t3_highlight_match_t structure.
void t3_highlight_free_list(t3_highlight_lang_t *list)
Free a list returned by t3_highlight_list.
Definition: io.c:161
t3_highlight_t * t3_highlight_load_by_detect(const char *line, size_t line_length, t3_bool first, int(*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error)
Load a highlighting pattern, based on auto-detection from the line content.
Definition: io.c:389
size_t t3_highlight_get_match_start(t3_highlight_match_t *match)
Get the start of the match.
Definition: match.c:315
A struct with error information.
Definition: highlight.h:104
char * extra
Further information about the error or NULL, but only if T3_HIGHLIGHT_VERBOSE_ERROR is set...
Definition: highlight.h:109
char * name
Display name of a language.
Definition: highlight.h:96
t3_bool t3_highlight_match(t3_highlight_match_t *match, const char *str, size_t size)
Find the next highlighting match in a subject string.
Definition: match.c:195
int t3_highlight_get_begin_attr(t3_highlight_match_t *match)
Get the attribute for the pre-match section of the result.
Definition: match.c:323
const char * t3_highlight_strerror(int error)
Get a string description for an error code.
Definition: highlight.c:528
int t3_highlight_next_line(t3_highlight_match_t *match)
Set up match for highlighting the next line of input.
Definition: match.c:335
size_t t3_highlight_get_start(t3_highlight_match_t *match)
Get the start index of a result.
Definition: match.c:311