aboutsummaryrefslogtreecommitdiff
path: root/syntax.h
blob: a4e4a33c3791c3191329ab08c5710d147d3d5672 (plain) (blame)
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
#ifndef SYNTAX_H
#define SYNTAX_H

#include <regex.h>

#define SYNTAX_RULES 10 /* maximal number of syntax rules per file type */

typedef struct {
	short fg, bg;   /* fore and background color */
	int attr;       /* curses attributes */
} Color;

typedef struct {
	char *rule;     /* regex to search for */
	Color *color;   /* settings to apply in case of a match */
	bool multiline; /* whether . should match new lines */
	regex_t regex;  /* compiled form of the above rule */
} SyntaxRule;

typedef struct Syntax Syntax;
struct Syntax {                         /* a syntax definition */
	char *name;                     /* syntax name */
	char *file;                     /* apply to files matching this regex */
	regex_t file_regex;             /* compiled file name regex */
	SyntaxRule rules[SYNTAX_RULES]; /* all rules for this file type */
};

#endif