summaryrefslogtreecommitdiff
path: root/src/lib/elementary/elm_code_syntax.h
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-01-20 22:09:16 +0000
committerAndy Williams <andy@andywilliams.me>2017-01-20 22:11:01 +0000
commit5851a9d4a82b1fb5638d46f510fe9e8b6c7bdbb4 (patch)
tree9f457827fa32944125d607cff6c5218a5234a85b /src/lib/elementary/elm_code_syntax.h
parent3090e9c3ae3b12e36cf62dff224d6f6146bcc9d4 (diff)
elm_code: Add initial simple syntax highlighting for C code
For c source and headers lookup a simple syntax definition. Use a very simple text processing line by line to tokenise. Simple but it gets us one step closer to cross-language syntax
Diffstat (limited to 'src/lib/elementary/elm_code_syntax.h')
-rw-r--r--src/lib/elementary/elm_code_syntax.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/lib/elementary/elm_code_syntax.h b/src/lib/elementary/elm_code_syntax.h
new file mode 100644
index 0000000..268e11a
--- /dev/null
+++ b/src/lib/elementary/elm_code_syntax.h
@@ -0,0 +1,65 @@
1#ifndef ELM_CODE_SYNTAX_H_
2# define ELM_CODE_SYNTAX_H_
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8/**
9 * @file
10 * @brief These routines are used for handling the parsing of Elm Code content.
11 */
12
13typedef struct _Elm_Code_Syntax Elm_Code_Syntax;
14
15/**
16 * @brief Syntax highlighting helper functions.
17 * @defgroup Syntax Parsing and marking up syntax in files
18 *
19 * @{
20 *
21 * Syntax functions for adding syntax highlighting to elm code.
22 *
23 */
24
25/**
26 * Lookup a syntax definition from a mime type.
27 * If there is no syntax known NULL will be returned.
28 *
29 * @param mime The mime type to be looked up for a matching syntax definition
30 * @return A syntax definition, if one is found, or NULL
31 *
32 * @ingroup Syntax
33 */
34EAPI Elm_Code_Syntax *elm_code_syntax_for_mime_get(const char *mime);
35
36/**
37 * Parse a line and apply the syntax definition by inserting Elm_Code_Token into the line.
38 *
39 * @param syntax The syntax definition to use (from elm_code_syntax_for_mime_get)
40 * @param line The line that contains the content to parse and will receive the tokens
41 *
42 * @ingroup Syntax
43 */
44EAPI void elm_code_syntax_parse_line(Elm_Code_Syntax *syntax, Elm_Code_Line *line);
45
46/**
47 * Parse a file and apply the syntax definition one line at a time.
48 *
49 * @param syntax The syntax definition to use (from elm_code_syntax_for_mime_get)
50 * @param file The file to parse - each line in the file will be processed
51 *
52 * @ingroup Syntax
53 */
54EAPI void elm_code_syntax_parse_file(Elm_Code_Syntax *syntax, Elm_Code_File *file);
55
56
57/**
58 * @}
59 */
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif /* ELM_CODE_SYNTAX_H_ */