libt3highlight
/home/gertjan/projects/tilde/highlight/src/highlight.h
00001 /* Copyright (C) 2011-2012 G.P. Halkes
00002    This program is free software: you can redistribute it and/or modify
00003    it under the terms of the GNU General Public License version 3, as
00004    published by the Free Software Foundation.
00005 
00006    This program is distributed in the hope that it will be useful,
00007    but WITHOUT ANY WARRANTY; without even the implied warranty of
00008    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009    GNU General Public License for more details.
00010 
00011    You should have received a copy of the GNU General Public License
00012    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00013 */
00014 #ifndef T3_HIGHLIGHT_H
00015 #define T3_HIGHLIGHT_H
00016 
00017 #include <t3config/config.h>
00018 #include <t3highlight/highlight_api.h>
00019 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00041 #define T3_HIGHLIGHT_VERSION 0
00042 
00046 #define T3_ERR_INVALID_FORMAT (-96)
00047 
00048 #define T3_ERR_INVALID_REGEX (-95)
00049 
00050 #define T3_ERR_NO_SYNTAX (-94)
00051 
00052 #define T3_ERR_UNDEFINED_USE (-93)
00053 
00054 #define T3_ERR_INVALID_NAME (-92)
00055 
00060 #define T3_HIGHLIGHT_UTF8 (1<<0)
00061 
00071 #define T3_HIGHLIGHT_UTF8_NOCHECK (1<<1)
00072 
00073 #define T3_HIGHLIGHT_USE_PATH (1<<2)
00074 
00075 #define T3_HIGHLIGHT_VERBOSE_ERROR (1<<3)
00076 
00082 typedef struct t3_highlight_t t3_highlight_t;
00086 typedef struct t3_highlight_match_t t3_highlight_match_t;
00087 
00091 typedef struct {
00092         char *name; 
00093         char *lang_file; 
00094 } t3_highlight_lang_t;
00095 
00100 typedef struct {
00101         int error;
00102         int line_number;
00103         char *file_name;
00104         char *extra;
00105 } t3_highlight_error_t;
00106 
00113 T3_HIGHLIGHT_API t3_highlight_lang_t *t3_highlight_list(int flags, t3_highlight_error_t *error);
00117 T3_HIGHLIGHT_API void t3_highlight_free_list(t3_highlight_lang_t *list);
00118 
00133 T3_HIGHLIGHT_API t3_highlight_t *t3_highlight_load(const char *name,
00134         int (*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error);
00146 T3_HIGHLIGHT_API t3_highlight_t *t3_highlight_load_by_filename(const char *name,
00147         int (*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error);
00159 T3_HIGHLIGHT_API t3_highlight_t *t3_highlight_load_by_langname(const char *name,
00160         int (*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error);
00173 T3_HIGHLIGHT_API t3_highlight_t *t3_highlight_load_by_detect(const char *line, size_t line_length, t3_bool first,
00174                 int (*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error);
00175 
00188 T3_HIGHLIGHT_API t3_highlight_t *t3_highlight_new(t3_config_t *syntax,
00189         int (*map_style)(void *, const char *), void *map_style_data, int flags, t3_highlight_error_t *error);
00190 
00194 T3_HIGHLIGHT_API void t3_highlight_free(t3_highlight_t *highlight);
00195 
00197 T3_HIGHLIGHT_API const char *t3_highlight_get_langfile(const t3_highlight_t *highlight);
00198 
00237 T3_HIGHLIGHT_API t3_bool t3_highlight_match(t3_highlight_match_t *match, const char *str, size_t size);
00238 
00243 T3_HIGHLIGHT_API t3_highlight_match_t *t3_highlight_new_match(const t3_highlight_t *highlight);
00247 T3_HIGHLIGHT_API void t3_highlight_free_match(t3_highlight_match_t *match);
00256 T3_HIGHLIGHT_API void t3_highlight_reset(t3_highlight_match_t *match, int state);
00260 T3_HIGHLIGHT_API size_t t3_highlight_get_start(t3_highlight_match_t *match);
00262 T3_HIGHLIGHT_API size_t t3_highlight_get_match_start(t3_highlight_match_t *match);
00264 T3_HIGHLIGHT_API size_t t3_highlight_get_end(t3_highlight_match_t *match);
00266 T3_HIGHLIGHT_API int t3_highlight_get_begin_attr(t3_highlight_match_t *match);
00268 T3_HIGHLIGHT_API int t3_highlight_get_match_attr(t3_highlight_match_t *match);
00270 T3_HIGHLIGHT_API int t3_highlight_get_state(t3_highlight_match_t *match);
00272 T3_HIGHLIGHT_API int t3_highlight_next_line(t3_highlight_match_t *match);
00273 
00278 T3_HIGHLIGHT_API const char *t3_highlight_strerror(int error);
00279 
00288 T3_HIGHLIGHT_API long t3_highlight_get_version(void);
00289 
00301 T3_HIGHLIGHT_API t3_bool t3_highlight_utf8check(const char *line, size_t size);
00302 
00318 T3_HIGHLIGHT_API char *t3_highlight_detect(const char *line, size_t line_length, t3_bool first,
00319         int flags, t3_highlight_error_t *error);
00320 
00321 #ifdef __cplusplus
00322 } /* extern "C" */
00323 #endif
00324 
00325 #endif
 All Data Structures Variables