Rizin
unix-like reverse engineering framework and cli tools
highlight.h
Go to the documentation of this file.
1 #ifndef TREE_SITTER_HIGHLIGHT_H_
2 #define TREE_SITTER_HIGHLIGHT_H_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <stdint.h>
9 
10 typedef enum {
19 
20 typedef struct TSHighlighter TSHighlighter;
22 
23 // Construct a `TSHighlighter` by providing a list of strings containing
24 // the HTML attributes that should be applied for each highlight value.
26  const char **highlight_names,
27  const char **attribute_strings,
28  uint32_t highlight_count
29 );
30 
31 // Delete a syntax highlighter.
33 
34 // Add a `TSLanguage` to a highlighter. The language is associated with a
35 // scope name, which can be used later to select a language for syntax
36 // highlighting. Along with the language, you must provide a JSON string
37 // containing the compiled PropertySheet to use for syntax highlighting
38 // with that language. You can also optionally provide an 'injection regex',
39 // which is used to detect when this language has been embedded in a document
40 // written in a different language.
42  TSHighlighter *self,
43  const char *scope_name,
44  const char *injection_regex,
45  const TSLanguage *language,
46  const char *highlight_query,
47  const char *injection_query,
48  const char *locals_query,
49  uint32_t highlight_query_len,
50  uint32_t injection_query_len,
51  uint32_t locals_query_len
52 );
53 
54 // Compute syntax highlighting for a given document. You must first
55 // create a `TSHighlightBuffer` to hold the output.
57  const TSHighlighter *self,
58  const char *scope_name,
59  const char *source_code,
60  uint32_t source_code_len,
62  const size_t *cancellation_flag
63 );
64 
65 // TSHighlightBuffer: This struct stores the HTML output of syntax
66 // highlighting. It can be reused for multiple highlighting calls.
68 
69 // Delete a highlight buffer.
71 
72 // Access the HTML content of a highlight buffer.
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif // TREE_SITTER_HIGHLIGHT_H_
void ts_highlight_buffer_delete(TSHighlightBuffer *)
void ts_highlighter_delete(TSHighlighter *)
TSHighlightBuffer * ts_highlight_buffer_new()
const uint8_t * ts_highlight_buffer_content(const TSHighlightBuffer *)
const uint32_t * ts_highlight_buffer_line_offsets(const TSHighlightBuffer *)
uint32_t ts_highlight_buffer_line_count(const TSHighlightBuffer *)
TSHighlightError ts_highlighter_add_language(TSHighlighter *self, const char *scope_name, const char *injection_regex, const TSLanguage *language, const char *highlight_query, const char *injection_query, const char *locals_query, uint32_t highlight_query_len, uint32_t injection_query_len, uint32_t locals_query_len)
uint32_t ts_highlight_buffer_len(const TSHighlightBuffer *)
TSHighlighter * ts_highlighter_new(const char **highlight_names, const char **attribute_strings, uint32_t highlight_count)
TSHighlightError ts_highlighter_highlight(const TSHighlighter *self, const char *scope_name, const char *source_code, uint32_t source_code_len, TSHighlightBuffer *output, const size_t *cancellation_flag)
struct TSHighlighter TSHighlighter
Definition: highlight.h:20
TSHighlightError
Definition: highlight.h:10
@ TSHighlightTimeout
Definition: highlight.h:13
@ TSHighlightInvalidLanguage
Definition: highlight.h:14
@ TSHighlightOk
Definition: highlight.h:11
@ TSHighlightUnknownScope
Definition: highlight.h:12
@ TSHighlightInvalidRegex
Definition: highlight.h:16
@ TSHighlightInvalidQuery
Definition: highlight.h:17
@ TSHighlightInvalidUtf8
Definition: highlight.h:15
struct TSHighlightBuffer TSHighlightBuffer
Definition: highlight.h:21
unsigned int uint32_t
Definition: sftypes.h:29
unsigned char uint8_t
Definition: sftypes.h:31
diff_output_t output
Definition: zipcmp.c:237