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 */
8 {"c", "\\.[hc]$"}, /* C */
9 {"roff", "\\.(ms|tr|roff|tmac|txt|[1-9])$"}, /* troff */
10 {"tex", "\\.tex$"}, /* tex */
11 {"msg", "letter$|mbox$|mail$"}, /* email */
12 {"mk", "Makefile$|makefile$|\\.mk$"}, /* makefile */
13 {"sh", "\\.sh$"}, /* shell script */
14 {"nm", "\\.nm$"}, /* neatmail */
17 /* syntax highlighting patterns */
18 static struct highlight
{
19 char *ft
; /* the filetype of this pattern */
20 int att
[16]; /* attributes of the matched groups */
21 char *pat
; /* regular expression */
22 int end
; /* the group ending this pattern */
24 {"c", {5}, "\\<(signed|unsigned|char|short|int|long|float|double|void|struct|enum|union|typedef)\\>"},
25 {"c", {5}, "\\<(static|extern|register)\\>"},
26 {"c", {4}, "\\<(return|for|while|if|else|do|sizeof|goto|switch|case|default|break|continue)\\>"},
27 {"c", {2 | SYN_IT
}, "//.*$"},
28 {"c", {2 | SYN_IT
}, "/\\*([^*]|\\*+[^*/])*\\*+/"},
29 {"c", {6}, "^#[ \t]*[a-zA-Z0-9_]+"},
30 {"c", {0, SYN_BD
}, "([a-zA-Z][a-zA-Z0-9_]+)\\(", 1},
31 {"c", {4}, "\"([^\"]|\\\\\")*\""},
32 {"c", {4}, "'([^\\]|\\\\.)'"},
33 {"c", {4}, "[-+]?\\<(0[xX][0-9a-fA-F]+|[0-9]+)\\>"},
35 {"roff", {4, 0, 5 | SYN_BD
, 4 | SYN_BD
, 5 | SYN_BD
, 4 | SYN_BD
},
36 "^[.'][ \t]*((SH.*)|(de) (.*)|([^ \t\\]{2,}))?.*$", 1},
37 {"roff", {2 | SYN_IT
}, "\\\\\".*$"},
38 {"roff", {3}, "\\\\{1,2}[*$fgkmns]([^[(]|\\(..|\\[[^]]*\\])"},
39 {"roff", {3}, "\\\\([^[(*$fgkmns]|\\(..|\\[[^]]*\\])"},
40 {"roff", {3}, "\\$[^$]+\\$"},
42 {"tex", {4 | SYN_BD
, 0, 3, 0, 5},
43 "\\\\[^[{ \t]+(\\[([^]]+)\\])?(\\{([^}]*)\\})?"},
44 {"tex", {3}, "\\$[^$]+\\$"},
45 {"tex", {2 | SYN_IT
}, "%.*$"},
48 {"msg", {6 | SYN_BD
}, "^From .*20..$"},
49 {"msg", {6 | SYN_BD
, 4 | SYN_BD
}, "^Subject: (.*)$"},
50 {"msg", {6 | SYN_BD
, 2 | SYN_BD
}, "^From: (.*)$"},
51 {"msg", {6 | SYN_BD
, 5 | SYN_BD
}, "^To: (.*)$"},
52 {"msg", {6 | SYN_BD
, 5 | SYN_BD
}, "^Cc: (.*)$"},
53 {"msg", {6 | SYN_BD
}, "^[A-Z][-A-Za-z]+: .+$"},
54 {"msg", {2 | SYN_IT
}, "^> .*$"},
57 {"mk", {0, 3}, "([A-Za-z_][A-Za-z0-9_]*)[ \t]*="},
58 {"mk", {3}, "\\$\\([a-zA-Z0-9_]+\\)"},
59 {"mk", {2 | SYN_IT
}, "#.*$"},
60 {"mk", {0, SYN_BD
}, "([A-Za-z_%.]+):"},
63 {"sh", {2 | SYN_IT
}, "#.*$"},
64 {"sh", {4}, "\"([^\"]|\\\\\")*\""},
65 {"sh", {4}, "\'[^\']*\'"},
68 {"nm", {0, 12 | SYN_BD
, 12 | SYN_BD
, 2, 8 | SYN_BD
},
69 "^([ROU])([0-9]+)\t([^\t]*)\t([^\t]*)"},
70 {"nm", {7}, "^[LJ].*$"},
71 {"nm", {0 | SYN_BD
| SYN_BGMK(13)}, "^[HT].*$"},
72 {"nm", {0 | SYN_BD
| SYN_BGMK(11)}, "^[MI].*$"},
73 {"nm", {0 | SYN_BD
| SYN_BGMK(12)}, "^[N].*$"},
74 {"nm", {0 | SYN_BD
| SYN_BGMK(10)}, "^[F].*$"},
75 {"nm", {7 | SYN_IT
}, "^\t.*$"},
76 {"nm", {SYN_BD
}, "^:.*$"},
79 {"---", {8 | SYN_BD
, 4, 1}, "^(\".*\").*(\\[[wr]\\]).*$"},
80 {"---", {8 | SYN_BD
, 4, 4}, "^(\".*\").*(L[0-9]+) +(C[0-9]+).*$"},
81 {"---", {8 | SYN_BD
}, "^.*$"},
84 /* how to hightlight text in the reverse direction */
85 #define SYN_REVDIR (SYN_BGMK(255))
87 /* right-to-left characters (used only in dircontexts[] and dirmarks[]) */
88 #define CR2L "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىييپچژکگی؛،»«؟ًٌٍَُِّْ"
89 /* neutral characters (used only in dircontexts[] and dirmarks[]) */
90 #define CNEUT "-!\"#$%&'()*+,./:;<=>?@^_`{|}~ "
92 /* direction context patterns; specifies the direction of a whole line */
93 static struct dircontext
{
98 {+1, "^[a-zA-Z_0-9]"},
101 /* direction marks; the direction of a few words in a line */
102 static struct dirmark
{
103 int ctx
; /* the direction context for this mark; 0 means any */
104 int dir
; /* the direction of the matched text */
105 int grp
; /* the nested subgroup; 0 means no groups */
108 {+0, +1, 1, "\\\\\\*\\[([^]]+)\\]"},
109 {+1, -1, 0, "[" CR2L
"][" CNEUT CR2L
"]*[" CR2L
"]"},
110 {-1, +1, 0, "[a-zA-Z0-9_][^" CR2L
"\\\\`$']*[a-zA-Z0-9_]"},
111 {+0, +1, 0, "\\$([^$]+)\\$"},
112 {+0, +1, 1, "\\\\[a-zA-Z0-9_]+\\{([^}]+)\\}"},
113 {-1, +1, 0, "\\\\[^ \t" CR2L
"]+"},
116 /* character placeholders */
117 static struct placeholder
{
118 char *s
; /* the source character */
119 char *d
; /* the placeholder */
120 int wid
; /* the width of the placeholder */