lbuf: store marks for each modification more compactly
[neatvi.git] / conf.h
blob7a44e27360b193821e739534292eb15d2c0e9295
1 /* neatvi configuration file */
3 /* map file names to file types */
4 static struct filetype {
5 char *ft; /* file type */
6 char *pat; /* file name pattern */
7 } filetypes[] = {
8 {"c", "\\.[hc]$"},
9 {"roff", "\\.(ms|tr|roff|tmac|txt)$"},
10 {"tex", "\\.tex$"},
11 {"msg", "letter|mbox|mail"},
12 {"mk", "Makefile|makefile|\\.mk$"},
13 {"sh", "\\.sh$"},
16 /* syntax highlighting patterns */
17 static struct highlight {
18 char *ft; /* the filetype of this pattern */
19 int att[16]; /* attributes of the matched groups */
20 char *pat; /* regular expression */
21 int end; /* the group ending this pattern */
22 } highlights[] = {
23 {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
24 {"c", {5}, "\\<(static|extern|register)\\>"},
25 {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
26 {"c", {2 | SYN_IT}, "//.*$"},
27 {"c", {2 | SYN_IT}, "/\\*([^*]|\\*[^/])*\\*/"},
28 {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
29 {"c", {0, SYN_BD}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
30 {"c", {4}, "\"([^\"]|\\\\\")*\""},
31 {"c", {4}, "'([^\\]|\\\\.)'"},
32 {"c", {4}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
34 {"roff", {4, 0, 5 | SYN_BD, 4 | SYN_BD, 5 | SYN_BD, 4 | SYN_BD},
35 "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
36 {"roff", {2 | SYN_IT}, "\\\\\".*$"},
37 {"roff", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
38 {"roff", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
39 {"roff", {3}, "\\$[^$]+\\$"},
41 {"tex", {4 | SYN_BD, 0, 3, 0, 5},
42 "\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
43 {"tex", {3}, "\\$[^$]+\\$"},
44 {"tex", {2 | SYN_IT}, "%.*$"},
46 {"msg", {6 | SYN_BD}, "^From .*20..$"},
47 {"msg", {6 | SYN_BD, 4 | SYN_BD}, "^Subject: (.*)$"},
48 {"msg", {6 | SYN_BD, 2 | SYN_BD}, "^From: (.*)$"},
49 {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^To: (.*)$"},
50 {"msg", {6 | SYN_BD, 5 | SYN_BD}, "^Cc: (.*)$"},
51 {"msg", {6 | SYN_BD}, "^[A-Z][-A-Za-z]+: .+$"},
52 {"msg", {2 | SYN_IT}, "^> .*$"},
54 {"mk", {0, 3}, "([A-Za-z_][A-Za-z0-9_]*)[ \t]*="},
55 {"mk", {3}, "\\$\\([a-zA-Z0-9_]+\\)"},
56 {"mk", {2 | SYN_IT}, "#.*$"},
57 {"mk", {0, SYN_BD}, "([A-Za-z_%.]+):"},
59 {"sh", {2 | SYN_IT}, "#.*$"},
60 {"sh", {4}, "\"([^\"]|\\\\\")*\""},
61 {"sh", {4}, "\'[^\']*\'"},
64 /* how to hightlight text in the reverse direction */
65 #define SYN_REVDIR (SYN_BGMK(255))
67 /* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
68 #define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی‌‍؛،»«؟ًٌٍَُِّْ"
69 /* neutral characters (used only in dircontexts[] and dirmarks[]) */
70 #define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
72 /* direction context patterns; specifies the direction of a whole line */
73 static struct dircontext {
74 int dir;
75 char *pat;
76 } dircontexts[] = {
77 {-1, "^[" CR2L "]"},
78 {+1, "^[a-zA-Z_0-9]"},
81 /* direction marks; the direction of a few words in a line */
82 static struct dirmark {
83 int ctx; /* the direction context for this mark; 0 means any */
84 int dir; /* the direction of the matched text */
85 int grp; /* the nested subgroup; 0 means no groups */
86 char *pat;
87 } dirmarks[] = {
88 {+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
89 {+1, -1, 0, "[" CR2L "][" CNEUT CR2L "]*[" CR2L "]"},
90 {-1, +1, 0, "[a-zA-Z0-9_][^" CR2L "\\\\`$']*[a-zA-Z0-9_]"},
91 {+0, +1, 0, "\\$([^$]+)\\$"},
92 {+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
93 {-1, +1, 0, "\\\\[^ \t" CR2L "]+"},
96 /* character placeholders */
97 static struct placeholder {
98 char *s; /* the source character */
99 char *d; /* the placeholder */
100 int wid; /* the width of the placeholder */
101 } placeholders[] = {
102 {"‌", "-", 1},
103 {"‍", "-", 1},
104 {"ْ", "ـْ", 1},
105 {"ٌ", "ـٌ", 1},
106 {"ٍ", "ـٍ", 1},
107 {"ً", "ـً", 1},
108 {"ُ", "ـُ", 1},
109 {"ِ", "ـِ", 1},
110 {"َ", "ـَ", 1},
111 {"ّ", "ـّ", 1},