summaryrefslogtreecommitdiff
path: root/syntax.h
blob: 9bf85a42c7c19b7f8c08e847c46e107f0362aa4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef _SYNTAX_H
#define _SYNTAX_H

#include <stdlib.h>

#include "editor.h"
#include "row.h"

#define HIGHLIGHT_FLAG_NUMBERS (1 << 0)
#define HIGHLIGHT_FLAG_STRINGS (1 << 1)

struct editor_syntax {
	char* filetype;
	char** filetype_match;
	char** keywords;
	char* single_line_comment_start;
	char* multi_line_comment_start;
	char* multi_line_comment_end;
	int flags;
};

enum editor_highlight {
	HIGHLIGHT_NORMAL = 0,
	HIGHLIGHT_COMMENT,
	HIGHLIGHT_MULTILINE_COMMENT,
	HIGHLIGHT_KEYWORD1,
	HIGHLIGHT_KEYWORD2,
	HIGHLIGHT_STRING,
	HIGHLIGHT_NUMBER,
	HIGHLIGHT_MATCH
};

#define HIGHLIGHT_DATABASE_ENTRY_COUNT (sizeof(highlight_database) / sizeof(highlight_database[0]))

void editor_update_syntax(struct editor_state* editor, struct editor_row* row);
int editor_syntax_to_colour(int highlight);
void editor_select_syntax_highlight(struct editor_state* editor);

#endif