1 /*******************************************************************************
2 *									       *
3 * highlightData.c -- Maintain, and allow user to edit, highlight pattern list  *
4 *		     used for syntax highlighting			       *
5 *									       *
6 * Copyright (C) 1999 Mark Edel						       *
7 *									       *
8 * This is free software; you can redistribute it and/or modify it under the    *
9 * terms of the GNU General Public License as published by the Free Software    *
10 * Foundation; either version 2 of the License, or (at your option) any later   *
11 * version. In addition, you may distribute version of this program linked to   *
12 * Motif or Open Motif. See README for details.                                 *
13 *                                                                              *
14 * This software is distributed in the hope that it will be useful, but WITHOUT *
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
16 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License        *
17 * for more details.							       *
18 * 									       *
19 * You should have received a copy of the GNU General Public License along with *
20 * software; if not, write to the Free Software Foundation, Inc., 59 Temple     *
21 * Place, Suite 330, Boston, MA  02111-1307 USA		                       *
22 *									       *
23 * Nirvana Text Editor	    						       *
24 * April, 1997								       *
25 *									       *
26 * Written by Mark Edel							       *
27 *									       *
28 *******************************************************************************/
29 
30 #ifdef HAVE_CONFIG_H
31 #include "../config.h"
32 #endif
33 
34 #include "highlightData.h"
35 #include "textBuf.h"
36 #include "nedit.h"
37 #include "highlight.h"
38 #include "regularExp.h"
39 #include "preferences.h"
40 #include "help.h"
41 #include "window.h"
42 #include "regexConvert.h"
43 #include "../util/misc.h"
44 #include "../util/DialogF.h"
45 #include "../util/managedList.h"
46 #include "../util/nedit_malloc.h"
47 
48 #include <stdio.h>
49 #include <string.h>
50 #include <limits.h>
51 #ifdef VMS
52 #include "../util/VMSparam.h"
53 #else
54 #ifndef __MVS__
55 #include <sys/param.h>
56 #endif
57 #endif /*VMS*/
58 
59 #include <Xm/Xm.h>
60 #include <Xm/Form.h>
61 #include <Xm/Frame.h>
62 #include <Xm/Text.h>
63 #include <Xm/LabelG.h>
64 #include <Xm/PushB.h>
65 #include <Xm/ToggleB.h>
66 #include <Xm/RowColumn.h>
67 #include <Xm/SeparatoG.h>
68 
69 #ifdef HAVE_DEBUG_H
70 #include "../debug.h"
71 #endif
72 
73 /* Maximum allowed number of styles (also limited by representation of
74    styles as a byte - 'b') */
75 #define MAX_HIGHLIGHT_STYLES 128
76 
77 /* Maximum number of patterns allowed in a pattern set (regular expression
78    limitations are probably much more restrictive).  */
79 #define MAX_PATTERNS 127
80 
81 /* Names for the fonts that can be used for syntax highlighting */
82 #define N_FONT_TYPES 4
83 enum fontTypes {PLAIN_FONT, ITALIC_FONT, BOLD_FONT, BOLD_ITALIC_FONT};
84 static const char *FontTypeNames[N_FONT_TYPES] =
85    {"Plain", "Italic", "Bold", "Bold Italic"};
86 
87 typedef struct {
88     char *name;
89     char *color;
90     char *bgColor;
91     int font;
92 } highlightStyleRec;
93 
94 static int styleError(const char *stringStart, const char *stoppedAt,
95        const char *message);
96 #if 0
97 static int lookupNamedPattern(patternSet *p, char *patternName);
98 #endif
99 static int lookupNamedStyle(const char *styleName);
100 static highlightPattern *readHighlightPatterns(char **inPtr, int withBraces,
101        char **errMsg, int *nPatterns);
102 static int readHighlightPattern(char **inPtr, char **errMsg,
103     	highlightPattern *pattern);
104 static patternSet *readDefaultPatternSet(const char *langModeName);
105 static int isDefaultPatternSet(patternSet *patSet);
106 static patternSet *readPatternSet(char **inPtr, int convertOld);
107 static patternSet *highlightError(char *stringStart, char *stoppedAt,
108     	const char *message);
109 static char *intToStr(int i);
110 static char *createPatternsString(patternSet *patSet, char *indentStr);
111 static void setStyleByName(const char *style);
112 static void hsDestroyCB(Widget w, XtPointer clientData, XtPointer callData);
113 static void hsOkCB(Widget w, XtPointer clientData, XtPointer callData);
114 static void hsApplyCB(Widget w, XtPointer clientData, XtPointer callData);
115 static void hsCloseCB(Widget w, XtPointer clientData, XtPointer callData);
116 static highlightStyleRec *copyHighlightStyleRec(highlightStyleRec *hs);
117 static void *hsGetDisplayedCB(void *oldItem, int explicitRequest, int *abort,
118     	void *cbArg);
119 static void hsSetDisplayedCB(void *item, void *cbArg);
120 static highlightStyleRec *readHSDialogFields(int silent);
121 static void hsFreeItemCB(void *item);
122 static void freeHighlightStyleRec(highlightStyleRec *hs);
123 static int hsDialogEmpty(void);
124 static int updateHSList(void);
125 static void updateHighlightStyleMenu(void);
126 static void convertOldPatternSet(patternSet *patSet);
127 static void convertPatternExpr(char **patternRE, char *patSetName,
128 	char *patName, int isSubsExpr);
129 static Widget createHighlightStylesMenu(Widget parent);
130 static void destroyCB(Widget w, XtPointer clientData, XtPointer callData);
131 static void langModeCB(Widget w, XtPointer clientData, XtPointer callData);
132 static void lmDialogCB(Widget w, XtPointer clientData, XtPointer callData);
133 static void styleDialogCB(Widget w, XtPointer clientData, XtPointer callData);
134 static void patTypeCB(Widget w, XtPointer clientData, XtPointer callData);
135 static void matchTypeCB(Widget w, XtPointer clientData, XtPointer callData);
136 static int checkHighlightDialogData(void);
137 static void updateLabels(void);
138 static void okCB(Widget w, XtPointer clientData, XtPointer callData);
139 static void applyCB(Widget w, XtPointer clientData, XtPointer callData);
140 static void checkCB(Widget w, XtPointer clientData, XtPointer callData);
141 static void restoreCB(Widget w, XtPointer clientData, XtPointer callData);
142 static void deleteCB(Widget w, XtPointer clientData, XtPointer callData);
143 static void closeCB(Widget w, XtPointer clientData, XtPointer callData);
144 static void helpCB(Widget w, XtPointer clientData, XtPointer callData);
145 static void *getDisplayedCB(void *oldItem, int explicitRequest, int *abort,
146     	void *cbArg);
147 static void setDisplayedCB(void *item, void *cbArg);
148 static void setStyleMenu(const char *styleName);
149 static highlightPattern *readDialogFields(int silent);
150 static int dialogEmpty(void);
151 static int updatePatternSet(void);
152 static patternSet *getDialogPatternSet(void);
153 static int patternSetsDiffer(patternSet *patSet1, patternSet *patSet2);
154 static highlightPattern *copyPatternSrc(highlightPattern *pat,
155     	highlightPattern *copyTo);
156 static void freeItemCB(void *item);
157 static void freePatternSrc(highlightPattern *pat, int freeStruct);
158 static void freePatternSet(patternSet *p);
159 
160 /* list of available highlight styles */
161 static int NHighlightStyles = 0;
162 static highlightStyleRec *HighlightStyles[MAX_HIGHLIGHT_STYLES];
163 
164 /* Highlight styles dialog information */
165 static struct {
166     Widget shell;
167     Widget nameW;
168     Widget colorW;
169     Widget bgColorW;
170     Widget plainW, boldW, italicW, boldItalicW;
171     Widget managedListW;
172     highlightStyleRec **highlightStyleList;
173     int nHighlightStyles;
174 } HSDialog = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0};
175 
176 /* Highlight dialog information */
177 static struct {
178     Widget shell;
179     Widget lmOptMenu;
180     Widget lmPulldown;
181     Widget styleOptMenu;
182     Widget stylePulldown;
183     Widget nameW;
184     Widget topLevelW;
185     Widget deferredW;
186     Widget subPatW;
187     Widget colorPatW;
188     Widget simpleW;
189     Widget rangeW;
190     Widget parentW;
191     Widget startW;
192     Widget endW;
193     Widget errorW;
194     Widget lineContextW;
195     Widget charContextW;
196     Widget managedListW;
197     Widget parentLbl;
198     Widget startLbl;
199     Widget endLbl;
200     Widget errorLbl;
201     Widget matchLbl;
202     char *langModeName;
203     int nPatterns;
204     highlightPattern **patterns;
205 } HighlightDialog = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
206                      NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
207                      NULL, NULL, NULL, NULL, NULL, 0, NULL };
208 
209 /* Pattern sources loaded from the .nedit file or set by the user */
210 static int NPatternSets = 0;
211 static patternSet *PatternSets[MAX_LANGUAGE_MODES];
212 
213 static char *DefaultPatternSets[] = {
214      "Ada:1:0{\n\
215 	Comments:\"--\":\"$\"::Comment::\n\
216 	String Literals:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
217 	Character Literals:\"'(?:[^\\\\]|\\\\.)'\":::Character Const::\n\
218 	Ada Attributes:\"(?i'size\\s+(use)>)|'\\l[\\l\\d]*(?:_[\\l\\d]+)*\":::Ada Attributes::\n\
219 	Size Attribute:\"\\1\":\"\"::Keyword:Ada Attributes:C\n\
220 	Based Numeric Literals:\"<(?:\\d+(?:_\\d+)*)#(?:[\\da-fA-F]+(?:_[\\da-fA-F]+)*)(?:\\.[\\da-fA-F]+(?:_[\\da-fA-F]+)*)?#(?iE[+\\-]?(?:\\d+(?:_\\d+)*))?(?!\\Y)\":::Numeric Const::\n\
221 	Numeric Literals:\"<(?:\\d+(?:_\\d+)*)(?:\\.\\d+(?:_\\d+)*)?(?iE[+\\-]?(?:\\d+(?:_\\d+)*))?>\":::Numeric Const::\n\
222 	Pragma:\"(?n(?ipragma)\\s+\\l[\\l\\d]*(?:_\\l[\\l\\d]*)*\\s*\\([^)]*\\)\\s*;)\":::Preprocessor::\n\
223 	Withs Use:\"(?#Make \\s work across newlines)(?n(?iwith|use)(?#Leading W/S)\\s+(?#First package name)(?:\\l[\\l\\d]*(?:(_|\\.\\l)[\\l\\d]*)*)(?#Additional package names [optional])(?:\\s*,\\s*(?:\\l[\\l\\d]*(?:(_|\\.\\l)[\\l\\d]+)*))*(?#Trailing W/S)\\s*;)+\":::Preprocessor::\n\
224 	Predefined Types:\"(?i(?=[bcdfilps]))<(?iboolean|character|count|duration|float|integer|long_float|long_integer|priority|short_float|short_integer|string)>\":::Storage Type::D\n\
225 	Predefined Subtypes:\"(?i(?=[fnp]))<(?ifield|natural|number_base|positive|priority)>\":::Storage Type::D\n\
226 	Reserved Words:\"(?i(?=[a-gil-pr-uwx]))<(?iabort|abs|accept|access|and|array|at|begin|body|case|constant|declare|delay|delta|digits|do|else|elsif|end|entry|exception|exit|for|function|generic|goto|if|in|is|limited|loop|mod|new|not|null|of|or|others|out|package|pragma|private|procedure|raise|range|record|rem|renames|return|reverse|select|separate|subtype|task|terminate|then|type|use|when|while|with|xor)>\":::Keyword::D\n\
227 	Dot All:\"\\.(?iall)>\":::Storage Type::\n\
228 	Ada 95 Only:\"(?i(?=[aprtu]))<(?iabstract|tagged|all|protected|aliased|requeue|until)>\":::Keyword::\n\
229 	Labels Parent:\"<(\\l[\\l\\d]*(?:_[\\l\\d]+)*)(?n\\s*:\\s*)(?ifor|while|loop|declare|begin)>\":::Keyword::D\n\
230 	Labels subpattern:\"\\1\":\"\"::Label:Labels Parent:DC\n\
231 	Endloop labels:\"<(?nend\\s+loop\\s+(\\l[\\l\\d]*(?:_[\\l\\d]+)*\\s*));\":::Keyword::\n\
232 	Endloop labels subpattern:\"\\1\":\"\"::Label:Endloop labels:C\n\
233 	Goto labels:\"\\<\\<\\l[\\l\\d]*(?:_[\\l\\d]+)*\\>\\>\":::Flag::\n\
234 	Exit parent:\"((?iexit))\\s+(\\l\\w*)(?i\\s+when>)?\":::Keyword::\n\
235 	Exit subpattern:\"\\2\":\"\"::Label:Exit parent:C\n\
236 	Identifiers:\"<(?:\\l[\\l\\d]*(?:_[\\l\\d]+)*)>\":::Identifier::D}",
237     "Awk:2:0{\n\
238 	Comment:\"#\":\"$\"::Comment::\n\
239 	Pattern:\"/(\\\\.|([[][]]?[^]]+[]])|[^/])+/\":::Preprocessor::\n\
240 	Keyword:\"<(return|print|printf|if|else|while|for|in|do|break|continue|next|exit|close|system|getline)>\":::Keyword::D\n\
241 	String:\"\"\"\":\"\"\"\":\"\\n\":String1::\n\
242 	String escape:\"\\\\(.|\\n)\":::String1:String:\n\
243 	Builtin functions:\"<(atan2|cos|exp|int|log|rand|sin|sqrt|srand|gsub|index|length|match|split|sprintf|sub|substr)>\":::Keyword::D\n\
244 	Gawk builtin functions:\"<(fflush|gensub|tolower|toupper|systime|strftime)>\":::Text Key1::D\n\
245 	Builtin variables:\"<(ARGC|ARGV|FILENAME|FNR|FS|NF|NR|OFMT|OFS|ORS|RLENGTH|RS|RSTART|SUBSEP)>\":::Storage Type::D\n\
246 	Gawk builtin variables:\"\"\"<(ARGIND|ERRNO|RT|IGNORECASE|FIELDWIDTHS)>\"\"\":::Storage Type::D\n\
247 	Field:\"\\$[0-9a-zA-Z_]+|\\$[ \\t]*\\([^,;]*\\)\":::Storage Type::D\n\
248 	BeginEnd:\"<(BEGIN|END)>\":::Preprocessor1::D\n\
249 	Numeric constant:\"(?<!\\Y)((0(x|X)[0-9a-fA-F]*)|[0-9.]+((e|E)(\\+|-)?)?[0-9]*)(L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::D\n\
250 	String pattern:\"~[ \\t]*\"\"\":\"\"\"\":\"\\n\":Preprocessor::\n\
251 	String pattern escape:\"\\\\(.|\\n)\":::Preprocessor:String pattern:\n\
252 	newline escape:\"\\\\$\":::Preprocessor1::\n\
253 	Function:\"function\":::Preprocessor1::D}",
254     "C++:1:0{\n\
255 	comment:\"/\\*\":\"\\*/\"::Comment::\n\
256 	cplus comment:\"//\":\"(?<!\\\\)$\"::Comment::\n\
257 	string:\"L?\"\"\":\"\"\"\":\"\\n\":String::\n\
258 	preprocessor line:\"^\\s*#\\s*(?:include|define|if|ifn?def|line|error|else|endif|elif|undef|pragma)>\":\"$\"::Preprocessor::\n\
259 	string escape chars:\"\\\\(?:.|\\n)\":::String1:string:\n\
260 	preprocessor esc chars:\"\\\\(?:.|\\n)\":::Preprocessor1:preprocessor line:\n\
261 	preprocessor comment:\"/\\*\":\"\\*/\"::Comment:preprocessor line:\n\
262 	preproc cplus comment:\"//\":\"$\"::Comment:preprocessor line:\n\
263     	preprocessor string:\"L?\"\"\":\"\"\"\":\"\\n\":Preprocessor1:preprocessor line:\n\
264     	prepr string esc chars:\"\\\\(?:.|\\n)\":::String1:preprocessor string:\n\
265 	preprocessor keywords:\"<__(?:LINE|FILE|DATE|TIME|STDC)__>\":::Preprocessor::\n\
266 	preprocessor keywords c++11:\"<__func__|__STDC_HOSTED__|_Pragma>\":::Preprocessor::\n\
267 	character constant:\"L?'\":\"'\":\"[^\\\\][^']\":Character Const::\n\
268 	numeric constant:\"(?<!\\Y)(?:(?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\\.?[0-9]*)|(?:\\.[0-9]+))(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::D\n\
269 	storage keyword:\"<(?:class|typename|typeid|template|friend|virtual|inline|explicit|operator|public|private|protected|const|extern|auto|register|static|mutable|unsigned|signed|volatile|char|double|float|int|long|short|bool|wchar_t|void|typedef|struct|union|enum|asm|export)>\":::Storage Type::D\n\
270 	storage keyword c++11:\"<(?:override|final|decltype|constexpr|noexcept)>\":::Storage Type::D\n\
271 	keyword:\"<(?:new|delete|this|return|goto|if|else|case|default|switch|break|continue|while|do|for|try|catch|throw|sizeof|true|false|namespace|using|dynamic_cast|static_cast|reinterpret_cast|const_cast)>\":::Keyword::D\n\
272 	keyword c++11:\"<(?:nullptr|static_assert|alignof)>\":::Keyword::D\n\
273 	braces:\"[{}]\":::Keyword::D}",
274     "C:1:0 {\n\
275     	comment:\"/\\*\":\"\\*/\"::Comment::\n\
276 	string:\"L?\"\"\":\"\"\"\":\"\\n\":String::\n\
277 	preprocessor line:\"^\\s*#\\s*(?:include|define|if|ifn?def|line|error|else|endif|elif|undef|pragma)>\":\"$\"::Preprocessor::\n\
278     	string escape chars:\"\\\\(?:.|\\n)\":::String1:string:\n\
279     	preprocessor esc chars:\"\\\\(?:.|\\n)\":::Preprocessor1:preprocessor line:\n\
280     	preprocessor comment:\"/\\*\":\"\\*/\"::Comment:preprocessor line:\n\
281     	preprocessor string:\"L?\"\"\":\"\"\"\":\"\\n\":Preprocessor1:preprocessor line:\n\
282     	prepr string esc chars:\"\\\\(?:.|\\n)\":::String1:preprocessor string:\n\
283 	preprocessor keywords:\"<__(?:LINE|FILE|DATE|TIME|STDC)__>\":::Preprocessor::\n\
284 	character constant:\"L?'\":\"'\":\"[^\\\\][^']\":Character Const::\n\
285 	numeric constant:\"(?<!\\Y)(?:(?:0(?:x|X)[0-9a-fA-F]*)|(?:(?:[0-9]+\\.?[0-9]*)|(?:\\.[0-9]+))(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::D\n\
286     	storage keyword:\"<(?:const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)>\":::Storage Type::D\n\
287     	keyword:\"<(?:return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)>\":::Keyword::D\n\
288     	braces:\"[{}]\":::Keyword::D}",
289     "CSS:1:0{\n\
290 	comment:\"/\\*\":\"\\*/\"::Comment::\n\
291 	import rule:\"@import\\s+(url\\([^)]+\\))\\s*\":\";\"::Warning::\n\
292 	import delim:\"&\":\"&\"::Preprocessor:import rule:C\n\
293 	import url:\"\\1\":::Subroutine1:import rule:C\n\
294 	import media:\"(all|screen|print|projection|aural|braille|embossed|handheld|tty|tv|,)\":::Preprocessor1:import rule:\n\
295 	media rule:\"(@media)\\s+\":\"(?=\\{)\"::Warning::\n\
296 	media delim:\"&\":\"&\"::Preprocessor:media rule:C\n\
297 	media type:\"(all|screen|print|projection|aural|braille|embossed|handheld|tty|tv|,)\":::Preprocessor1:media rule:\n\
298 	charset rule:\"@charset\\s+(\"\"[^\"\"]+\"\")\\s*;\":::Preprocessor::\n\
299 	charset name:\"\\1\":::String:charset rule:C\n\
300 	font-face rule:\"@font-face\":::Preprocessor::\n\
301 	page rule:\"@page\":\"(?=\\{)\"::Preprocessor1::\n\
302 	page delim:\"&\":\"&\"::Preprocessor:page rule:C\n\
303 	page pseudo class:\":(first|left|right)\":::Storage Type:page rule:\n\
304 	declaration:\"\\{\":\"\\}\"::Warning::\n\
305 	declaration delims:\"&\":\"&\"::Keyword:declaration:C\n\
306 	declaration comment:\"/\\*\":\"\\*/\"::Comment:declaration:\n\
307 	property:\"<(azimuth|background(-(attachment|color|image|position|repeat))?|border(-(bottom(-(color|style|width))?|-(color|style|width)|collapse|color|left(-(color|style|width))?|right(-(color|style|width))?|spacing|style|top(-(color|style|width))?|width))?|bottom|caption-side|clear|clip|color|content|counter-(increment|reset)|cue(-(after|before))?|cursor|direction|display|elevation|empty-cells|float|font(-(family|size|size-adjust|stretch|style|variant|weight))?|height|left|letter-spacing|line-height|list-style(-(image|position|type))?|margin(-(bottom|left|right|top))?|marker-offset|marks|max-(height|width)|min-(height|width)|orphans|outline(-(color|style|width))?|overflow|padding(-(bottom|left|right|top))?|page(-break-(after|before|inside))?|pause(-(after|before))?|pitch(-range)?|play-during|position|quotes|richness|right|size|speak(-(header|numeral|punctuation))?|speech-rate|stress|table-layout|text(-(align|decoration|indent|shadow|transform))|top|unicode-bidi|vertical-align|visibility|voice-family|volume|white-space|widows|width|word-spacing|z-index)>\":::Identifier1:declaration:\n\
308 	value:\":\":\";\":\"\\}\":Warning:declaration:\n\
309 	value delims:\"&\":\"&\"::Keyword:value:C\n\
310 	value modifier:\"!important|inherit\":::Keyword:value:\n\
311 	uri value:\"<url\\([^)]+\\)\":::Subroutine1:value:\n\
312 	clip value:\"<rect\\(\\s*([+-]?\\d+(?:\\.\\d*)?)(in|cm|mm|pt|pc|em|ex|px)\\s*(,|\\s)\\s*([+-]?\\d+(?:\\.\\d*)?)(in|cm|mm|pt|pc|em|ex|px)\\s*(,|\\s)\\s*([+-]?\\d+(?:\\.\\d*)?)(in|cm|mm|pt|pc|em|ex|px)\\s*(,|\\s)\\s*([+-]?\\d+(?:\\.\\d*)?)(in|cm|mm|pt|pc|em|ex|px)\\s*\\)\":::Subroutine:value:\n\
313 	function value:\"<attr\\([^)]+\\)|<counter\\((\\l|\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?))([-\\l\\d]|\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?))*\\s*(,\\s*<(disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-alpha|lower-latin|upper-alpha|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha|none)>)?\\)|<counters\\((\\l|\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?))([-\\l\\d]|\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?))*\\s*,\\s*(\"\"[^\"\"]*\"\"|'[^']*')\\s*(,\\s*<(disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-greek|lower-alpha|lower-latin|upper-alpha|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha|none)>)?\\)\":::Subroutine:value:\n\
314 	color value:\"(#[A-Fa-f\\d]{6}>|#[A-Fa-f\\d]{3}>|rgb\\(([+-]?\\d+(\\.\\d*)?)\\s*,\\s*([+-]?\\d+(\\.\\d*)?)\\s*,\\s*([+-]?\\d+(\\.\\d*)?)\\)|rgb\\(([+-]?\\d+(\\.\\d*)?%)\\s*,\\s*([+-]?\\d+(\\.\\d*)?%)\\s*,\\s*([+-]?\\d+(\\.\\d*)?%)\\)|<(?iaqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow)>|<transparent>)\":::Text Arg2:value:\n\
315 	dimension value:\"[+-]?(\\d*\\.\\d+|\\d+)(in|cm|mm|pt|pc|em|ex|px|deg|grad|rad|s|ms|hz|khz)>\":::Numeric Const:value:\n\
316 	percentage value:\"[+-]?(\\d*\\.\\d+|\\d+)%\":::Numeric Const:value:\n\
317 	named value:\"<(100|200|300|400|500|600|700|800|900|above|absolute|always|armenian|auto|avoid|baseline|behind|below|bidi-override|blink|block|bold|bolder|both|bottom|capitalize|caption|center(?:-left|-right)?|child|circle|cjk-ideographic|close-quote|code|collapse|compact|condensed|continuous|crop|cross(?:hair)?|cursive|dashed|decimal(?:-leading-zero)?|default|digits|disc|dotted|double|e-resize|embed|expanded|extra(?:-condensed|-expanded)|fantasy|far(?:-left|-right)|fast(?:er)?|female|fixed|georgian|groove|hebrew|help|hidden|hide|high(?:er)?|hiragana(?:-iroha)?|icon|inherit|inline(?:-table)?|inset|inside|italic|justify|katakana(?:-iroha)?|landscape|larger?|left(?:-side|wards)?|level|lighter|line-through|list-item|loud|low(?:er(?:-alpha|-greek|-latin|-roman|case)?)?|ltr|male|marker|medium|menu|message-box|middle|mix|monospace|move|n-resize|narrower|ne-resize|no(?:-close-quote|-open-quote|-repeat)|none|normal|nowrap|nw-resize|oblique|once|open-quote|out(?:set|side)|overline|pointer|portrait|pre|relative|repeat(?:-x|-y)?|ridge|right(?:-side|wards)?|rtl|run-in|s-resize|sans-serif|scroll|se-resize|semi(?:-condensed|-expanded)|separate|serif|show|silent|slow(?:er)?|small(?:-caps|-caption|er)?|soft|solid|spell-out|square|static|status-bar|sub|super|sw-resize|table(?:-caption|-cell|-column(?:-group)?|-footer-group|-header-group|-row(?:-group)?)?|text(?:-bottom|-top)?|thick|thin|top|ultra(?:-condensed|-expanded)|underline|upper(?:-alpha|-latin|-roman|case)|visible|w-resize|wait|wider|x-(?:fast|high|large|loud|low|slow|small|soft)|xx-(large|small))>\":::Text Arg2:value:\n\
318 	integer value:\"<\\d+>\":::Numeric Const:value:\n\
319 	font family:\"(?iarial|courier|impact|helvetica|lucida|symbol|times|verdana)\":::String:value:\n\
320 	dq string value:\"\"\"\":\"\"\"\":\"\\n\":String:value:\n\
321 	dq string escape:\"\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?)\":::Text Escape:dq string value:\n\
322 	dq string continuation:\"\\\\\\n\":::Text Escape:dq string value:\n\
323 	sq string value:\"'\":\"'\":\"\\n\":String:value:\n\
324 	sq string escape:\"\\\\([ -~\\0200-\\0377]|[\\l\\d]{1,6}\\s?)\":::Text Escape:sq string value:\n\
325 	sq string continuation:\"\\\\\\n\":::Text Escape:sq string value:\n\
326 	operators:\"[,/]\":::Keyword:value:\n\
327 	selector id:\"#[-\\w]+>\":::Pointer::\n\
328 	selector class:\"\\.[-\\w]+>\":::Storage Type::\n\
329 	selector pseudo class:\":(first-child|link|visited|hover|active|focus|lang(\\([\\-\\w]+\\))?)(?!\\Y)\":::Text Arg1::\n\
330 	selector attribute:\"\\[[^\\]]+\\]\":::Ada Attributes::\n\
331 	selector operators:\"[,>*+]\":::Keyword::\n\
332 	selector pseudo element:\":(first-letter|first-line|before|after)>\":::Text Arg::\n\
333 	type selector:\"<[\\l_][-\\w]*>\":::Plain::\n\
334 	free text:\".\":::Warning::\n\
335 	info:\"(?# version 1.31; author/maintainer: Joor Loohuis, joor@loohuis-consulting.nl)\":::Plain::D}",
336     "Csh:1:0{\n\
337 	Comment:\"#\":\"$\"::Comment::\n\
338 	Single Quote String:\"'\":\"([^\\\\]'|^')\":\"\\n\":String::\n\
339 	SQ String Esc Char:\"\\\\([bcfnrt$\\n\\\\]|[0-9][0-9]?[0-9]?)\":::String1:Single Quote String:\n\
340 	Double Quote String:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
341 	DQ String Esc Char:\"\\\\([bcfnrt\\n\\\\]|[0-9][0-9]?[0-9]?)\":::String1:Double Quote String:\n\
342 	Keywords:\"(^|[`;()])[ 	]*(return|if|endif|then|else|switch|endsw|while|end|foreach|do|done)>\":::Keyword::D\n\
343 	Variable Ref:\"\\$([<$0-9\\*]|[#a-zA-Z_?][0-9a-zA-Z_[\\]]*(:([ehqrtx]|gh|gt|gr))?|\\{[#0-9a-zA-Z_?][a-zA-Z0-9_[\\]]*(:([ehqrtx]|gh|gt|gr))?})\":::Identifier1::\n\
344 	Variable in String:\"\\$([<$0-9\\*]|[#a-zA-Z_?][0-9a-zA-Z_[\\]]*(:([ehqrtx]|gh|gt|gr))?|\\{[#0-9a-zA-Z_?][a-zA-Z0-9_[\\]]*(:([ehqrtx]|gh|gt|gr))?})\":::Identifier1:Double Quote String:\n\
345 	Naked Variable Cmds:\"<(unset|set|setenv|shift)[ \\t]+[0-9a-zA-Z_]*(\\[.+\\])?\":::Identifier1::\n\
346 	Recolor Naked Cmd:\"\\1\":::Keyword:Naked Variable Cmds:C\n\
347 	Built In Cmds:\"(^|\\|&|[\\|`;()])[ 	]*(alias|bg|break|breaksw|case|cd|chdir|continue|default|echo|eval|exec|exit|fg|goto|glob|hashstat|history|jobs|kill|limit|login|logout|nohup|notify|nice|onintr|popd|pushd|printenv|read|rehash|repeat|set|setenv|shift|source|suspend|time|umask|unalias|unhash|unlimit|unset|unsetenv|wait)>\":::Keyword::D\n\
348 	Tcsh Built In Cmds:\"(^|\\|&|[\\|`;()])[ 	]*(alloc|bindkey|builtins|complete|echotc|filetest|hup|log|sched|settc|setty|stop|telltc|uncomplete|where|which|dirs|ls-F)>\":::Keyword::D\n\
349 	Special Chars:\"([-{};.,<>&~=!|^%[\\]\\+\\*\\|()])\":::Keyword::D}",
350     "Fortran:2:0{\n\
351 	Comment:\"^[Cc*!]\":\"$\"::Comment::\n\
352 	Bang Comment:\"!\":\"$\"::Comment::\n\
353 	Debug Line:\"^D\":\"$\"::Preprocessor::\n\
354 	String:\"'\":\"'\":\"\\n([^ \\t]| [^ \\t]|  [^ \\t]|   [^ \\t]|    [^ \\t]|     [ \\t0]| *\\t[^1-9])\":String::\n\
355 	Keywords:\"<(?iaccept|automatic|backspace|block|call|close|common|continue|data|decode|delete|dimension|do|else|elseif|encode|enddo|end *file|endif|end|entry|equivalence|exit|external|format|function|go *to|if|implicit|include|inquire|intrinsic|logical|map|none|on|open|parameter|pause|pointer|print|program|read|record|return|rewind|save|static|stop|structure|subroutine|system|then|type|union|unlock|virtual|volatile|while|write)>\":::Keyword::D\n\
356 	Data Types:\"<(?ibyte|character|complex|double *complex|double *precision|double|integer|real)(\\*[0-9]+)?>\":::Keyword::D\n\
357 	F90 Keywords:\"<(?iallocatable|allocate|case|case|cycle|deallocate|elsewhere|namelist|recursive|rewrite|select|where|intent|optional)>\":::Keyword::D\n\
358 	Continuation:\"^(     [^ \\t0]|( |  |   |    )?\\t[1-9])\":::Flag::\n\
359 	Continuation in String:\"\\n(     [^ \\t0]|( |  |   |    )?\\t[1-9])\":::Flag:String:}",
360     "Java:3:0{\n\
361 	README:\"Java highlighting patterns for NEdit 5.1. Version 1.5 Author/maintainer: Joachim Lous - jlous at users.sourceforge.net\":::Flag::D\n\
362 	doccomment:\"/\\*\\*\":\"\\*/\"::Text Comment::\n\
363 	doccomment tag:\"@\\l*\":::Text Key1:doccomment:\n\
364 	comment:\"/\\*\":\"\\*/\"::Comment::\n\
365 	cplus comment:\"//\":\"$\"::Comment::\n\
366 	string:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
367 	string escape:\"(?:\\\\u[\\dA-Faf]{4}|\\\\[0-7]{1,3}|\\\\[btnfr'\"\"\\\\])\":::String1:string:\n\
368 	single quoted:\"'\":\"'\":\"\\n\":String::\n\
369 	single quoted escape:\"(?:\\\\u[\\dA-Faf]{4}|\\\\[0-7]{1,3}|\\\\[btnfr'\"\"\\\\])(?=')\":::String1:single quoted:\n\
370 	single quoted char:\".(?=')\":::String:single quoted:\n\
371 	single quoted error:\".\":::Flag:single quoted:\n\
372 	hex const:\"<(?i0[X][\\dA-F]+)>\":::Numeric Const::\n\
373 	long const:\"<(?i[\\d]+L)>\":::Numeric Const::\n\
374 	decimal const:\"(?<!\\Y)(?i\\d+(?:\\.\\d*)?(?:E[+\\-]?\\d+)?[FD]?|\\.\\d+(?:E[+\\-]?\\d+)?[FD]?)(?!\\Y)\":::Numeric Const::\n\
375 	include:\"<(?:import|package)>\":\";\":\"\\n\":Preprocessor::\n\
376 	classdef:\"<(?:class|interface)>\\s*\\n?\\s*([\\l_]\\w*)\":::Keyword::\n\
377 	classdef name:\"\\1\":\"\"::Storage Type:classdef:C\n\
378 	extends:\"<(?:extends)>\":\"(?=(?:<implements>|[{;]))\"::Keyword::\n\
379 	extends argument:\"<[\\l_][\\w\\.]*(?=\\s*(?:/\\*.*\\*/)?(?://.*)?\\n?\\s*(?:[,;{]|<implements>))\":::Storage Type:extends:\n\
380 	extends comma:\",\":::Keyword:extends:\n\
381 	extends comment:\"/\\*\":\"\\*/\"::Comment:extends:\n\
382 	extends cpluscomment:\"//\":\"$\"::Comment:extends:\n\
383 	extends error:\".\":::Flag:extends:\n\
384 	impl_throw:\"<(?:implements|throws)>\":\"(?=[{;])\"::Keyword::\n\
385 	impl_throw argument:\"<[\\l_][\\w\\.]*(?=\\s*(?:/\\*.*\\*/)?(?://.*)?\\n?\\s*[,;{])\":::Storage Type:impl_throw:\n\
386 	impl_throw comma:\",\":::Keyword:impl_throw:\n\
387 	impl_throw comment:\"/\\*\":\"\\*/\"::Comment:impl_throw:\n\
388 	impl_throw cpluscomment:\"//\":\"$\"::Comment:impl_throw:\n\
389 	impl_throw error:\".\":::Flag:impl_throw:\n\
390 	case:\"<case>\":\":\"::Label::\n\
391 	case single quoted:\"'\\\\?[^']'\":::Character Const:case:\n\
392 	case numeric const:\"(?<!\\Y)(?i0[X][\\dA-F]+|\\d+(:?\\.\\d*)?(?:E[+\\-]?\\d+)?F?|\\.\\d+(?:E[+\\-]?\\d+)?F?|\\d+L)(?!\\Y)\":::Numeric Const:case:\n\
393 	case cast:\"\\(\\s*([\\l_][\\w.]*)\\s*\\)\":::Keyword:case:\n\
394 	case cast type:\"\\1\":\"\"::Storage Type:case cast:C\n\
395 	case variable:\"[\\l_][\\w.]*\":::Identifier1:case:\n\
396 	case signs:\"[-+*/<>^&|%()]\":::Keyword:case:\n\
397 	case error:\".\":::Flag:case:\n\
398 	label:\"([;{}:])\":\"[\\l_]\\w*\\s*:\":\"[^\\s\\n]\":Label::\n\
399 	label qualifier:\"\\1\":\"\"::Keyword:label:C\n\
400 	labelref:\"<(?:break|continue)>\\s*\\n?\\s*([\\l_]\\w*)?(?=\\s*\\n?\\s*;)\":::Keyword::\n\
401 	labelref name:\"\\1\":\"\"::Label:labelref:C\n\
402 	instanceof:\"<instanceof>\\s*\\n?\\s*([\\l_][\\w.]*)\":::Keyword::\n\
403 	instanceof class:\"\\1\":\"\"::Storage Type:instanceof:C\n\
404 	newarray:\"new\\s*[\\n\\s]\\s*([\\l_][\\w\\.]*)\\s*\\n?\\s*(?=\\[)\":::Keyword::\n\
405 	newarray type:\"\\1\":\"\"::Storage Type:newarray:C\n\
406 	constructor def:\"<(abstract|final|native|private|protected|public|static|synchronized)\\s*[\\n|\\s]\\s*[\\l_]\\w*\\s*\\n?\\s*(?=\\()\":::Subroutine::\n\
407 	constructor def modifier:\"\\1\":\"\"::Keyword:constructor def:C\n\
408 	keyword - modifiers:\"<(?:abstract|final|native|private|protected|public|static|transient|synchronized|volatile)>\":::Keyword::\n\
409 	keyword - control flow:\"<(?:catch|do|else|finally|for|if|return|switch|throw|try|while)>\":::Keyword::\n\
410 	keyword - calc value:\"<(?:new|super|this)>\":::Keyword::\n\
411 	keyword - literal value:\"<(?:false|null|true)>\":::Numeric Const::\n\
412 	function def:\"<([\\l_][\\w\\.]*)>((?:\\s*\\[\\s*\\])*)\\s*[\\n|\\s]\\s*<[\\l_]\\w*>\\s*\\n?\\s*(?=\\()\":::Plain::\n\
413 	function def type:\"\\1\":\"\"::Storage Type:function def:C\n\
414 	function def type brackets:\"\\2\":\"\"::Keyword:function def:C\n\
415 	function call:\"<[\\l_]\\w*>\\s*\\n?\\s*(?=\\()\":::Plain::\n\
416 	cast:\"[^\\w\\s]\\s*\\n?\\s*\\(\\s*([\\l_][\\w\\.]*)\\s*\\)\":::Keyword::\n\
417 	cast type:\"\\1\":\"\"::Storage Type:cast:C\n\
418 	declaration:\"<[\\l_][\\w\\.]*>((:?\\s*\\[\\s*\\]\\s*)*)(?=\\s*\\n?\\s*(?!instanceof)[\\l_]\\w*)\":::Storage Type::\n\
419 	declaration brackets:\"\\1\":\"\"::Keyword:declaration:C\n\
420 	variable:\"<[\\l_]\\w*>\":::Identifier1::D\n\
421 	braces and parens:\"[(){}[\\]]\":::Keyword::D\n\
422 	signs:\"[-+*/%=,.;:<>!|&^?]\":::Keyword::D\n\
423 	error:\".\":::Flag::D}",
424 #ifndef VMS
425 /* The VAX C compiler cannot compile this definition */
426     "JavaScript:1:0{\n\
427 	DSComment:\"//\":\"$\"::Comment::\n\
428 	MLComment:\"/\\*\":\"\\*/\"::Comment::\n\
429 	DQColors:\"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9]\":::Text Arg1:DQStrings:\n\
430 	SQColors:\"aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|(#)[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-F-af0-9]\":::Text Arg1:SQStrings:\n\
431 	Numeric:\"(?<!\\Y)((0(x|X)[0-9a-fA-F]*)|[0-9.]+((e|E)(\\+|-)?)?[0-9]*)(L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::\n\
432 	Events:\"<(onAbort|onBlur|onClick|onChange|onDblClick|onDragDrop|onError|onFocus|onKeyDown|onKeyPress|onLoad|onMouseDown|onMouseMove|onMouseOut|onMouseOver|onMouseUp|onMove|onResize|onSelect|onSubmit|onUnload)>\":::Keyword::\n\
433 	Braces:\"[{}]\":::Keyword::\n\
434 	Statements:\"<(break|continue|else|for|if|in|new|return|this|typeof|var|while|with)>\":::Keyword::\n\
435 	Function:\"function[\\t ]+([a-zA-Z0-9_]+)[\\t \\(]+\":\"[\\n{]\"::Keyword::\n\
436 	FunctionName:\"\\1\":\"\"::Storage Type:Function:C\n\
437 	FunctionArgs:\"\\(\":\"\\)\"::Text Arg:Function:\n\
438 	Parentheses:\"[\\(\\)]\":::Plain::\n\
439 	BuiltInObjectType:\"<(anchor|Applet|Area|Array|button|checkbox|Date|document|elements|FileUpload|form|frame|Function|hidden|history|Image|link|location|Math|navigator|Option|password|Plugin|radio|reset|select|string|submit|text|textarea|window)>\":::Storage Type::\n\
440 	SQStrings:\"'\":\"'\":\"\\n\":String::\n\
441 	DQStrings:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
442 	EventCapturing:\"captureEvents|releaseEvents|routeEvent|handleEvent\":\"\\)\":\"\\n\":Keyword::\n\
443 	PredefinedMethods:\"<(abs|acos|alert|anchor|asin|atan|atan2|back|big|blink|blur|bold|ceil|charAt|clear|clearTimeout|click|close|confirm|cos|escape|eval|exp|fixed|floor|focus|fontcolor|fontsize|forward|getDate|getDay|getHours|getMinutes|getMonth|getSeconds|getTime|getTimezoneOffset|getYear|go|indexOf|isNaN|italics|javaEnabled|join|lastIndexOf|link|log|max|min|open|parse|parseFloat|parseInt|pow|prompt|random|reload|replace|reset|reverse|round|scroll|select|setDate|setHours|setMinutes|setMonth|setSeconds|setTimeout|setTime|setYear|sin|small|sort|split|sqrt|strike|sub|submit|substring|sup|taint|tan|toGMTString|toLocaleString|toLowerCase|toString|toUpperCase|unescape|untaint|UTC|write|writeln)>\":::Keyword::\n\
444 	Properties:\"<(action|alinkColor|anchors|appCodeName|appName|appVersion|bgColor|border|checked|complete|cookie|defaultChecked|defaultSelected|defaultStatus|defaultValue|description|E|elements|enabledPlugin|encoding|fgColor|filename|forms|frames|hash|height|host|hostname|href|hspace|index|lastModified|length|linkColor|links|LN2|LN10|LOG2E|LOG10E|lowsrc|method|name|opener|options|parent|pathname|PI|port|protocol|prototype|referrer|search|selected|selectedIndex|self|SQRT1_2|SQRT2|src|status|target|text|title|top|type|URL|userAgent|value|vlinkColor|vspace|width|window)>\":::Storage Type::\n\
445 	Operators:\"[= ; ->]|[/]|&|\\|\":::Preprocessor::}",
446 #endif /*VMS*/
447     "LaTeX:1:0{\n\
448 	Comment:\"%\":\"$\"::Text Comment::\n\
449 	Parameter:\"#[0-9]*\":::Text Arg::\n\
450 	Special Chars:\"[{}&]\":::Keyword::\n\
451 	Escape Chars:\"\\\\[$&%#_{}]\":::Text Escape::\n\
452 	Super Sub 1 Char:\"(?:\\^|_)(?:\\\\\\l+|#\\d|[^{\\\\])\":::Text Arg2::\n\
453 	Verbatim Begin End:\"\\\\begin\\{verbatim\\*?}\":\"\\\\end\\{verbatim\\*?}\"::Plain::\n\
454 	Verbatim BG Color:\"&\":\"&\"::Keyword:Verbatim Begin End:C\n\
455 	Verbatim:\"(\\\\verb\\*?)([^\\l\\s\\*]).*?(\\2)\":::Plain::\n\
456 	Verbatim Color:\"\\1\\2\\3\":\"\"::Keyword:Verbatim:C\n\
457 	Inline Math:\"(?<!#\\d)(?:\\$|\\\\\\()\":\"\\$|\\\\\\)\":\"\\\\\\(|(?n[^\\\\]%)\":LaTeX Math::\n\
458 	Math Color:\"&\":\"&\"::Keyword:Inline Math:C\n\
459 	Math Escape Chars:\"\\\\\\$\":::Text Escape:Inline Math:\n\
460 	No Arg Command:\"\\\\(?:left|right)[\\[\\]{}()]\":::Text Key::\n\
461 	Command:\"[_^]|[\\\\@](?:a'|a`|a=|[A-Za-z]+\\*?|\\\\\\*|[-@_='`^\"\"|\\[\\]*:!+<>/~.,\\\\ ])\":\"nevermatch\":\"[^{[(]\":Text Key::\n\
462 	Cmd Brace Args:\"\\{\":\"}\":\"(?<=^%)|\\\\]|\\$\\$|\\\\end\\{equation\\}\":Text Arg2:Command:\n\
463 	Brace Color:\"&\":\"&\"::Text Arg:Cmd Brace Args:C\n\
464 	Cmd Paren Args:\"\\(\":\"\\)\":\"$\":Text Arg2:Command:\n\
465 	Paren Color:\"&\":\"&\"::Text Arg:Cmd Paren Args:C\n\
466 	Cmd Bracket Args:\"\\[\":\"\\]\":\"$|\\\\\\]\":Text Arg2:Command:\n\
467 	Bracket Color:\"&\":\"&\"::Text Arg:Cmd Bracket Args:C\n\
468 	Sub Cmd Bracket Args Esc:\"\\\\\\}\":::Plain:Sub Cmd Bracket Args:\n\
469 	Sub Cmd Bracket Args:\"\\{\":\"\\}\":\"$|\\\\\\]\":Preprocessor1:Cmd Bracket Args:\n\
470 	Sub Command:\"(?:[_^]|(?:[\\\\@](?:[A-Za-z]+\\*?|[^A-Za-z$&%#{}~\\\\ \\t])))\":::Text Key1:Cmd Brace Args:\n\
471 	Sub Brace:\"\\{\":\"}\"::Text Arg2:Cmd Brace Args:\n\
472 	Sub Sub Brace:\"\\{\":\"}\"::Text Arg2:Sub Brace:\n\
473 	Sub Sub Sub Brace:\"\\{\":\"}\"::Text Arg2:Sub Sub Brace:\n\
474 	Sub Sub Sub Sub Brace:\"\\{\":\"}\"::Text Arg2:Sub Sub Sub Brace:\n\
475 	Sub Paren:\"\\(\":\"\\)\":\"$\":Text Arg2:Cmd Paren Args:\n\
476 	Sub Sub Paren:\"\\(\":\"\\)\":\"$\":Text Arg2:Sub Paren:\n\
477 	Sub Sub Sub Paren:\"\\(\":\"\\)\":\"$\":Text Arg2:Sub Sub Paren:\n\
478 	Sub Parameter:\"#[0-9]*\":::Text Arg:Cmd Brace Args:\n\
479 	Sub Spec Chars:\"[{}$&]\":::Text Arg:Cmd Brace Args:\n\
480 	Sub Esc Chars:\"\\\\[$&%#_{}~^\\\\]\":::Text Arg1:Cmd Brace Args:}",
481     "Lex:1:0{\n\
482 	comment:\"/\\*\":\"\\*/\"::Comment::\n\
483 	string:\"L?\"\"\":\"\"\"\":\"\\n\":String::\n\
484 	meta string:\"\\\\\"\".*\\\\\"\"\":::String::\n\
485 	preprocessor line:\"^\\s*#\\s*(include|define|if|ifn?def|line|error|else|endif|elif|undef|pragma)>\":\"$\"::Preprocessor::\n\
486 	string escape chars:\"\\\\(.|\\n)\":::String1:string:\n\
487 	preprocessor esc chars:\"\\\\(.|\\n)\":::Preprocessor1:preprocessor line:\n\
488 	preprocessor comment:\"/\\*\":\"\\*/\"::Comment:preprocessor line:\n\
489     	preprocessor string:\"L?\"\"\":\"\"\"\":\"\\n\":Preprocessor1:preprocessor line:\n\
490     	prepr string esc chars:\"\\\\(?:.|\\n)\":::String1:preprocessor string:\n\
491 	character constant:\"'\":\"'\":\"[^\\\\][^']\":Character Const::\n\
492 	numeric constant:\"(?<!\\Y)((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::D\n\
493 	storage keyword:\"<(const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)>\":::Storage Type::D\n\
494 	keyword:\"<(return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)>\":::Keyword::D\n\
495 	lex keyword:\"<(yylval|yytext|input|unput|output|lex_input|lex_output|yylex|yymore|yyless|yyin|yyout|yyleng|yywtext|yywleng|yyterminate|REJECT|ECHO|BEGIN|YY_NEW_FILE|yy_create_buffer|yy_switch_to_buffer|yy_delete_buffer|YY_CURRENT_BUFFER|YY_BUFFER_STATE|YY_DECL|YY_INPUT|yywrap|YY_USER_ACTION|YY_USER_INIT|YY_BREAK)>\":::Text Arg::D\n\
496 	stdlib:\"<(BUFSIZ|CHAR_BIT|CHAR_MAX|CHAR_MIN|CLOCKS_PER_SEC|DBL_DIG|DBL_EPSILON|DBL_MANT_DIG|DBL_MAX|DBL_MAX_10_EXP|DBL_MAX_EXP|DBL_MIN|DBL_MIN_10_EXP|DBL_MIN_EXP|EDOM|EOF|ERANGE|EXIT_FAILURE|EXIT_SUCCESS|FILE|FILENAME_MAX|FLT_DIG|FLT_EPSILON|FLT_MANT_DIG|FLT_MAX|FLT_MAX_10_EXP|FLT_MAX_EXP|FLT_MIN|FLT_MIN_10_EXP|FLT_MIN_EXP|FLT_RADIX|FLT_ROUNDS|FOPEN_MAX|HUGE_VAL|INT_MAX|INT_MIN|LC_ALL|LC_COLLATE|LC_CTYPE|LC_MONETARY|LC_NUMERIC|LC_TIME|LDBL_DIG|LDBL_EPSILON|LDBL_MANT_DIG|LDBL_MAX|LDBL_MAX_10_EXP|LDBL_MAX_EXP|LDBL_MIN|LDBL_MIN_10_EXP|LDBL_MIN_EXP|LONG_MAX|LONG_MIN|L_tmpnam|MB_CUR_MAX|MB_LEN_MAX|NULL|RAND_MAX|SCHAR_MAX|SCHAR_MIN|SEEK_CUR|SEEK_END|SEEK_SET|SHRT_MAX|SHRT_MIN|SIGABRT|SIGFPE|SIGILL|SIGINT|SIGSEGV|SIGTERM|SIG_DFL|SIG_ERR|SIG_IGN|TMP_MAX|UCHAR_MAX|UINT_MAX|ULONG_MAX|USHRT_MAX|WCHAR_MAX|WCHAR_MIN|WEOF|_IOFBF|_IOLBF|_IONBF|abort|abs|acos|asctime|asin|assert|atan|atan2|atexit|atof|atoi|atol|bsearch|btowc|calloc|ceil|clearerr|clock|clock_t|cos|cosh|ctime|difftime|div|div_t|errno|exit|exp|fabs|fclose|feof|ferror|fflush|fgetc|fgetpos|fgets|fgetwc|fgetws|floor|fmod|fopen|fpos_t|fprintf|fputc|fputs|fputwc|fputws|fread|free|freopen|frexp|fscanf|fseek|fsetpos|ftell|fwide|fwprintf|fwrite|fwscanf|getc|getchar|getenv|gets|getwc|getwchar|gmtime|isalnum|isalpha|iscntrl|isdigit|isgraph|islower|isprint|ispunct|isspace|isupper|iswalnum|iswalpha|iswcntrl|iswctype|iswdigit|iswgraph|iswlower|iswprint|iswpunct|iswspace|iswupper|iswxdigit|isxdigit|jmp_buf|labs|lconv|ldexp|ldiv|ldiv_t|localeconv|localtime|log|log10|longjmp|malloc|mblen|mbrlen|mbrtowc|mbsinit|mbsrtowcs|mbstate_t|mbstowcs|mbtowc|memchr|memcmp|memcpy|memmove|memset|mktime|modf|offsetof|perror|pow|printf|ptrdiff_t|putc|puts|putwc|putwchar|qsort|raise|rand|realloc|remove|rename|rewind|scanf|setbuf|setjmp|setlocale|setvbuf|sig_atomic_t|signal|sin|sinh|size_t|sprintf|sqrt|srand|sscanf|stderr|stdin|stdout|strcat|strchr|strcmp|strcoll|strcpy|strcspn|strerror|strftime|strlen|strncat|strncmp|strncpy|stroul|strpbrk|strrchr|strspn|strstr|strtod|strtok|strtol|strxfrm|swprintf|swscanf|system|tan|tanh|time|time_t|tm|tmpfile|tmpnam|tolower|toupper|towctrans|towlower|towupper|ungetc|ungetwc|va_arg|va_end|va_list|va_start|vfwprintf|vprintf|vsprintf|vswprintf|vwprintf|wint_t|wmemchr|wmemcmp|wmemcpy|wmemmove|wmemset|wprintf|wscanf)>\":::Subroutine::D\n\
497 	label:\"<goto>|(^[ \\t]*[A-Za-z_][A-Za-z0-9_]*[ \\t]*:)\":::Flag::D\n\
498 	braces:\"[{}]\":::Keyword::D\n\
499 	markers:\"(?<!\\Y)(%\\{|%\\}|%%)(?!\\Y)\":::Flag::D}",
500     "Makefile:8:0{\n\
501 	Comment:\"#\":\"$\"::Comment::\n\
502 	Comment Continuation:\"\\\\\\n\":::Keyword:Comment:\n\
503 	Assignment:\"^( *| [ \\t]*)[A-Za-z0-9_+][^ \\t]*[ \\t]*(\\+|:)?=\":\"$\"::Preprocessor::\n\
504 	Assignment Continuation:\"\\\\\\n\":::Keyword:Assignment:\n\
505 	Assignment Comment:\"#\":\"$\"::Comment:Assignment:\n\
506 	Dependency Line:\"^( *| [ \\t]*)(.DEFAULT|.DELETE_ON_ERROR|.EXPORT_ALL_VARIABLES.IGNORE|.INTERMEDIATE|.PHONY|.POSIX|.PRECIOUS|.SECONDARY|.SILENT|.SUFFIXES)*(([A-Za-z0-9./$(){} _@^<*?%+-]*(\\\\\\n)){,8}[A-Za-z0-9./$(){} _@^<*?%+-]*)::?\":\"$|;\"::Text Key1::\n\
507 	Dep Target Special:\"\\2\":\"\"::Text Key1:Dependency Line:C\n\
508 	Dep Target:\"\\3\":\"\"::Text Key:Dependency Line:C\n\
509 	Dep Continuation:\"\\\\\\n\":::Keyword:Dependency Line:\n\
510 	Dep Comment:\"#\":\"$\"::Comment:Dependency Line:\n\
511 	Dep Internal Macro:\"\\$([<@*?%]|\\$@)\":::Preprocessor1:Dependency Line:\n\
512 	Dep Macro:\"\\$([A-Za-z0-9_]|\\([^)]*\\)|\\{[^}]*})\":::Preprocessor:Dependency Line:\n\
513 	Continuation:\"\\\\$\":::Keyword::\n\
514 	Macro:\"\\$([A-Za-z0-9_]|\\([^)]*\\)|\\{[^}]*})\":::Preprocessor::\n\
515 	Internal Macro:\"\\$([<@*?%]|\\$@)\":::Preprocessor1::\n\
516 	Escaped Dollar:\"\\$\\$\":::Comment::\n\
517 	Include:\"^( *| [ \\t]*)include[ \\t]\":::Keyword::\n\
518 	Exports:\"^( *| [ \\t]*)<export|unexport>[ \\t]\":\"$\"::Keyword::\n\
519 	Exports var:\".[A-Za-z0-9_+]*\":\"$\"::Keyword:Exports:\n\
520 	Conditionals:\"^( *| [ \\t]*)<ifeq|ifneq>[ \\t]\":::Keyword::D\n\
521 	Conditionals ifdefs:\"^( *| [ \\t]*)<ifdef|ifndef>[ \\t]\":\"$\"::Keyword::D\n\
522 	Conditionals ifdefs var:\".[A-Za-z0-9_+]*\":\"$\"::Preprocessor:Conditionals ifdefs:D\n\
523 	Conditional Ends:\"^( *| [ \\t]*)<else|endif>\":::Keyword::D\n\
524 	vpath:\"^( *| [ \\t]*)<vpath>[ \\t]\":::Keyword::D\n\
525 	define:\"^( *| [ \\t]*)<define>[ \\t]\":\"$\"::Keyword::D\n\
526 	define var:\".[A-Za-z0-9_+]*\":\"$\"::Preprocessor:define:D\n\
527 	define Ends:\"^( *| [ \\t]*)<endef>\":::Keyword::D}",
528     "Matlab:1:0{\n\
529 	Comment:\"%\":\"$\"::Comment::\n\
530 	Comment in Octave:\"#\":\"$\"::Comment::\n\
531 	Keyword:\"<(break|clear|else|elseif|for|function|global|if|return|then|while|end(if|for|while|function))>\":::Keyword::\n\
532 	Transpose:\"[\\w.]('+)\":::Plain::\n\
533 	Paren transposed:\"\\)('+)\":::Keyword::\n\
534 	Paren transp close:\"\\1\":\"\"::Plain:Paren transposed:C\n\
535 	Parentheses:\"[\\(\\)]\":::Keyword::\n\
536 	Brackets transposed:\"\\]('+)\":::Text Key1::\n\
537 	Brack transp close:\"\\1\":\"\"::Plain:Brackets transposed:C\n\
538 	Brackets:\"[\\[\\]]\":::Text Key1::\n\
539 	Braces transposed:\"\\}('+)\":::Text Arg::\n\
540 	Braces transp close:\"\\1\":\"\"::Plain:Braces transposed:C\n\
541 	Braces:\"[\\{\\}]\":::Text Arg::\n\
542 	String:\"'\":\"'\"::String::\n\
543 	Numeric const:\"(?<!\\Y)(((\\d+\\.?\\d*)|(\\.\\d+))([eE][+\\-]?\\d+)?)(?!\\Y)\":::Numeric Const::\n\
544 	Three periods to end:\"(\\.\\.\\.)\":\"$\"::Comment::\n\
545 	Three periods:\"\\1\":\"\"::Keyword:Three periods to end:C\n\
546 	Shell command:\"!\":\"$\"::String1::\n\
547 	Comment in shell cmd:\"%\":\"$\"::Comment:Shell command:\n\
548 	Relational operators:\"==|~=|\\<=|\\>=|\\<|\\>\":::Text Arg1::\n\
549 	Wrong logical ops:\"&&|\\|\\|\":::Plain::\n\
550 	Logical operators:\"~|&|\\|\":::Text Arg2::}",
551     "NEdit Macro:2:0{\n\
552         README:\"NEdit Macro syntax highlighting patterns, version 2.6, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
553         Comment:\"#\":\"$\"::Comment::\n\
554         Built-in Misc Vars:\"(?<!\\Y)\\$(?:active_pane|args|calltip_ID|column|cursor|display_width|empty_array|file_name|file_path|language_mode|line|locked|max_font_width|min_font_width|modified|n_display_lines|n_panes|rangeset_list|read_only|selection_(?:start|end|left|right)|server_name|text_length|top_line)>\":::Identifier::\n\
555         Built-in Pref Vars:\"(?<!\\Y)\\$(?:auto_indent|em_tab_dist|file_format|font_name|font_name_bold|font_name_bold_italic|font_name_italic|highlight_syntax|incremental_backup|incremental_search_line|make_backup_copy|match_syntax_based|overtype_mode|show_line_numbers|show_matching|statistics_line|tab_dist|use_tabs|wrap_margin|wrap_text)>\":::Identifier2::\n\
556         Built-in Special Vars:\"(?<!\\Y)\\$(?:[1-9]|list_dialog_button|n_args|read_status|search_end|shell_cmd_status|string_dialog_button|sub_sep)>\":::String1::\n\
557         Built-in Subrs:\"<(?:append_file|beep|calltip|clipboard_to_string|dialog|focus_window|get_character|get_pattern_(by_name|at_pos)|get_range|get_selection|get_style_(by_name|at_pos)|getenv|kill_calltip|length|list_dialog|max|min|rangeset_(?:add|create|destroy|get_by_name|includes|info|invert|range|set_color|set_mode|set_name|subtract)|read_file|replace_in_string|replace_range|replace_selection|replace_substring|search|search_string|select|select_rectangle|set_cursor_pos|set_language_mode|set_locked|shell_command|split|string_compare|string_dialog|string_to_clipboard|substring|t_print|tolower|toupper|valid_number|write_file)>\":::Subroutine::\n\
558         Menu Actions:\"<(?:new|open|open-dialog|open_dialog|open-selected|open_selected|close|save|save-as|save_as|save-as-dialog|save_as_dialog|revert-to-saved|revert_to_saved|revert_to_saved_dialog|include-file|include_file|include-file-dialog|include_file_dialog|load-macro-file|load_macro_file|load-macro-file-dialog|load_macro_file_dialog|load-tags-file|load_tags_file|load-tags-file-dialog|load_tags_file_dialog|unload_tags_file|load_tips_file|load_tips_file_dialog|unload_tips_file|print|print-selection|print_selection|exit|undo|redo|delete|select-all|select_all|shift-left|shift_left|shift-left-by-tab|shift_left_by_tab|shift-right|shift_right|shift-right-by-tab|shift_right_by_tab|find|find-dialog|find_dialog|find-again|find_again|find-selection|find_selection|find_incremental|start_incremental_find|replace|replace-dialog|replace_dialog|replace-all|replace_all|replace-in-selection|replace_in_selection|replace-again|replace_again|replace_find|replace_find_same|replace_find_again|goto-line-number|goto_line_number|goto-line-number-dialog|goto_line_number_dialog|goto-selected|goto_selected|mark|mark-dialog|mark_dialog|goto-mark|goto_mark|goto-mark-dialog|goto_mark_dialog|match|select_to_matching|goto_matching|find-definition|find_definition|show_tip|split-window|split_window|close-pane|close_pane|uppercase|lowercase|fill-paragraph|fill_paragraph|control-code-dialog|control_code_dialog|filter-selection-dialog|filter_selection_dialog|filter-selection|filter_selection|execute-command|execute_command|execute-command-dialog|execute_command_dialog|execute-command-line|execute_command_line|shell-menu-command|shell_menu_command|macro-menu-command|macro_menu_command|bg_menu_command|post_window_bg_menu|beginning-of-selection|beginning_of_selection|end-of-selection|end_of_selection|repeat_macro|repeat_dialog|raise_window|focus_pane|set_statistics_line|set_incremental_search_line|set_show_line_numbers|set_auto_indent|set_wrap_text|set_wrap_margin|set_highlight_syntax|set_make_backup_copy|set_incremental_backup|set_show_matching|set_match_syntax_based|set_overtype_mode|set_locked|set_tab_dist|set_em_tab_dist|set_use_tabs|set_fonts|set_language_mode)(?=\\s*\\()\":::Subroutine::\n\
559         Text Actions:\"<(?:self-insert|self_insert|grab-focus|grab_focus|extend-adjust|extend_adjust|extend-start|extend_start|extend-end|extend_end|secondary-adjust|secondary_adjust|secondary-or-drag-adjust|secondary_or_drag_adjust|secondary-start|secondary_start|secondary-or-drag-start|secondary_or_drag_start|process-bdrag|process_bdrag|move-destination|move_destination|move-to|move_to|move-to-or-end-drag|move_to_or_end_drag|end_drag|copy-to|copy_to|copy-to-or-end-drag|copy_to_or_end_drag|exchange|process-cancel|process_cancel|paste-clipboard|paste_clipboard|copy-clipboard|copy_clipboard|cut-clipboard|cut_clipboard|copy-primary|copy_primary|cut-primary|cut_primary|newline|newline-and-indent|newline_and_indent|newline-no-indent|newline_no_indent|delete-selection|delete_selection|delete-previous-character|delete_previous_character|delete-next-character|delete_next_character|delete-previous-word|delete_previous_word|delete-next-word|delete_next_word|delete-to-start-of-line|delete_to_start_of_line|delete-to-end-of-line|delete_to_end_of_line|forward-character|forward_character|backward-character|backward_character|key-select|key_select|process-up|process_up|process-down|process_down|process-shift-up|process_shift_up|process-shift-down|process_shift_down|process-home|process_home|forward-word|forward_word|backward-word|backward_word|forward-paragraph|forward_paragraph|backward-paragraph|backward_paragraph|beginning-of-line|beginning_of_line|end-of-line|end_of_line|beginning-of-file|beginning_of_file|end-of-file|end_of_file|next-page|next_page|previous-page|previous_page|page-left|page_left|page-right|page_right|toggle-overstrike|toggle_overstrike|scroll-up|scroll_up|scroll-down|scroll_down|scroll_left|scroll_right|scroll-to-line|scroll_to_line|select-all|select_all|deselect-all|deselect_all|focusIn|focusOut|process-return|process_return|process-tab|process_tab|insert-string|insert_string|mouse_pan)>\":::Subroutine::\n\
560         Keyword:\"<(?:break|continue|define|delete|else|for|if|in|return|while)>\":::Keyword::\n\
561         Braces:\"[{}\\[\\]]\":::Keyword::\n\
562         Global Variable:\"\\$[A-Za-z0-9_]+\":::Identifier1::\n\
563         String:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
564         String Escape Char:\"\\\\(?:.|\\n)\":::Text Escape:String:\n\
565         Numeric Const:\"(?<!\\Y)-?[0-9]+>\":::Numeric Const::\n\
566         Macro Definition:\"(?<=define)\\s+\\w+\":::Subroutine1::\n\
567         Custom Macro:\"\\w+(?=\\s*(?:\\\\\\n)?\\s*[\\(])\":::Subroutine1::\n\
568         Variables:\"\\w+\":::Identifier1::D}",
569     "Pascal:1:0{\n\
570 	TP Directives:\"\\{\\$\":\"\\}\"::Comment::\n\
571 	Comment:\"\\(\\*|\\{\":\"\\*\\)|\\}\"::Comment::\n\
572 	String:\"'\":\"'\":\"\\n\":String::D\n\
573 	Array delimitors:\"\\(\\.|\\.\\)|\\[|\\]\":::Character Const::D\n\
574 	Parentheses:\"\\(|\\)\":::Keyword::D\n\
575 	X Numeric Values:\"<([2-9]|[12]\\d|3[0-6])#[\\d\\l]+>\":::Text Key::D\n\
576 	TP Numeric Values:\"(?<!\\Y)(#\\d+|\\$[\\da-fA-F]+)>\":::Text Key1::D\n\
577 	Numeric Values:\"<\\d+(\\.\\d+)?((e|E)(\\+|-)?\\d+)?>\":::Numeric Const::D\n\
578 	Reserved Words 1:\"<(?iBegin|Const|End|Program|Record|Type|Var)>\":::Keyword::D\n\
579 	Reserved Words 2:\"<(?iForward|Goto|Label|Of|Packed|With)>\":::Identifier::D\n\
580 	X Reserved Words:\"<(?iBindable|Export|Implementation|Import|Interface|Module|Only|Otherwise|Protected|Qualified|Restricted|Value)>\":::Identifier1::D\n\
581 	TP Reserved Words:\"<(?iAbsolute|Assembler|Exit|External|Far|Inline|Interrupt|Near|Private|Unit|Uses)>\":::Text Comment::D\n\
582 	Data Types:\"<(?iArray|Boolean|Char|File|Integer|Real|Set|Text)>\":::Storage Type::D\n\
583 	X Data Types:\"<(?iBindingType|Complex|String|TimeStamp)>\":::Text Arg1::D\n\
584 	TP Data Types:\"<(?iByte|Comp|Double|Extended|LongInt|ShortInt|Single|Word)>\":::Text Arg2::D\n\
585 	Predefined Consts:\"<(?iFalse|Input|MaxInt|Nil|Output|True)>\":::String1::D\n\
586 	X Predefined Consts:\"<(?iEpsReal|MaxChar|MaxReal|MinReal|StandardInput|StandardOutput)>\":::String2::D\n\
587 	Conditionals:\"<(?iCase|Do|DownTo|Else|For|If|Repeat|Then|To|Until|While)>\":::Ada Attributes::D\n\
588 	Proc declaration:\"<(?iProcedure)>\":::Character Const::D\n\
589 	Predefined Proc:\"<(?iDispose|Get|New|Pack|Page|Put|Read|ReadLn|Reset|Rewrite|Unpack|Write|WriteLn)>\":::Subroutine::D\n\
590 	X Predefined Proc:\"<(?iBind|Extend|GetTimeStamp|Halt|ReadStr|SeekRead|SeekUpdate|SeekWrite|Unbind|Update|WriteStr)>\":::Subroutine1::D\n\
591 	Func declaration:\"<(?iFunction)>\":::Identifier::D\n\
592 	Predefined Func:\"<(?iAbs|Arctan|Chr|Cos|Eof|Eoln|Exp|Ln|Odd|Ord|Pred|Round|Sin|Sqr|Sqrt|Succ|Trunc)>\":::Preprocessor::D\n\
593 	X Predefined Func:\"<(?iArg|Binding|Card|Cmplx|Date|Empty|Eq|Ge|Gt|Im|Index|LastPosition|Le|Length|Lt|Ne|Polar|Position|Re|SubStr|Time|Trim)>\":::Preprocessor1::D\n\
594 	X Operators:\"(\\>\\<|\\*\\*)|<(?iAnd_Then|Or_Else|Pow)>\":::Text Arg1::D\n\
595 	Assignment:\":=\":::Plain::D\n\
596 	Operators:\"(\\<|\\>|=|\\^|@)|<(?iAnd|Div|In|Mod|Not|Or)>\":::Text Arg::D\n\
597 	TP Operators:\"<(?iShl|Shr|Xor)>\":::Text Arg2::D}",
598     "Perl:2:0{\n\
599 	dq here doc:\"(\\<\\<(\"\"?))EOF(\\2.*)$\":\"^EOF>\"::Label::\n\
600 	dq here doc delims:\"\\1\\3\":::Keyword:dq here doc:C\n\
601 	dq here doc esc chars:\"\\\\([nrtfbaeulULQE@%\\$\\\\]|0[0-7]+|x[0-9a-fA-F]+|c\\l)\":::Text Escape:dq here doc:\n\
602 	dq here doc variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:dq here doc:\n\
603 	dq here doc content:\".\":::String:dq here doc:\n\
604 	dq string:\"(?<!\\Y)\"\"\":\"\"\"\":\"\\n\\s*\\n\":String::\n\
605 	dq string delims:\"&\":\"&\"::Keyword:dq string:C\n\
606 	dq string esc chars:\"\\\\([nrtfbaeulULQE\"\"@%\\$\\\\]|0[0-7]+|x[0-9a-fA-F]+|c\\l)\":::Text Escape:dq string:\n\
607 	dq string variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:dq string:\n\
608 	gen dq string:\"<qq/\":\"(?!\\\\)/\":\"\\n\\s*\\n\":String::\n\
609 	gen dq string delims:\"&\":\"&\"::Keyword:gen dq string:C\n\
610 	gen dq string esc chars:\"\\\\([nrtfbaeulULQE@%\\$\\\\]|0[0-7]+|x[0-9a-fA-F]+|c\\l)\":::Text Escape:gen dq string:\n\
611 	gen dq string variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:gen dq string:\n\
612 	sq here doc:\"(\\<\\<')EOF('.*)$\":\"^EOF>\"::Label::\n\
613 	sq here doc delims:\"\\1\\2\":::Keyword:sq here doc:C\n\
614 	sq here doc esc chars:\"\\\\\\\\\":::Text Escape:sq here doc:\n\
615 	sq here doc content:\".\":::String1:sq here doc:\n\
616 	sq string:\"(?<!\\Y)'\":\"'\":\"\\n\\s*\\n\":String1::\n\
617 	sq string delims:\"&\":\"&\"::Keyword:sq string:C\n\
618 	sq string esc chars:\"\\\\(\\\\|')\":::Text Escape:sq string:\n\
619 	gen sq string:\"<q/\":\"(?!\\\\)/\":\"\\n\\s*\\n\":String1::\n\
620 	gen sq string delims:\"&\":\"&\"::Keyword:gen sq string:C\n\
621 	gen sq string esc chars:\"\\\\(\\\\|/)\":::Text Escape:gen sq string:\n\
622 	implicit sq:\"[-\\w]+(?=\\s*=\\>)|(\\{)[-\\w]+(\\})\":::String1::\n\
623 	implicit sq delims:\"\\1\\2\":::Keyword:implicit sq:C\n\
624 	word list:\"<qw\\(\":\"\\)\":\"\\n\\s*\\n\":Keyword::\n\
625 	word list content:\".\":::String1:word list:\n\
626 	bq here doc:\"(\\<\\<`)EOF(`.*)$\":\"^EOF>\"::Label::\n\
627 	bq here doc delims:\"\\1\\2\":::Keyword:bq here doc:C\n\
628 	bq here doc comment:\"#\":\"$\"::Comment:bq here doc:\n\
629 	bq here doc variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:bq here doc:\n\
630 	bq here doc content:\".\":::String1:bq here doc:\n\
631 	bq string:\"(?<!\\Y)`\":\"`(?!\\Y)\":\"\\n\\s*\\n\":String1::\n\
632 	bq string delims:\"&\":\"&\"::Keyword:bq string:C\n\
633 	bq string variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:bq string:\n\
634 	gen bq string:\"<qx/\":\"(?!\\\\)/\":\"\\n\\s*\\n\":String1::\n\
635 	gen bq string delims:\"&\":\"&\"::Keyword:gen bq string:C\n\
636 	gen bq string variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:gen bq string:\n\
637 	gen bq string esc chars:\"\\\\/\":::Text Escape:gen bq string:\n\
638 	transliteration:\"<((y|tr)/)(\\\\/|[^/])+(/)(\\\\/|[^/])*(/[cds]*)\":::String::D\n\
639 	transliteration delims:\"\\1\\4\\6\":::Keyword:transliteration:DC\n\
640 	last array index:\"\\$#([\\l_](\\w|::(?=\\w))*)?\":::Identifier1::\n\
641 	comment:\"#\":\"$\"::Comment::\n\
642 	label:\"((?:^|;)\\s*<([A-Z_]+)>\\s*:(?=(?:[^:]|\\n)))|(goto|last|next|redo)\\s+(<((if|unless)|[A-Z_]+)>|)\":::Plain::\n\
643 	label identifier:\"\\2\\5\":::Label:label:C\n\
644 	label keyword:\"\\3\\6\":::Keyword:label:C\n\
645 	handle:\"(\\<)[A-Z_]+(\\>)|(bind|binmode|close(?:dir)?|connect|eof|fcntl|fileno|flock|getc|getpeername|getsockname|getsockopt|ioctl|listen|open(?:dir)?|recv|read(?:dir)?|rewinddir|seek(?:dir)?|send|setsockopt|shutdown|socket|sysopen|sysread|sysseek|syswrite|tell(?:dir)?|write)>\\s*(\\(?)\\s*[A-Z_]+>|<(accept|pipe|socketpair)>\\s*(\\(?)\\s*[A-Z_]+\\s*(,)\\s*[A-Z_]+>|(print|printf|select)>\\s*(\\(?)\\s*[A-Z_]+>(?!\\s*,)\":::Storage Type::\n\
646 	handle delims:\"\\1\\2\\4\\6\\7\\9\":::Keyword:handle:C\n\
647 	handle functions:\"\\3\\5\\8\":::Subroutine:handle:C\n\
648 	statements:\"<(if|until|while|elsif|else|unless|for(each)?|continue|last|goto|next|redo|do(?=\\s*\\{)|BEGIN|END)>\":::Keyword::D\n\
649 	packages and modules:\"<(bless|caller|import|no|package|prototype|require|return|INIT|CHECK|BEGIN|END|use|new)>\":::Keyword::D\n\
650 	pragm modules:\"<(attrs|autouse|base|blib|constant|diagnostics|fields|integer|less|lib|locale|ops|overload|re|sigtrap|strict|subs|vars|vmsish)>\":::Keyword::D\n\
651 	standard methods:\"<(can|isa|VERSION)>\":::Keyword::D\n\
652 	file tests:\"-[rwxRWXoOezsfdlSpbcugktTBMAC]>\":::Subroutine::D\n\
653 	subr header:\"<sub\\s+<([\\l_]\\w*)>\":\"(?:\\{|;)\"::Keyword::D\n\
654 	subr header coloring:\"\\1\":::Plain:subr header:DC\n\
655 	subr prototype:\"\\(\":\"\\)\"::Flag:subr header:D\n\
656 	subr prototype delims:\"&\":\"&\"::Keyword:subr prototype:DC\n\
657 	subr prototype chars:\"\\\\?[@$%&*]|;\":::Identifier1:subr prototype:D\n\
658 	references:\"\\\\(\\$|@|%|&)(::)?[\\l_](\\w|::(?=\\w))*|\\\\(\\$?|@|%|&)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|\\\\(\\$|@|%|&)(?=\\{)\":::Identifier1::\n\
659 	variables:\"\\$([-_./,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1::\n\
660 	named operators:\"<(lt|gt|le|ge|eq|ne|cmp|not|and|or|xor|sub|x)>\":::Keyword::D\n\
661 	library functions:\"<((?# arithmetic functions)abs|atan2|cos|exp|int|log|rand|sin|sqrt|srand|time|(?# conversion functions)chr|gmtime|hex|localtime|oct|ord|vec|(?# structure conversion)pack|unpack|(?# string functions)chomp|chop|crypt|eval(?=\\s*[^{])|index|lc|lcfirst|length|quotemeta|rindex|substr|uc|ucfirst|(?# array and hash functions)delete|each|exists|grep|join|keys|map|pop|push|reverse|scalar|shift|sort|splice|split|unshift|values|(?# search and replace functions)pos|study|(?# file operations)chmod|chown|link|lstat|mkdir|readlink|rename|rmdir|stat|symlink|truncate|unlink|utime|(?# input/output)binmode|close|eof|fcntl|fileno|flock|getc|ioctl|open|pipe|print|printf|read|readline|readpipe|seek|select|sprintf|sysopen|sysread|sysseek|syswrite|tell|(?# formats)formline|write|(?# tying variables)tie|tied|untie|(?# directory reading routines)closedir|opendir|readdir|rewinddir|seekdir|telldir|(?# system interaction)alarm|chdir|chroot|die|exec|exit|fork|getlogin|getpgrp|getppid|getpriority|glob|kill|setpgrp|setpriority|sleep|syscall|system|times|umask|wait|waitpid|warn|(?# networking)accept|bind|connect|getpeername|getsockname|getsockopt|listen|recv|send|setsockopt|shutdown|socket|socketpair|(?# system V ipc)msgctl|msgget|msgrcv|msgsnd|semctl|semget|semop|shmctl|shmget|shmread|shmwrite|(?# miscellaneous)defined|do|dump|eval(?=\\s*\\{)|local|my|ref|reset|undef|(?# informations from system databases)endpwent|getpwent|getpwnam|getpwuid|setpwent|endgrent|getgrent|getgrgid|getgrnam|setgrent|endnetent|getnetbyaddr|getnetbyname|getnetent|setnetent|endhostend|gethostbyaddr|gethostbyname|gethostent|sethostent|endservent|getservbyname|getservbyport|getservent|setservent|endprotoent|getprotobyname|getprotobynumber|getprotoent|setprotoent)>\":::Subroutine::\n\
662 	subroutine call:\"(&|-\\>)\\w(\\w|::)*(?!\\Y)|<\\w(\\w|::)*(?=\\s*\\()\":::Subroutine1::D\n\
663 	symbolic operators:\">[-<>+.*/\\\\?!~=%^&:]<\":::Keyword::D\n\
664 	braces and parens:\"[\\[\\]{}\\(\\)\\<\\>]\":::Keyword::D\n\
665 	numerics:\"(?<!\\Y)((?i0x[\\da-f]+)|0[0-7]+|(\\d+\\.?\\d*|\\.\\d+)([eE][\\-+]?\\d+)?|[\\d_]+)(?!\\Y)\":::Numeric Const::D\n\
666 	tokens:\"__(FILE|PACKAGE|LINE|DIE|WARN)__\":::Preprocessor::D\n\
667 	end token:\"^__(END|DATA)__\":\"never_match_this_pattern\"::Plain::\n\
668 	end token delim:\"&\":::Preprocessor:end token:C\n\
669 	pod:\"(?=^=)\":\"^=cut\"::Text Comment::\n\
670 	re match:\"(?<!\\Y)((m|qr|~\\s*)/)\":\"(/(gc?|[imosx])*)\"::Plain::\n\
671 	re match delims:\"&\":\"&\"::Keyword:re match:C\n\
672 	re match esc chars:\"\\\\([/abdeflnrstuwzABDEGLQSUWZ+?.*$^(){}[\\]|\\\\]|0[0-7]{2}|x[0-9a-fA-F]{2})\":::Text Escape:re match:\n\
673 	re match class:\"\\[\\^?\":\"\\]\"::Plain:re match:\n\
674 	re match class delims:\"&\":\"&\"::Regex:re match class:C\n\
675 	re match class esc chars:\"\\\\([abdeflnrstuwzABDEGLQSUWZ^\\]\\\\-]|0[0-7]{2}|x[0-9a-fA-F]{2})\":::Text Escape:re match class:\n\
676 	re match variables:\"\\$([-_.,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:re match:\n\
677 	re match comment:\"\\(\\?#[^)]*\\)\":::Comment:re match:\n\
678 	re match syms:\"[.^$[\\])|)]|\\{\\d+(,\\d*)?\\}\\??|\\((\\?([:=!>imsx]|\\<[=!]))?|[?+*]\\??\":::Regex:re match:\n\
679 	re match refs:\"\\\\[1-9]\\d?\":::Identifier1:re match:\n\
680 	re sub:\"<(s/)\":\"(/)((?:\\\\/|\\\\[1-9]\\d?|[^/])*)(/[egimosx]*)\"::Plain::\n\
681 	re sub delims:\"\\1\":\"\\1\\3\"::Keyword:re sub:C\n\
682 	re sub subst:\"\\2\":\"\\2\"::String:re sub:C\n\
683 	re sub esc chars:\"\\\\([/abdeflnrstuwzABDEGLQSUWZ+?.*$^(){}[\\]|\\\\]|0[0-7]{2}|x[0-9a-fA-F]{2})\":::Text Escape:re sub:\n\
684 	re sub class:\"\\[\\^?\":\"\\]\"::Plain:re sub:\n\
685 	re sub class delims:\"&\":\"&\"::Regex:re sub class:C\n\
686 	re sub class esc chars:\"\\\\([abdeflnrstuwzABDEGLQSUWZ^\\]\\\\-]|0[0-7]{2}|x[0-9a-fA-F]{2})\":::Text Escape:re sub class:\n\
687 	re sub variables:\"\\$([-_.,\"\"\\\\*?#;!@$<>(%=~^|&`'+[\\]]|:(?!:)|\\^[ADEFHILMOPSTWX]|ARGV|\\d{1,2})|(@|\\$#)(ARGV|EXPORT|EXPORT_OK|F|INC|ISA|_)>|%(ENV|EXPORT_TAGS|INC|SIG)>|(\\$#?|@|%)(::)?[\\l_](\\w|::(?=\\w))*|(\\$#?|@|%)\\{(::)?[\\l_](\\w|::(?=\\w))*\\}|(\\$|@|%)(?=\\{)\":::Identifier1:re sub:\n\
688 	re sub comment:\"\\(\\?#[^)]*\\)\":::Comment:re sub:\n\
689 	re sub syms:\"[.^$[\\])|)]|\\{\\d+(,\\d*)?\\}\\??|\\((\\?([:=!>imsx]|\\<[=!]))?|[?+*]\\??\":::Regex:re sub:\n\
690 	re sub refs:\"\\\\[1-9]\\d?\":::Identifier1:re sub:\n\
691 	info:\"version: 2.02p1; author/maintainer: Joor Loohuis, joor@loohuis-consulting.nl\":::Plain::}",
692     "PostScript:1:0{\n\
693 	DSCcomment:\"^%[%|!]\":\"$\"::Preprocessor::\n\
694 	Comment:\"%\":\"$\"::Comment::\n\
695 	string:\"\\(\":\"\\)\"::String::\n\
696 	string esc chars:\"\\\\(n|r|t|b|f|\\\\|\\(|\\)|[0-9][0-9]?[0-9]?)?\":::String2:string:\n\
697 	string2:\"\\(\":\"\\)\"::String:string:\n\
698 	string2 esc chars:\"\\\\(n|r|t|b|f|\\\\|\\(|\\)|[0-9][0-9]?[0-9]?)?\":::String2:string2:\n\
699 	string3:\"\\(\":\"\\)\"::String:string2:\n\
700 	string3 esc chars:\"\\\\(n|r|t|b|f|\\\\|\\(|\\)|[0-9][0-9]?[0-9]?)?\":::String2:string3:\n\
701 	ASCII 85 string:\"\\<~\":\"~\\>\":\"[^!-uz]\":String1::\n\
702 	Dictionary:\"(\\<\\<|\\>\\>)\":::Storage Type::\n\
703 	hex string:\"\\<\":\"\\>\":\"[^0-9a-fA-F> \\t]\":String1::\n\
704 	Literal:\"/[^/%{}\\(\\)\\<\\>\\[\\]\\f\\n\\r\\t ]*\":::Text Key::\n\
705 	Number:\"(?<!\\Y)((([2-9]|[1-2][0-9]|3[0-6])#[0-9a-zA-Z]*)|(((\\+|-)?[0-9]+\\.?[0-9]*)|((\\+|-)?\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(?!\\Y)\":::Numeric Const::D\n\
706 	Array:\"[\\[\\]]\":::Storage Type::D\n\
707 	Procedure:\"[{}]\":::Subroutine::D\n\
708 	Operator1:\"(?<!\\Y)(=|==|abs|add|aload|anchorsearch|and|arc|arcn|arcto|array|ashow|astore|atan|awidthshow|begin|bind|bitshift|bytesavailable|cachestatus|ceiling|charpath|clear|cleardictstack|cleartomark|clip|clippath|closefile|closepath|concat|concatmatrix|copy|copypage|cos|count|countdictstack|countexecstack|counttomark|currentdash|currentdict|currentfile|currentflat|currentfont|currentgray|currenthsbcolor|currentlinecap|currentlinejoin|currentlinewidth|currentmatrix|currentmiterlimit|currentpoint|currentrgbcolor|currentscreen|currenttransfer|curveto|cvi|cvlit|cvn|cvr|cvrs|cvs|cvx|def|defaultmatrix|definefont|dict|dictstack|div|dtransform|dup|echo|eexec|end|eoclip|eofill|eq|erasepage|errordict|exch|exec|execstack|executeonly|executive|exit|exitserver|exp|false|file|fill|findfont|flattenpath|floor|flush|flushfile|FontDirectory|for|forall|ge|get|getinterval|grestore|grestoreall|gsave|gt|handleerror|identmatrix|idiv|idtransform|if|ifelse|image|imagemask|index|initclip|initgraphics|initmatrix|internaldict|invertmatrix|itransform|known|kshow|le|length|lineto|ln|load|log|loop|lt|makefont|mark|matrix|maxlength|mod|moveto|mul|ne|neg|newpath|noaccess|not|null|nulldevice|or|pathbbox|pathforall|pop|print|prompt|pstack|put|putinterval|quit|rand|rcheck|rcurveto|read|readhexstring|readline|readonly|readstring|repeat|resetfile|restore|reversepath|rlineto|rmoveto|roll|rotate|round|rrand|run|save|scale|scalefont|search|serverdict|setcachedevice|setcachelimit|setcharwidth|setdash|setflat|setfont|setgray|sethsbcolor|setlinecap|setlinejoin|setlinewidth|setmatrix|setmiterlimit|setrgbcolor|setscreen|settransfer|show|showpage|sin|sqrt|srand|stack|StandardEncoding|start|status|statusdict|stop|stopped|store|string|stringwidth|stroke|strokepath|sub|systemdict|token|transform|translate|true|truncate|type|userdict|usertime|version|vmstatus|wcheck|where|widthshow|write|writehexstring|writestring|xcheck|xor)(?!\\Y)\":::Keyword::D\n\
709 	Operator2:\"<(arct|colorimage|cshow|currentblackgeneration|currentcacheparams|currentcmykcolor|currentcolor|currentcolorrendering|currentcolorscreen|currentcolorspace|currentcolortransfer|currentdevparams|currentglobal|currentgstate|currenthalftone|currentobjectformat|currentoverprint|currentpacking|currentpagedevice|currentshared|currentstrokeadjust|currentsystemparams|currentundercolorremoval|currentuserparams|defineresource|defineuserobject|deletefile|execform|execuserobject|filenameforall|fileposition|filter|findencoding|findresource|gcheck|globaldict|GlobalFontDirectory|glyphshow|gstate|ineofill|infill|instroke|inueofill|inufill|inustroke|ISOLatin1Encoding|languagelevel|makepattern|packedarray|printobject|product|realtime|rectclip|rectfill|rectstroke|renamefile|resourceforall|resourcestatus|revision|rootfont|scheck|selectfont|serialnumber|setbbox|setblackgeneration|setcachedevice2|setcacheparams|setcmykcolor|setcolor|setcolorrendering|setcolorscreen|setcolorspace|setcolortransfer|setdevparams|setfileposition|setglobal|setgstate|sethalftone|setobjectformat|setoverprint|setpacking|setpagedevice|setpattern|setshared|setstrokeadjust|setsystemparams|setucacheparams|setundercolorremoval|setuserparams|setvmthreshold|shareddict|SharedFontDirectory|startjob|uappend|ucache|ucachestatus|ueofill|ufill|undef|undefinefont|undefineresource|undefineuserobject|upath|UserObjects|ustroke|ustrokepath|vmreclaim|writeobject|xshow|xyshow|yshow)>\":::Keyword::D\n\
710 	Operator3:\"<(GetHalftoneName|GetPageDeviceName|GetSubstituteCRD|StartData|addglyph|beginbfchar|beginbfrange|begincidchar|begincidrange|begincmap|begincodespacerange|beginnotdefchar|beginnotdefrange|beginrearrangedfont|beginusematrix|cliprestore|clipsave|composefont|currentsmoothness|currenttrapparams|endbfchar|endbfrange|endcidchar|endcidrange|endcmap|endcodespacerange|endnotdefchar|endnotdefrange|endrearrangedfont|endusematrix|findcolorrendering|removeall|removeglyphs|setsmoothness|settrapparams|settrapzone|shfill|usecmap|usefont)>\":::Keyword::D\n\
711 	Old operator:\"<(condition|currentcontext|currenthalftonephase|defineusername|detach|deviceinfo|eoviewclip|fork|initviewclip|join|lock|monitor|notify|rectviewclip|sethalftonephase|viewclip|viewclippath|wait|wtranslation|yield)>\":::Keyword::D}",
712     "Python:2:0{\n\
713 	Comment:\"#\":\"$\"::Comment::\n\
714 	String3s:\"[uU]?[rR]?'{3}\":\"'{3}\"::String::\n\
715 	String3d:\"[uU]?[rR]?\"\"{3}\":\"\"\"{3}\"::String::\n\
716 	String1s:\"[uU]?[rR]?'\":\"'\":\"$\":String::\n\
717 	String1d:\"[uU]?[rR]?\"\"\":\"\"\"\":\"$\":String::\n\
718 	String escape chars 3s:\"\\\\(?:\\n|\\\\|'|\"\"|a|b|f|n|r|t|v|[0-7]{1,3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|U[\\da-fA-F]{8})\":::String1:String3s:\n\
719 	String escape chars 3d:\"\\\\(?:\\n|\\\\|'|\"\"|a|b|f|n|r|t|v|[0-7]{1,3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|U[\\da-fA-F]{8})\":::String1:String3d:\n\
720 	String escape chars 1s:\"\\\\(?:\\n|\\\\|'|\"\"|a|b|f|n|r|t|v|[0-7]{1,3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|U[\\da-fA-F]{8})\":::String1:String1s:\n\
721 	String escape chars 1d:\"\\\\(?:\\n|\\\\|'|\"\"|a|b|f|n|r|t|v|[0-7]{1,3}|x[\\da-fA-F]{2}|u[\\da-fA-F]{4}|U[\\da-fA-F]{8})\":::String1:String1d:\n\
722 	Representation:\"`\":\"`\":\"$\":String2::\n\
723 	Representation cont:\"\\\\\\n\":::String2:Representation:\n\
724 	Number:\"(?<!\\Y)(?:(?:(?:[1-9]\\d*|(?:[1-9]\\d*|0)?\\.\\d+|(?:[1-9]\\d*|0)\\.)[eE][\\-+]?\\d+|(?:[1-9]\\d*|0)?\\.\\d+|(?:[1-9]\\d*|0)\\.)[jJ]?|(?:[1-9]\\d*|0)[jJ]|(?:0|[1-9]\\d*|0[oO]?[0-7]+|0[xX][\\da-fA-F]+|0[bB][0-1]+)[lL]?)(?!\\Y)\":::Numeric Const::\n\
725 	Multiline import:\"<from>.*?\\(\":\"\\)\"::Preprocessor::\n\
726 	Multiline import comment:\"#\":\"$\"::Comment:Multiline import:\n\
727 	Import:\"<(?:import|from)>\":\";|$\":\"#\":Preprocessor::\n\
728 	Import continuation:\"\\\\\\n\":::Preprocessor:Import:\n\
729 	Member definition:\"<(def)\\s+(?:(__(?:abs|add|and|call|cmp|coerce|complex|contains|del|delattr|delete|delitem|div|divmod|enter|eq|exit|float|floordiv|format|ge|get|getattr|getitem|gt|hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|index|init|int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|long|lshift|lt|mod|mul|ne|neg|nonzero|oct|or|pos|pow|radd|rand|rdiv|rdivmod|repr|reversed|rfloordiv|rlshift|rmod|rmul|ror|rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|str|sub|truediv|unicode|xor)__)|((__bases__|__class__|__dict__|__doc__|__func__|__metaclass__|__module__|__name__|__self__|__slots__|co_argcount|co_cellvars|co_code|co_filename|co_firstlineno|co_flags|co_lnotab|co_name|co_names|co_nlocals|co_stacksize|co_varnames|f_back|f_builtins|f_code|f_exc_traceback|f_exc_type|f_exc_value|f_globals|f_lasti|f_restricted|f_trace|func_closure|func_code|func_defaults|func_dict|func_doc|func_globals|func_name|im_class|im_func|im_self|tb_frame|tb_lasti|tb_next)|(__(?:delslice|getslice|setslice)__)|(__(?:members|methods)__))|(and|as|assert|break|continue|def|del|elif|else|except|exec|finally|for|from|if|import|in|is|not|or|pass|print|raise|return|try|while|with|yield|class|global|lambda)|([\\l_]\\w*))(?=(?:\\s*(?:\\\\\\n\\s*)?\\(\\s*|\\s*\\(\\s*(?:\\\\?\\n\\s*)?)self>)\":::Plain::\n\
730 	Member def color:\"\\1\":::Keyword:Member definition:C\n\
731 	Member def special:\"\\2\":::Subroutine:Member definition:C\n\
732 	Member def deprecated:\"\\3\":::Warning:Member definition:C\n\
733 	Member def error:\"\\7\":::Flag:Member definition:C\n\
734 	Static method definition:\"<(def)\\s+(__(?:new)__)\":::Plain::\n\
735 	Static def color:\"\\1\":::Keyword:Static method definition:C\n\
736 	Static def special:\"\\2\":::Subroutine:Static method definition:C\n\
737 	Function definition:\"<(def)\\s+(?:(ArithmeticError|AssertionError|AttributeError|BaseException|BufferError|BytesWarning|DeprecationWarning|EOFError|Ellipsis|EnvironmentError|Exception|False|FloatingPointError|FutureWarning|GeneratorExit|IOError|ImportError|ImportWarning|IndentationError|IndexError|KeyError|KeyboardInterrupt|LookupError|MemoryError|NameError|None|NotImplemented|NotImplementedError|OSError|OverflowError|PendingDeprecationWarning|ReferenceError|RuntimeError|RuntimeWarning|StandardError|StopIteration|SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|True|TypeError|UnboundLocalError|UnicodeDecodeError|UnicodeEncodeError|UnicodeError|UnicodeTranslateError|UnicodeWarning|UserWarning|ValueError|Warning|WindowsError|ZeroDivisionError|__builtins__|__debug__|__doc__|__import__|__name__|abs|all|any|apply|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|copyright|credits|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|license|list|locals|long|map|max|min|object|oct|open|ord|pow|property|quit|range|raw_input|reduce|reload|repr|reversed|round|self|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)|(and|as|assert|break|continue|def|del|elif|else|except|exec|finally|for|from|if|import|in|is|not|or|pass|print|raise|return|try|while|with|yield|class|global|lambda)|([\\l_]\\w*))>\":::Plain::\n\
738 	Function def color:\"\\1\":::Keyword:Function definition:C\n\
739 	Function def deprecated:\"\\2\":::Warning:Function definition:C\n\
740 	Function def error:\"\\3\":::Flag:Function definition:C\n\
741 	Class definition:\"<(class)\\s+(?:(ArithmeticError|AssertionError|AttributeError|BaseException|BufferError|BytesWarning|DeprecationWarning|EOFError|Ellipsis|EnvironmentError|Exception|False|FloatingPointError|FutureWarning|GeneratorExit|IOError|ImportError|ImportWarning|IndentationError|IndexError|KeyError|KeyboardInterrupt|LookupError|MemoryError|NameError|None|NotImplemented|NotImplementedError|OSError|OverflowError|PendingDeprecationWarning|ReferenceError|RuntimeError|RuntimeWarning|StandardError|StopIteration|SyntaxError|SyntaxWarning|SystemError|SystemExit|TabError|True|TypeError|UnboundLocalError|UnicodeDecodeError|UnicodeEncodeError|UnicodeError|UnicodeTranslateError|UnicodeWarning|UserWarning|ValueError|Warning|WindowsError|ZeroDivisionError|__builtins__|__debug__|__doc__|__import__|__name__|abs|all|any|apply|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|copyright|credits|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|license|list|locals|long|map|max|min|object|oct|open|ord|pow|property|quit|range|raw_input|reduce|reload|repr|reversed|round|self|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)|(and|as|assert|break|continue|def|del|elif|else|except|exec|finally|for|from|if|import|in|is|not|or|pass|print|raise|return|try|while|with|yield|class|global|lambda)|([\\l_]\\w*))>\":::Plain::\n\
742 	Class def color:\"\\1\":::Storage Type:Class definition:C\n\
743 	Class def deprecated:\"\\2\":::Warning:Class definition:C\n\
744 	Class def error:\"\\3\":::Flag:Class definition:C\n\
745 	Member reference:\"\\.\\s*(?:\\\\?\\n\\s*)?(?:((__(?:abs|add|and|call|cmp|coerce|complex|contains|del|delattr|delete|delitem|div|divmod|enter|eq|exit|float|floordiv|format|ge|get|getattr|getitem|gt|hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|index|init|int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|long|lshift|lt|mod|mul|ne|neg|nonzero|oct|or|pos|pow|radd|rand|rdiv|rdivmod|repr|reversed|rfloordiv|rlshift|rmod|rmul|ror|rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|str|sub|truediv|unicode|xor)__)|(__(?:new)__))|((__(?:delslice|getslice|setslice)__)|(__(?:members|methods)__))|(__bases__|__class__|__dict__|__doc__|__func__|__metaclass__|__module__|__name__|__self__|__slots__|co_argcount|co_cellvars|co_code|co_filename|co_firstlineno|co_flags|co_lnotab|co_name|co_names|co_nlocals|co_stacksize|co_varnames|f_back|f_builtins|f_code|f_exc_traceback|f_exc_type|f_exc_value|f_globals|f_lasti|f_restricted|f_trace|func_closure|func_code|func_defaults|func_dict|func_doc|func_globals|func_name|im_class|im_func|im_self|tb_frame|tb_lasti|tb_next)|(and|as|assert|break|continue|def|del|elif|else|except|exec|finally|for|from|if|import|in|is|not|or|pass|print|raise|return|try|while|with|yield|class|global|lambda)|([\\l_]\\w*))>\":::Plain::\n\
746 	Member special method:\"\\1\":::Subroutine:Member reference:C\n\
747 	Member deprecated:\"\\4\":::Warning:Member reference:C\n\
748 	Member special attrib:\"\\7\":::Identifier1:Member reference:C\n\
749 	Member ref error:\"\\8\":::Flag:Member reference:C\n\
750 	Storage keyword:\"<(?:class|global|lambda)>\":::Storage Type::\n\
751 	Keyword:\"<(?:and|as|assert|break|continue|def|del|elif|else|except|exec|finally|for|from|if|import|in|is|not|or|pass|print|raise|return|try|while|with|yield)>\":::Keyword::\n\
752 	Built-in function:\"<(?:__import__|abs|all|any|basestring|bin|bool|bytearray|bytes|callable|chr|classmethod|cmp|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|exit|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|isinstance|issubclass|iter|len|list|locals|long|map|max|min|object|oct|open|ord|pow|property|quit|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)>\":::Subroutine::\n\
753 	Built-in name:\"<(?:Ellipsis|False|None|NotImplemented|True|__builtins__|__debug__|__doc__|__name__|copyright|credits|license|self)>\":::Identifier1::\n\
754 	Built-in exceptions:\"<(?:ArithmeticError|AssertionError|AttributeError|BaseException|BufferError|EOFError|EnvironmentError|Exception|FloatingPointError|GeneratorExit|IOError|ImportError|IndentationError|IndexError|KeyError|KeyboardInterrupt|LookupError|MemoryError|NameError|NotImplementedError|OSError|OverflowError|ReferenceError|RuntimeError|StandardError|StopIteration|SyntaxError|SystemError|SystemExit|TabError|TypeError|UnboundLocalError|UnicodeDecodeError|UnicodeEncodeError|UnicodeError|UnicodeTranslateError|ValueError|WindowsError|ZeroDivisionError)>\":::Identifier1::\n\
755 	Built-in warnings:\"<(?:BytesWarning|DeprecationWarning|FutureWarning|ImportWarning|PendingDeprecationWarning|RuntimeWarning|SyntaxWarning|UnicodeWarning|UserWarning|Warning)>\":::Identifier1::\n\
756 	Deprecated function:\"<(?:apply|buffer|coerce|intern)>\":::Warning::\n\
757 	Braces and parens:\"[[{()}\\]]\":::Keyword::D\n\
758 	Decorator:\"(@)\":\"$\":\"#\":Preprocessor1::\n\
759 	Decorator continuation:\"\\\\\\n\":::Preprocessor1:Decorator:\n\
760 	Decorator marker:\"\\1\":::Storage Type:Decorator:C\n\
761 	Operators:\"\\+|-|\\*|\\*\\*|/|//|%|\\<\\<|\\>\\>|\\&|\\||\\^|~|\\<|\\>|\\<=|\\>=|==|!=\":::Keyword::\n\
762 	Delimiter:\"\\(|\\)|\\[|\\]|\\{|\\}|,|:|\\.|;|=|\\+=|-=|\\*=|/=|//=|%=|\\&=|\\|=|\\^=|\\>\\>=|\\<\\<=|\\*\\*=\":::Keyword::\n\
763 	Invalid:\"\\$|\\?|<(?:0[bB]\\w+|0[xX]\\w+|(?:0|[1-9]\\d*)\\w+)>\":::Flag::}",
764     "Regex:1:0{\n\
765 	Comments:\"(?#This is a comment!)\\(\\?#[^)]*(?:\\)|$)\":::Comment::\n\
766 	Literal Escape:\"(?#Special chars that need escapes)\\\\[abefnrtv()\\[\\]<>{}.|^$*+?&\\\\]\":::Preprocessor::\n\
767 	Shortcut Escapes:\"(?#Shortcuts for common char classes)\\\\[dDlLsSwW]\":::Character Const::\n\
768 	Backreferences:\"(?#Internal regex backreferences)\\\\[1-9]\":::Storage Type::\n\
769 	Word Delimiter:\"(?#Special token to match NEdit [non]word-delimiters)\\\\[yY]\":::Subroutine::\n\
770 	Numeric Escape:\"(?#Negative lookahead is to exclude \\x0 and \\00)(?!\\\\[xX0]0*(?:[^\\da-fA-F]|$))\\\\(?:[xX]0*[1-9a-fA-F][\\da-fA-F]?|0*[1-3]?[0-7]?[0-7])\":::Numeric Const::\n\
771 	Quantifiers:\"(?#Matches greedy and lazy quantifiers)[*+?]\\??\":::Flag::\n\
772 	Counting Quantifiers:\"(?#Properly limits range numbers to 0-65535)\\{(?:[0-5]?\\d?\\d?\\d?\\d|6[0-4]\\d\\d\\d|65[0-4]\\d\\d|655[0-2]\\d|6553[0-5])?(?:,(?:[0-5]?\\d?\\d?\\d?\\d|6[0-4]\\d\\d\\d|65[0-4]\\d\\d|655[0-2]\\d|6553[0-5])?)?\\}\\??\":::Numeric Const::\n\
773 	Character Class:\"(?#Handles escapes, char ranges, ^-] at beginning and - at end)\\[\\^?[-\\]]?(?:(?:\\\\(?:[abdeflnrstvwDLSW\\-()\\[\\]<>{}.|^$*+?&\\\\]|[xX0][\\da-fA-F]+)|[^\\\\\\]])(?:-(?:\\\\(?:[abdeflnrstvwDLSW\\-()\\[\\]<>{}.|^$*+?&\\\\]|[xX0][\\da-fA-F]+)|[^\\\\\\]]))?)*\\-?]\":::Character Const::\n\
774 	Anchors:\"(?#\\B is the \"\"not a word boundary\"\" anchor)[$^<>]|\\\\B\":::Flag::\n\
775 	Parens and Alternation:\"\\(?:\\?(?:[:=!iInN])|[()|]\":::Keyword::\n\
776 	Match Themselves:\"(?#Highlight chars left over which just match themselves).\":::Text Comment::D}",
777     "SGML HTML:6:0{\n\
778 	markup declaration:\"\\<!\":\"\\>\"::Plain::\n\
779 	mdo-mdc:\"&\":\"&\"::Storage Type:markup declaration:C\n\
780 	markup declaration dq string:\"\"\"\":\"\"\"\"::String1:markup declaration:\n\
781 	markup declaration sq string:\"'\":\"'\"::String1:markup declaration:\n\
782 	entity declaration:\"((?ientity))[ \\t\\n][ \\t]*\\n?[ \\t]*(%[ \\t\\n][ \\t]*\\n?[ \\t]*)?(\\l[\\l\\d\\-\\.]*|#((?idefault)))[ \\t\\n][ \\t]*\\n?[ \\t]*((?i[cs]data|pi|starttag|endtag|m[ds]))?\":::Preprocessor:markup declaration:\n\
783 	ed name:\"\\2\":\"\"::String2:element declaration:C\n\
784 	ed type:\"\\4\":\"\"::Storage Type:entity declaration:C\n\
785 	doctype declaration:\"((?idoctype))[ \\t\\n][ \\t]*\\n?[ \\t]*(\\l[\\l\\d\\-\\.]*)\":::Preprocessor:markup declaration:\n\
786 	dt name:\"\\2\":\"\"::String2:doctype declaration:C\n\
787 	element declaration:\"((?ielement))[ \\t\\n][ \\t]*\\n?[ \\t]*(\\l[\\l\\d\\-\\.]*)\":::Preprocessor:markup declaration:\n\
788 	attribute declaration:\"((?iattlist))[ \\t\\n][ \\t]*\\n?[ \\t]*(\\l[\\l\\d\\-\\.]*)\":::Preprocessor:markup declaration:\n\
789 	ad name:\"\\2\":\"\"::String2:attribute declaration:C\n\
790 	notation declaration:\"((?inotation))[ \\t\\n][ \\t]*\\n?[ \\t]*(\\l[\\l\\d\\-\\.]*)\":::Preprocessor:markup declaration:\n\
791 	nd name:\"\\2\":\"\"::String2:notation declaration:C\n\
792 	shortref declaration:\"((?ishortref))[ \\t\\n][ \\t]*\\n?[ \\t]*(\\l[\\l\\d\\-\\.]*)\":::Preprocessor:markup declaration:\n\
793 	sd name:\"\\2\":\"\"::String2:shortref declaration:C\n\
794 	comment:\"\\-\\-\":\"\\-\\-\"::Comment:markup declaration:\n\
795 	pi:\"\\<\\?[^\\>]*\\??\\>\":::Flag::\n\
796 	stag:\"(\\<)(\\(\\l[\\w\\-\\.:]*\\))?\\l[\\w\\-\\.:]*\":\"/?\\>\"::Text Key1::\n\
797 	stago-tagc:\"\\1\":\"&\"::Text Arg:stag:C\n\
798 	Attribute:\"([\\l\\-]+)[ \\t\\v]*\\n?[ \\t\\v]*=[ \\t\\v]*\\n?[ \\t\\v]*(\"\"([^\"\"]*\\n){,4}[^\"\"]*\"\"|'([^']*\\n){,4}[^']*'|\\&([^;]*\\n){,4}[^;]*;|[\\w\\-\\.:]+)\":::Plain:stag:\n\
799 	Attribute name:\"\\1\":\"\"::Text Arg2:Attribute:C\n\
800 	Attribute value:\"\\2\":\"\"::String:Attribute:C\n\
801 	Boolean Attribute:\"([\\l\\-]+)\":::Text Arg1:stag:\n\
802 	etag:\"(\\</)(\\(\\l[\\w\\-\\.:]*\\))?(\\l[\\w\\-\\.:]*[ \\t\\v]*\\n?[ \\t\\v]*)?(\\>)\":::Text Key1::\n\
803 	etago-tagc:\"\\1\\4\":\"\"::Text Arg:etag:C\n\
804 	Character reference:\"\\&((\\(\\l[\\l\\d\\-\\.]*\\))?\\l[\\l\\d]*|#\\d+|#[xX][a-fA-F\\d]+);?\":::Text Escape::\n\
805 	parameter entity:\"%(\\(\\l[\\l\\d\\-\\.]*\\))?\\l[\\l\\d\\-\\.]*;?\":::Text Escape::\n\
806 	md parameter entity:\"%(\\(\\l[\\l\\d\\-\\.]*\\))?\\l[\\l\\d\\-\\.]*;?\":::Text Escape:markup declaration:\n\
807 	system-public id:\"<(?isystem|public|cdata)>\":::Storage Type:markup declaration:}",
808     "SQL:1:0{\n\
809 	keywords:\",|%|\\<|\\>|:=|=|<(SELECT|ON|FROM|ORDER BY|DESC|WHERE|AND|OR|NOT|NULL|TRUE|FALSE)>\":::Keyword::\n\
810 	comment:\"--\":\"$\"::Comment::\n\
811 	data types:\"<(CHAR|VARCHAR2\\([0-9]*\\)|INT[0-9]*|POINT|BOX|TEXT|BOOLEAN|VARCHAR2|VARCHAR|NUMBER\\([0-9]*\\)|NUMBER)(?!\\Y)\":::Storage Type::\n\
812 	string:\"'\":\"'\"::String::\n\
813 	keywords2:\"END IF;|(?<!\\Y)(CREATE|REPLACE|BEGIN|END|FUNCTION|RETURN|FETCH|OPEN|CLOSE| IS|NOTFOUND|CURSOR|IF|ELSE|THEN|INTO|IS|IN|WHEN|OTHERS|GRANT|ON|TO|EXCEPTION|SHOW|SET|OUT|PRAGMA|AS|PACKAGE)>\":::Preprocessor1::\n\
814 	comment2:\"/\\*\":\"\\*/\"::Comment::}",
815     "Sh Ksh Bash:1:0{\n\
816         README:\"Shell syntax highlighting patterns, version 2.2, maintainer Thorsten Haude, nedit at thorstenhau.de\":::Flag::D\n\
817         escaped special characters:\"\\\\[\\\\\"\"$`']\":::Keyword::\n\
818         single quoted string:\"'\":\"'\"::String1::\n\
819         double quoted string:\"\"\"\":\"\"\"\"::String::\n\
820         double quoted escape:\"\\\\[\\\\\"\"$`]\":::String2:double quoted string:\n\
821         dq command sub:\"`\":\"`\":\"\"\"\":Subroutine:double quoted string:\n\
822         dq arithmetic expansion:\"\\$\\(\\(\":\"\\)\\)\":\"\"\"\":String:double quoted string:\n\
823         dq new command sub:\"\\$\\(\":\"\\)\":\"\"\"\":Subroutine:double quoted string:\n\
824         dqncs single quoted string:\"'\":\"'\"::String1:dq new command sub:\n\
825         dq variables:\"\\$([-*@#?$!0-9]|[a-zA-Z_][0-9a-zA-Z_]*)\":::Identifier1:double quoted string:\n\
826         dq variables2:\"\\$\\{\":\"}\":\"\\n\":Identifier1:double quoted string:\n\
827         arithmetic expansion:\"\\$\\(\\(\":\"\\)\\)\"::String::\n\
828         ae escapes:\"\\\\[\\\\$`\"\"']\":::String2:arithmetic expansion:\n\
829         ae single quoted string:\"'\":\"'\":\"\\)\\)\":String1:arithmetic expansion:\n\
830         ae command sub:\"`\":\"`\":\"\\)\\)\":Subroutine:arithmetic expansion:\n\
831         ae arithmetic expansion:\"\\$\\(\\(\":\"\\)\\)\"::String:arithmetic expansion:\n\
832         ae new command sub:\"\\$\\(\":\"\\)\":\"\\)\\)\":Subroutine:arithmetic expansion:\n\
833         ae variables:\"\\$([-*@#?$!0-9]|[a-zA-Z_][0-9a-zA-Z_]*)\":::Identifier1:arithmetic expansion:\n\
834         ae variables2:\"\\$\\{\":\"}\":\"\\)\\)\":Identifier1:arithmetic expansion:\n\
835         comments:\"^[ \\t]*#\":\"$\"::Comment::\n\
836         command substitution:\"`\":\"`\"::Subroutine::\n\
837         cs escapes:\"\\\\[\\\\$`\"\"']\":::Subroutine1:command substitution:\n\
838         cs single quoted string:\"'\":\"'\":\"`\":String1:command substitution:\n\
839         cs variables:\"\\$([-*@#?$!0-9]|[a-zA-Z_][0-9a-zA-Z_]*)\":::Identifier1:command substitution:\n\
840         cs variables2:\"\\$\\{\":\"}\":\"`\":Identifier1:command substitution:\n\
841         new command substitution:\"\\$\\(\":\"\\)\"::Subroutine::\n\
842         ncs new command substitution:\"\\$\\(\":\"\\)\"::Subroutine:new command substitution:\n\
843         ncs escapes:\"\\\\[\\\\$`\"\"']\":::Subroutine1:new command substitution:\n\
844         ncs single quoted string:\"'\":\"'\"::String1:new command substitution:\n\
845         ncs variables:\"\\$([-*@#?$!0-9]|[a-zA-Z_][0-9a-zA-Z_]*)\":::Identifier1:new command substitution:\n\
846         ncs variables2:\"\\$\\{\":\"}\":\"\\)\":Identifier1:new command substitution:\n\
847         assignment:\"[a-zA-Z_][0-9a-zA-Z_]*=\":::Identifier1::\n\
848         variables:\"\\$([-*@#?$!0-9_]|[a-zA-Z_][0-9a-zA-Z_]*)\":::Identifier1::\n\
849         variables2:\"\\$\\{\":\"}\"::Identifier1::\n\
850         internal var:\"\\$\\{\":\"}\"::Identifier1:variables2:\n\
851         comments in line:\"#\":\"$\"::Comment::\n\
852         numbers:\"<(?i0x[\\da-f]+)|((\\d*\\.)?\\d+([eE][-+]?\\d+)?(?iul?|l|f)?)>\":::Numeric Const::D\n\
853         keywords:\"(?<!\\Y)(if|fi|then|else|elif|case|esac|while|for|do|done|in|select|time|until|function|\\[\\[|\\]\\])(?!\\Y)[\\s\\n]\":::Keyword::D\n\
854         command options:\"(?<=\\s)-[^ \\t{}[\\],()'\"\"~!@#$%^&*|\\\\<>?]+\":::Identifier::\n\
855         delimiters:\"[{};<>&~=!|^%[\\]+*|]\":::Text Key::D\n\
856         built ins:\"(?<!\\Y)(:|\\.|source|alias|bg|bind|break|builtin|cd|chdir|command|compgen|complete|continue|declare|dirs|disown|echo|enable|eval|exec|exit|export|fc|fg|getopts|hash|help|history|jobs|kill|let|local|logout|popd|print|printf|pushd|pwd|read|readonly|return|set|shift|shopt|stop|suspend|test|times|trap|type|typeset|ulimit|umask|unalias|unset|wait|whence)(?!\\Y)[\\s\\n;]\":::Subroutine1::D}",
857     "Tcl:1:0{\n\
858 	Double Quote String:\"\"\"\":\"\"\"\"::String::\n\
859 	Single Quote String:\"'\":\"'\":\"[^\\\\][^']\":String::\n\
860 	Ignore Escaped Chars:\"\\\\(.|\\n)\":::Plain::\n\
861 	Variable Ref:\"\\$\\w+|\\$\\{[^}]*}|\\$|#auto\":::Identifier1::\n\
862 	Comment:\"#\":\"$\"::Comment::\n\
863 	Keywords:\"<(after\\s+(\\d+|cancel|idle|info)?|append|array\\s+(anymore|donesearch|exists|get|names|nextelement|set|size|startsearch|unset)|bell|bgerror|binary\\s+(format|scan)|bind(tags)?|body|break|case|catch|cd|class|clipboard\\s+(clear|append)|clock\\s+(clicks|format|scan|seconds)|close|code|common|concat|configbody|constructor|continue|delete\\s+(class|object|namespace)|destroy|destructor|else|elseif|encoding\\s+(convertfrom|convertto|names|system)|ensemble|eof|error|eval|event\\s+(add|delete|generate|info)|exec|exit|expr|fblocked|fconfigure|fcopy|file\\s+(atime|attributes|channels|copy|delete|dirname|executable|exists|extension|isdirectory|isfile|join|lstat|mkdir|mtime|nativename|owned|pathtype|readable|readlink|rename|rootname|size|split|stat|tail|type|volume|writable)|fileevent|find\\s+(classes|objects)|flush|focus|font\\s+(actual|configure|create|delete|families|measure|metrics|names)|foreach|format|gets|glob(al)?|grab\\s+(current|release|set|status|(-global\\s+)?\\w+)|grid(\\s+bbox|(column|row)?configure|forget|info|location|propagate|remove|size|slaves)?|history\\s+(add|change|clear|event|info|keep|nextid|redo)|if|image\\s+(create|delete|height|names|type|width)|incr|info\\s+(args|body|cmdcount|commands|complete|default|exists|globals|hostname|level|library|loaded|locals|nameofexecutable|patchlevel|procs|script|sharedlibextension|tclversion|vars)|inherit|interp\\s+(alias(es)?|create|delete|eval|exists|expose|hide|hidden|invokehidden|issafe|marktrusted|share|slaves|target|transfer)|join|lappend|lindex|linsert|list|llength|load|local|lrange|lreplace|lsearch|lsort|method|memory\\s+(info|(trace|validate)\\s+(on|off)|trace_on_at_malloc|break_on_malloc|display)|namespace\\s+(children|code|current|delete|eval|export|forget|import|inscope|origin|parent|qualifiers|tail|which)|open|option\\s+(add|clear|get|read(file))|pack\\s+(configure|forget|info|propagate|slaves)?|package\\s+(forget|ifneeded|names|present|provide|require|unknown|vcompare|versions|vsatisfies)|pid|place\\s+(configure|forget|info|slaves)?|proc|puts|pwd|raise|read|regexp|regsub|rename|resource\\s+(close|delete|files|list|open|read|types|write)|return|scan|scope(dobject)?|seek|selection\\s+(clear|get|handle|own)|send|set|socket|source|split|string\\s+(bytelength|compare|equal|first|index|is|last|length|map|match|range|repeat|replace|tolower|totitle|toupper|trim|trimleft|trimright|wordend|wordstart)|subst|switch|tell|time|tk\\s+(appname|scaling|useinputmethods)|tk_(bindForTraversal|bisque|chooseColor|chooseDirectory|dialog|focusFollowsMouse|focusNext|focusPrev|getOpenFile|getSaveFile|menuBar|messageBox|optionMenu|popup|setPalette)|tkerror|tkwait\\s+(variable|visibility|window)|trace\\s+(variable|vdelete|vinfo)|unknown|unset|update|uplevel|upvar|usual|variable|while|winfo\\s+(atom|atomname|cells|children|class|colormapfull|containing|depth|exists|fpixels|geometry|height|id|interp|ismapped|manager|name|parent|pathname|pixels|pointerx|pointerxy|pointery|reqheight|reqwidth|rgb|rootx|rooty|screen(cells|depth|height|mmheigth|mmidth|visual|width)?|server|toplevel|viewable|visual(id|savailable)?|vroot(height|width|x|y)|width|x|y)|wm\\s+(aspect|client|colormapwindows|command|deiconify|focusmodel|frame|geometry|grid|group|iconbitmap|icon(ify|mask|name|position|window)|(max|min)size|overrideredirect|positionfrom|protocol|resizable|sizefrom|state|title|transient|withdraw))(?!\\Y)\":::Keyword::D\n\
864 	Widgets:\"<(button(box){0,1}|calendar|canvas(printbox|printdialog){0,1}|check(box|button)|combobox|date(entry|field)|dialog(shell){0,1}|entry(field){0,1}|(ext){0,1}fileselection(box|dialog)|feedback|finddialog|frame|hierarchy|hyperhelp|label(edframe|edwidget){0,1}|listbox|mainwindow|menu(bar|button){0,1}|message(box|dialog){0,1}|notebook|optionmenu|panedwindow|promptdialog|pushbutton|radio(box|button)|scale|scrollbar|scrolled(canvas|frame|html|listbox|text)|selection(box|dialog)|shell|spin(date|int|ner|time)|tab(notebook|set)|text|time(entry|field)|toolbar|toplevel|watch)>\":::Identifier::\n\
865 	Braces and Brackets:\"[\\[\\]{}]\":::Keyword::D\n\
866 	DQ String Esc Chars:\"\\\\(.|\\n)\":::String1:Double Quote String:\n\
867 	SQ String Esc Chars:\"\\\\(.|\\n)\":::String1:Single Quote String:\n\
868 	Variable in String:\"\\$\\w+|\\$\\{[^}]*}|\\$\":::Identifier1:Double Quote String:\n\
869 	Storage:\"<(public|private|protected)>\":::Storage Type::\n\
870 	Namespace:\"\\w+::\":::Keyword::}",
871     "VHDL:1:0{\n\
872 	Comments:\"--\":\"$\"::Comment::\n\
873 	String Literals:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
874 	Vhdl Attributes:\"'[a-zA-Z][a-zA-Z_]+\":::Ada Attributes::\n\
875 	Character Literals:\"'\":\"'\":\"[^\\\\][^']\":Character Const::\n\
876 	Numeric Literals:\"(?<!\\Y)(((2#|8#|10#|16#)[_0-9a-fA-F]*#)|[0-9.]+)(?!\\Y)\":::Numeric Const::\n\
877 	Predefined Types:\"<(?ialias|constant|signal|variable|subtype|type|resolved|boolean|string|integer|natural|time)>\":::Storage Type::D\n\
878 	Predefined SubTypes:\"<(?istd_logic|std_logic_vector|std_ulogic|std_ulogic_vector|bit|bit_vector)>\":::Storage Type::D\n\
879 	Reserved Words:\"<(?iabs|access|after|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|disconnect|downto|else|elsif|end|entity|error|exit|failure|file|for|function|generate|generic|guarded|if|in|inout|is|label|library|linkage|loop|map|mod|nand|new|next|nor|not|note|null|of|on|open|or|others|out|package|port|procedure|process|range|record|register|rem|report|return|select|severity|then|to|transport|units|until|use|wait|warning|when|while|with|xor|group|impure|inertial|literal|postponed|pure|reject|rol|ror|shared|sla|sll|sra|srl|unaffected|xnor)>\":::Keyword::D\n\
880 	Identifiers:\"<([a-zA-Z][a-zA-Z0-9_]*)>\":::Plain::D\n\
881 	Flag Special Comments:\"--\\<[^a-zA-Z0-9]+\\>\":::Flag:Comments:\n\
882 	Instantiation:\"([a-zA-Z][a-zA-Z0-9_]*)([ \\t]+):([ \\t]+)([a-zA-Z][a-zA-Z0-9_]*)([ \\t]+)(port|generic|map)\":::Keyword::\n\
883 	Instance Name:\"\\1\":\"\"::Identifier1:Instantiation:C\n\
884 	Component Name:\"\\4\":\"\"::Identifier:Instantiation:C\n\
885 	Syntax Character:\"(\\<=|=\\>|:|=|:=|;|,|\\(|\\))\":::Keyword::}",
886     "Verilog:1:0{\n\
887 	Comment:\"/\\*\":\"\\*/\"::Comment::\n\
888 	cplus comment:\"//\":\"$\"::Comment::\n\
889 	String Literals:\"\"\"\":\"\"\"\":\"\\n\":String::\n\
890 	preprocessor line:\"^[ ]*`\":\"$\"::Preprocessor::\n\
891 	Reserved WordsA:\"(?<!\\Y)(module|endmodule|parameter|specify|endspecify|begin|end|initial|always|if|else|task|endtask|force|release|attribute|case|case[xz]|default|endattribute|endcase|endfunction|endprimitive|endtable|for|forever|function|primitive|table|while|;)(?!\\Y)\":::Keyword::\n\
892 	Predefined Types:\"<(and|assign|buf|bufif[01]|cmos|deassign|defparam|disable|edge|event|force|fork|highz[01]|initial|inout|input|integer|join|large|macromodule|medium|nand|negedge|nmos|nor|not|notif[01]|or|output|parameter|pmos|posedge|pullup|rcmos|real|realtime|reg|release|repeat|rnmos|rpmos|rtran|rtranif[01]|scalered|signed|small|specparam|strength|strong[01]|supply[01]|time|tran|tranif[01]|tri[01]?|triand|trior|trireg|unsigned|vectored|wait|wand|weak[01]|wire|wor|xnor|xor)>\":::Storage Type::D\n\
893 	System Functions:\"\\$[a-z_]+\":::Subroutine::D\n\
894 	Numeric Literals:\"(?<!\\Y)([0-9]*'[dD][0-9xz\\\\?_]+|[0-9]*'[hH][0-9a-fxz\\\\?_]+|[0-9]*'[oO][0-7xz\\\\?_]+|[0-9]*'[bB][01xz\\\\?_]+|[0-9.]+((e|E)(\\\\+|-)?)?[0-9]*|[0-9]+)(?!\\Y)\":::Numeric Const::\n\
895 	Delay Word:\"(?<!\\Y)((#\\(.*\\))|(#[0-9]*))(?!\\Y)\":::Ada Attributes::D\n\
896 	Simple Word:\"([a-zA-Z][a-zA-Z0-9]*)\":::Plain::D\n\
897 	Instance Declaration:\"([a-zA-Z][a-zA-Z0-9_]*)([ \\t]+)([a-zA-Z][a-zA-Z0-9_$]*)([ \\t]*)\\(\":::Plain::\n\
898 	Module name:\"\\1\":\"\"::Identifier:Instance Declaration:C\n\
899 	Instance Name:\"\\3\":\"\"::Identifier1:Instance Declaration:C\n\
900 	Pins Declaration:\"(?<!\\Y)(\\.([a-zA-Z0-9_]+))>\":::Storage Type1::\n\
901 	Special Chars:\"(\\{|\\}|,|;|=|\\.)\":::Keyword::}",
902     "XML:1:0{\n\
903 	comment:\"\\<!--\":\"--\\>\"::Comment::\n\
904 	ignored section:\"\\<!\\[\\s*IGNORE\\s*\\[\":\"\\]\\]\\>\"::Text Comment::\n\
905 	declaration:\"\\<\\?(?ixml)\":\"\\?\\>\"::Warning::\n\
906 	declaration delims:\"&\":\"&\"::Keyword:declaration:C\n\
907 	declaration attributes:\"((?iversion|encoding|standalone))=\":::Keyword:declaration:\n\
908 	declaration attribute names:\"\\1\":::Preprocessor:declaration attributes:C\n\
909 	declaration sq string:\"'\":\"'\":\"\\n\\n\":String1:declaration:\n\
910 	declaration sq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:declaration sq string:\n\
911 	declaration dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:declaration:\n\
912 	declaration dq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:declaration dq string:\n\
913 	doctype:\"(\\<!(?idoctype))\\s+(\\<?(?!(?ixml))[\\l_][\\w:-]*\\>?)\":\"\\>\":\"\\[\":Warning::\n\
914 	doctype delims:\"\\1\":\"&\"::Keyword:doctype:C\n\
915 	doctype root element:\"\\2\":::Identifier:doctype:C\n\
916 	doctype keyword:\"(SYSTEM|PUBLIC)\":::Keyword:doctype:\n\
917 	doctype sq string:\"'\":\"'\":\"\\n\\n\":String1:doctype:\n\
918 	doctype dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:doctype:\n\
919 	processing instruction:\"\\<\\?\\S+\":\"\\?\\>\"::Preprocessor::\n\
920 	processing instruction attribute:\"[\\l_][\\w:-]*=((\"\"[^\"\"]*\"\")|('[^']*'))\":::Preprocessor:processing instruction:\n\
921 	processing instruction value:\"\\1\":::String:processing instruction attribute:C\n\
922 	cdata:\"\\<!\\[(?icdata)\\[\":\"\\]\\]\\>\"::Text Comment::\n\
923 	cdata delims:\"&\":\"&\"::Preprocessor:cdata:C\n\
924 	element declaration:\"\\<!ELEMENT\":\"\\>\"::Warning::\n\
925 	element declaration delims:\"&\":\"&\"::Keyword:element declaration:C\n\
926 	element declaration entity ref:\"%(?!(?ixml))[\\l_][\\w:-]*;\":::Identifier1:element declaration:\n\
927 	element declaration keyword:\"(?<!\\Y)(ANY|#PCDATA|EMPTY)>\":::Storage Type:element declaration:\n\
928 	element declaration name:\"<(?!(?ixml))[\\l_][\\w:-]*\":::Identifier:element declaration:\n\
929 	element declaration operator:\"[(),?*+|]\":::Keyword:element declaration:\n\
930 	entity declaration:\"\\<!ENTITY\":\"\\>\"::Warning::\n\
931 	entity declaration delims:\"&\":\"&\"::Keyword:entity declaration:C\n\
932 	entity declaration sq string:\"'\":\"'\":\"\\n\\n\":String1:entity declaration:\n\
933 	entity declaration sq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:entity declaration sq string:\n\
934 	entity declaration dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:entity declaration:\n\
935 	entity declaration dq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:entity declaration dq string:\n\
936 	entity declaration keyword:\"SYSTEM|NDATA\":::Keyword:entity declaration:\n\
937 	entity declaration name:\"<(?!(?ixml))[\\l_][\\w:-]*\":::Identifier:entity declaration:\n\
938 	parameter entity declaration:\"%\\s+((?!(?ixml))[\\l_][\\w:-]*)>\":::Keyword:entity declaration:\n\
939 	parameter entity name:\"\\1\":::Identifier:parameter entity declaration:C\n\
940 	notation:\"\\<!NOTATION\":\"\\>\"::Warning::\n\
941 	notation delims:\"&\":\"&\"::Keyword:notation:C\n\
942 	notation sq string:\"'\":\"'\":\"\\n\\n\":String1:notation:\n\
943 	notation sq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:notation sq string:\n\
944 	notation dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:notation:\n\
945 	notation dq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:notation dq string:\n\
946 	notation keyword:\"SYSTEM\":::Keyword:notation:\n\
947 	notation name:\"<(?!(?ixml))[\\l_][\\w:-]*\":::Identifier:notation:\n\
948 	attribute declaration:\"\\<!ATTLIST\":\"\\>\"::Warning::\n\
949 	attribute declaration delims:\"&\":\"&\"::Keyword:attribute declaration:C\n\
950 	attribute declaration sq string:\"'\":\"'\":\"\\n\\n\":String1:attribute declaration:\n\
951 	attribute declaration sq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:attribute declaration sq string:\n\
952 	attribute declaration dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:attribute declaration:\n\
953 	attribute declaration dq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:attribute declaration dq string:\n\
954 	attribute declaration namespace:\"(?ixmlns)(:[\\l_][\\w:]*)?\":::Preprocessor:attribute declaration:\n\
955 	attribute declaration default modifier:\"#(REQUIRED|IMPLIED|FIXED)>\":::Keyword:attribute declaration:\n\
956 	attribute declaration data type:\"<(CDATA|ENTIT(Y|IES)|ID(REFS?)?|NMTOKENS?|NOTATION)>\":::Storage Type:attribute declaration:\n\
957 	attribute declaration name:\"<(?!(?ixml))[\\l_][\\w:-]*\":::Identifier:attribute declaration:\n\
958 	attribute declaration operator:\"[(),?*+|]\":::Keyword:attribute declaration:\n\
959 	element:\"(\\</?)((?!(?ixml))[\\l_][\\w:-]*)\":\"/?\\>\"::Warning::\n\
960 	element delims:\"\\1\":\"&\"::Keyword:element:C\n\
961 	element name:\"\\2\":::Identifier:element:C\n\
962 	element assign:\"=\":::Keyword:element:\n\
963 	element reserved attribute:\"(?ixml:(lang|space|link|attribute))(?==)\":::Text Key:element:\n\
964 	element namespace:\"(?ixmlns:[\\l_]\\w*)(?==)\":::Preprocessor:element:\n\
965 	element attribute:\"[\\l_][\\w:-]*(?==)\":::Text Key1:element:\n\
966 	element sq string:\"'\":\"'\":\"\\n\\n\":String1:element:\n\
967 	element sq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:element sq string:\n\
968 	element dq string:\"\"\"\":\"\"\"\":\"\\n\\n\":String:element:\n\
969 	element dq string entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape:element dq string:\n\
970 	entity:\"&((amp|lt|gt|quot|apos)|#x[\\da-fA-F]*|[\\l_]\\w*);\":::Text Escape::\n\
971 	marked section:\"\\<!\\[\\s*(?:INCLUDE|(%(?!(?ixml))[\\l_][\\w:-]*;))\\s*\\[|\\]\\]\\>\":::Label::\n\
972 	marked section entity ref:\"\\1\":::Identifier:marked section:C\n\
973 	internal subset delims:\"[\\[\\]>]\":::Keyword::D\n\
974 	info:\"(?# version 0.1; author/maintainer: Joor Loohuis, joor@loohuis-consulting.nl)\":::Comment::D}",
975     "X Resources:2:0{\n\
976 	Preprocessor:\"^\\s*#\":\"$\"::Preprocessor::\n\
977 	Preprocessor Wrap:\"\\\\\\n\":::Preprocessor1:Preprocessor:\n\
978 	Comment:\"^\\s*!\":\"$\"::Comment::\n\
979 	Comment Wrap:\"\\\\\\n\":::Comment:Comment:\n\
980 	Resource Continued:\"^(\\s*[^:\\s]+\\s*:)(?:(\\\\.)|.)*(\\\\)\\n\":\"$\"::Plain::\n\
981 	RC Space Warning:\"\\\\\\s+$\":::Flag:Resource Continued:\n\
982 	RC Esc Chars:\"\\\\.\":::Text Arg2:Resource Continued:\n\
983 	RC Esc Chars 2:\"\\2\":\"\"::Text Arg2:Resource Continued:C\n\
984 	RC Name:\"\\1\":\"\"::Identifier:Resource Continued:C\n\
985 	RC Wrap:\"\\\\\\n\":::Text Arg1:Resource Continued:\n\
986 	RC Wrap2:\"\\3\":\"\"::Text Arg1:Resource Continued:C\n\
987 	Resource:\"^\\s*[^:\\s]+\\s*:\":\"$\"::Plain::\n\
988 	Resource Space Warning:\"\\S+\\s+$\":::Flag:Resource:\n\
989 	Resource Esc Chars:\"\\\\.\":::Text Arg2:Resource:\n\
990 	Resource Name:\"&\":\"\"::Identifier:Resource:C\n\
991 	Free Text:\"^.*$\":::Flag::}",
992     "Yacc:1:0{\n\
993 	comment:\"/\\*\":\"\\*/\"::Comment::\n\
994 	string:\"L?\"\"\":\"\"\"\":\"\\n\":String::\n\
995 	preprocessor line:\"^\\s*#\\s*(include|define|if|ifn?def|line|error|else|endif|elif|undef|pragma)>\":\"$\"::Preprocessor::\n\
996 	string escape chars:\"\\\\(.|\\n)\":::String1:string:\n\
997 	preprocessor esc chars:\"\\\\(.|\\n)\":::Preprocessor1:preprocessor line:\n\
998 	preprocessor comment:\"/\\*\":\"\\*/\"::Comment:preprocessor line:\n\
999     	preprocessor string:\"L?\"\"\":\"\"\"\":\"\\n\":Preprocessor1:preprocessor line:\n\
1000     	prepr string esc chars:\"\\\\(?:.|\\n)\":::String1:preprocessor string:\n\
1001 	character constant:\"'\":\"'\":\"[^\\\\][^']\":Character Const::\n\
1002 	numeric constant:\"(?<!\\Y)((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?(?!\\Y)\":::Numeric Const::D\n\
1003 	storage keyword:\"<(const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)>\":::Storage Type::D\n\
1004 	rule:\"^[ \\t]*[A-Za-z_][A-Za-z0-9_]*[ \\t]*:\":::Preprocessor1::D\n\
1005 	keyword:\"<(return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)>\":::Keyword::D\n\
1006 	yacc keyword:\"<(error|YYABORT|YYACCEPT|YYBACKUP|YYERROR|YYINITDEPTH|YYLTYPE|YYMAXDEPTH|YYRECOVERING|YYSTYPE|yychar|yyclearin|yydebug|yyerrok|yyerror|yylex|yylval|yylloc|yynerrs|yyparse)>\":::Text Arg::D\n\
1007 	percent keyword:\"(?<!\\Y)(%left|%nonassoc|%prec|%right|%start|%token|%type|%union)>([ \\t]*\\<.*\\>)?\":::Text Arg::D\n\
1008 	braces:\"[{}]\":::Keyword::D\n\
1009 	markers:\"(?<!\\Y)(%\\{|%\\}|%%)(?!\\Y)\":::Flag::D\n\
1010 	percent sub-expr:\"\\2\":::Text Arg2:percent keyword:DC}"
1011 };
1012 
1013 
1014 /*
1015 ** Read a string (from the  value of the styles resource) containing highlight
1016 ** styles information, parse it, and load it into the stored highlight style
1017 ** list (HighlightStyles) for this NEdit session.
1018 */
LoadStylesString(char * inString)1019 int LoadStylesString(char *inString)
1020 {
1021     char *errMsg, *fontStr;
1022     char *inPtr = inString;
1023     highlightStyleRec *hs;
1024     int i;
1025 
1026     for (;;) {
1027 
1028 	/* skip over blank space */
1029 	inPtr += strspn(inPtr, " \t");
1030 
1031 	/* Allocate a language mode structure in which to store the info. */
1032 	hs = (highlightStyleRec *)NEditMalloc(sizeof(highlightStyleRec));
1033 
1034 	/* read style name */
1035 	hs->name = ReadSymbolicField(&inPtr);
1036 	if (hs->name == NULL)
1037     	    return styleError(inString,inPtr, "style name required");
1038 	if (!SkipDelimiter(&inPtr, &errMsg)) {
1039 	    NEditFree(hs->name);
1040 	    NEditFree(hs);
1041     	    return styleError(inString,inPtr, errMsg);
1042     	}
1043 
1044     	/* read color */
1045 	hs->color = ReadSymbolicField(&inPtr);
1046 	if (hs->color == NULL) {
1047 	    NEditFree(hs->name);
1048 	    NEditFree(hs);
1049     	    return styleError(inString,inPtr, "color name required");
1050 	}
1051         hs->bgColor = NULL;
1052         if (SkipOptSeparator('/', &inPtr)) {
1053     	    /* read bgColor */
1054 	    hs->bgColor = ReadSymbolicField(&inPtr); /* no error if fails */
1055     	}
1056 	if (!SkipDelimiter(&inPtr, &errMsg)) {
1057 	    freeHighlightStyleRec(hs);
1058     	    return styleError(inString,inPtr, errMsg);
1059     	}
1060 
1061 	/* read the font type */
1062 	fontStr = ReadSymbolicField(&inPtr);
1063 	for (i=0; i<N_FONT_TYPES; i++) {
1064 	    if (!strcmp(FontTypeNames[i], fontStr)) {
1065 	    	hs->font = i;
1066 	    	break;
1067 	    }
1068 	}
1069 	if (i == N_FONT_TYPES) {
1070 	    NEditFree(fontStr);
1071 	    freeHighlightStyleRec(hs);
1072 	    return styleError(inString, inPtr, "unrecognized font type");
1073 	}
1074 	NEditFree(fontStr);
1075 
1076    	/* pattern set was read correctly, add/change it in the list */
1077    	for (i=0; i<NHighlightStyles; i++) {
1078 	    if (!strcmp(HighlightStyles[i]->name, hs->name)) {
1079 		freeHighlightStyleRec(HighlightStyles[i]);
1080 		HighlightStyles[i] = hs;
1081 		break;
1082 	    }
1083 	}
1084 	if (i == NHighlightStyles) {
1085 	    HighlightStyles[NHighlightStyles++] = hs;
1086    	    if (NHighlightStyles > MAX_HIGHLIGHT_STYLES)
1087    		return styleError(inString, inPtr,
1088    	    		"maximum allowable number of styles exceeded");
1089 	}
1090 
1091     	/* if the string ends here, we're done */
1092    	inPtr += strspn(inPtr, " \t\n");
1093     	if (*inPtr == '\0')
1094     	    return True;
1095     }
1096 }
1097 
1098 /*
1099 ** Create a string in the correct format for the styles resource, containing
1100 ** all of the highlight styles information from the stored highlight style
1101 ** list (HighlightStyles) for this NEdit session.
1102 */
WriteStylesString(void)1103 char *WriteStylesString(void)
1104 {
1105     int i;
1106     char *outStr;
1107     textBuffer *outBuf;
1108     highlightStyleRec *style;
1109 
1110     outBuf = BufCreate();
1111     for (i=0; i<NHighlightStyles; i++) {
1112     	style = HighlightStyles[i];
1113     	BufInsert(outBuf, outBuf->length, "\t");
1114     	BufInsert(outBuf, outBuf->length, style->name);
1115     	BufInsert(outBuf, outBuf->length, ":");
1116     	BufInsert(outBuf, outBuf->length, style->color);
1117         if (style->bgColor) {
1118             BufInsert(outBuf, outBuf->length, "/");
1119             BufInsert(outBuf, outBuf->length, style->bgColor);
1120         }
1121     	BufInsert(outBuf, outBuf->length, ":");
1122     	BufInsert(outBuf, outBuf->length, FontTypeNames[style->font]);
1123     	BufInsert(outBuf, outBuf->length, "\\n\\\n");
1124     }
1125 
1126     /* Get the output, and lop off the trailing newlines */
1127     outStr = BufGetRange(outBuf, 0, outBuf->length - (i==1?0:4));
1128     BufFree(outBuf);
1129     return outStr;
1130 }
1131 
1132 /*
1133 ** Read a string representing highlight pattern sets and add them
1134 ** to the PatternSets list of loaded highlight patterns.  Note that the
1135 ** patterns themselves are not parsed until they are actually used.
1136 **
1137 ** The argument convertOld, reads patterns in pre 5.1 format (which means
1138 ** that they may contain regular expressions are of the older syntax where
1139 ** braces were not quoted, and \0 was a legal substitution character).
1140 */
LoadHighlightString(char * inString,int convertOld)1141 int LoadHighlightString(char *inString, int convertOld)
1142 {
1143     char *inPtr = inString;
1144     patternSet *patSet;
1145     int i;
1146 
1147     for (;;) {
1148 
1149    	/* Read each pattern set, abort on error */
1150    	patSet = readPatternSet(&inPtr, convertOld);
1151    	if (patSet == NULL)
1152    	    return False;
1153 
1154 	/* Add/change the pattern set in the list */
1155 	for (i=0; i<NPatternSets; i++) {
1156 	    if (!strcmp(PatternSets[i]->languageMode, patSet->languageMode)) {
1157 		freePatternSet(PatternSets[i]);
1158 		PatternSets[i] = patSet;
1159 		break;
1160 	    }
1161 	}
1162 	if (i == NPatternSets) {
1163 	    PatternSets[NPatternSets++] = patSet;
1164    	    if (NPatternSets > MAX_LANGUAGE_MODES)
1165    		return False;
1166 	}
1167 
1168     	/* if the string ends here, we're done */
1169    	inPtr += strspn(inPtr, " \t\n");
1170     	if (*inPtr == '\0')
1171     	    return True;
1172     }
1173 }
1174 
1175 /*
1176 ** Create a string in the correct format for the highlightPatterns resource,
1177 ** containing all of the highlight pattern information from the stored
1178 ** highlight pattern list (PatternSets) for this NEdit session.
1179 */
WriteHighlightString(void)1180 char *WriteHighlightString(void)
1181 {
1182     char *outStr, *str, *escapedStr;
1183     textBuffer *outBuf;
1184     int psn, written = False;
1185     patternSet *patSet;
1186 
1187     outBuf = BufCreate();
1188     for (psn=0; psn<NPatternSets; psn++) {
1189     	patSet = PatternSets[psn];
1190     	if (patSet->nPatterns == 0)
1191     	    continue;
1192     	written = True;
1193     	BufInsert(outBuf, outBuf->length, patSet->languageMode);
1194     	BufInsert(outBuf, outBuf->length, ":");
1195     	if (isDefaultPatternSet(patSet))
1196     	    BufInsert(outBuf, outBuf->length, "Default\n\t");
1197     	else {
1198     	    BufInsert(outBuf, outBuf->length, intToStr(patSet->lineContext));
1199     	    BufInsert(outBuf, outBuf->length, ":");
1200     	    BufInsert(outBuf, outBuf->length, intToStr(patSet->charContext));
1201     	    BufInsert(outBuf, outBuf->length, "{\n");
1202     	    BufInsert(outBuf, outBuf->length,
1203     	    	    str = createPatternsString(patSet, "\t\t"));
1204     	    NEditFree(str);
1205     	    BufInsert(outBuf, outBuf->length, "\t}\n\t");
1206     	}
1207     }
1208 
1209     /* Get the output string, and lop off the trailing newline and tab */
1210     outStr = BufGetRange(outBuf, 0, outBuf->length - (written?2:0));
1211     BufFree(outBuf);
1212 
1213     /* Protect newlines and backslashes from translation by the resource
1214        reader */
1215     escapedStr = EscapeSensitiveChars(outStr);
1216     NEditFree(outStr);
1217     return escapedStr;
1218 }
1219 
1220 /*
1221 ** Update regular expressions in stored pattern sets to version 5.1 regular
1222 ** expression syntax, in which braces and \0 have different meanings
1223 */
convertOldPatternSet(patternSet * patSet)1224 static void convertOldPatternSet(patternSet *patSet)
1225 {
1226     int p;
1227     highlightPattern *pattern;
1228 
1229     for (p=0; p<patSet->nPatterns; p++) {
1230 	pattern = &patSet->patterns[p];
1231 	convertPatternExpr(&pattern->startRE, patSet->languageMode,
1232 		pattern->name, pattern->flags & COLOR_ONLY);
1233 	convertPatternExpr(&pattern->endRE, patSet->languageMode,
1234 		pattern->name, pattern->flags & COLOR_ONLY);
1235 	convertPatternExpr(&pattern->errorRE, patSet->languageMode,
1236 		pattern->name, pattern->flags & COLOR_ONLY);
1237     }
1238 }
1239 
1240 /*
1241 ** Convert a single regular expression, patternRE, to version 5.1 regular
1242 ** expression syntax.  It will convert either a match expression or a
1243 ** substitution expression, which must be specified by the setting of
1244 ** isSubsExpr.  Error messages are directed to stderr, and include the
1245 ** pattern set name and pattern name as passed in patSetName and patName.
1246 */
convertPatternExpr(char ** patternRE,char * patSetName,char * patName,int isSubsExpr)1247 static void convertPatternExpr(char **patternRE, char *patSetName,
1248 	char *patName, int isSubsExpr)
1249 {
1250     char *newRE, *errorText;
1251 
1252     if (*patternRE == NULL)
1253 	return;
1254     if (isSubsExpr) {
1255 	newRE = (char*)NEditMalloc(strlen(*patternRE) + 5000);
1256 	ConvertSubstituteRE(*patternRE, newRE, strlen(*patternRE) + 5000);
1257 	NEditFree(*patternRE);
1258 	*patternRE = NEditStrdup(newRE);
1259 	NEditFree(newRE);
1260     } else{
1261 	newRE = ConvertRE(*patternRE, &errorText);
1262 	if (newRE == NULL) {
1263 	    fprintf(stderr, "NEdit error converting old format regular "
1264 		    "expression in pattern set %s, pattern %s: %s\n",
1265 		    patSetName, patName, errorText);
1266 	}
1267 	NEditFree(*patternRE);
1268 	*patternRE = newRE;
1269     }
1270 }
1271 
1272 /*
1273 ** Find the font (font struct) associated with a named style.
1274 ** This routine must only be called with a valid styleName (call
1275 ** NamedStyleExists to find out whether styleName is valid).
1276 */
FontOfNamedStyle(WindowInfo * window,const char * styleName)1277 XFontStruct *FontOfNamedStyle(WindowInfo *window, const char *styleName)
1278 {
1279     int styleNo=lookupNamedStyle(styleName),fontNum;
1280     XFontStruct *font;
1281 
1282     if (styleNo<0)
1283         return GetDefaultFontStruct(TheDisplay, window->fontList);
1284     fontNum = HighlightStyles[styleNo]->font;
1285     if (fontNum == BOLD_FONT)
1286     	font = window->boldFontStruct;
1287     else if (fontNum == ITALIC_FONT)
1288     	font = window->italicFontStruct;
1289     else if (fontNum == BOLD_ITALIC_FONT)
1290     	font = window->boldItalicFontStruct;
1291     else /* fontNum == PLAIN_FONT */
1292     	font = GetDefaultFontStruct(TheDisplay, window->fontList);
1293 
1294     /* If font isn't loaded, silently substitute primary font */
1295     return font == NULL ? GetDefaultFontStruct(TheDisplay, window->fontList) : font;
1296 }
1297 
FontOfNamedStyleIsBold(char * styleName)1298 int FontOfNamedStyleIsBold(char *styleName)
1299 {
1300     int styleNo=lookupNamedStyle(styleName),fontNum;
1301 
1302     if (styleNo<0)
1303         return 0;
1304     fontNum = HighlightStyles[styleNo]->font;
1305     return (fontNum == BOLD_FONT || fontNum == BOLD_ITALIC_FONT);
1306 }
1307 
FontOfNamedStyleIsItalic(char * styleName)1308 int FontOfNamedStyleIsItalic(char *styleName)
1309 {
1310     int styleNo=lookupNamedStyle(styleName),fontNum;
1311 
1312     if (styleNo<0)
1313         return 0;
1314     fontNum = HighlightStyles[styleNo]->font;
1315     return (fontNum == ITALIC_FONT || fontNum == BOLD_ITALIC_FONT);
1316 }
1317 
1318 /*
1319 ** Find the color associated with a named style.  This routine must only be
1320 ** called with a valid styleName (call NamedStyleExists to find out whether
1321 ** styleName is valid).
1322 */
ColorOfNamedStyle(const char * styleName)1323 char *ColorOfNamedStyle(const char *styleName)
1324 {
1325     int styleNo=lookupNamedStyle(styleName);
1326 
1327     if (styleNo<0)
1328         return "black";
1329     return HighlightStyles[styleNo]->color;
1330 }
1331 
1332 /*
1333 ** Find the background color associated with a named style.
1334 */
BgColorOfNamedStyle(const char * styleName)1335 char *BgColorOfNamedStyle(const char *styleName)
1336 {
1337     int styleNo=lookupNamedStyle(styleName);
1338 
1339     if (styleNo<0)
1340         return "";
1341     return HighlightStyles[styleNo]->bgColor;
1342 }
1343 
1344 /*
1345 ** Determine whether a named style exists
1346 */
NamedStyleExists(const char * styleName)1347 int NamedStyleExists(const char *styleName)
1348 {
1349     return lookupNamedStyle(styleName) != -1;
1350 }
1351 
1352 /*
1353 ** Look through the list of pattern sets, and find the one for a particular
1354 ** language.  Returns NULL if not found.
1355 */
FindPatternSet(const char * langModeName)1356 patternSet *FindPatternSet(const char *langModeName)
1357 {
1358     int i;
1359 
1360     if (langModeName == NULL)
1361     	return NULL;
1362 
1363     for (i=0; i<NPatternSets; i++)
1364     	if (!strcmp(langModeName, PatternSets[i]->languageMode))
1365     	    return PatternSets[i];
1366     return NULL;
1367 
1368 }
1369 
1370 /*
1371 ** Returns True if there are highlight patterns, or potential patterns
1372 ** not yet committed in the syntax highlighting dialog for a language mode,
1373 */
LMHasHighlightPatterns(const char * languageMode)1374 int LMHasHighlightPatterns(const char *languageMode)
1375 {
1376     if (FindPatternSet(languageMode) != NULL)
1377     	return True;
1378     return HighlightDialog.shell!=NULL && !strcmp(HighlightDialog.langModeName,
1379     	    languageMode) && HighlightDialog.nPatterns != 0;
1380 }
1381 
1382 /*
1383 ** Change the language mode name of pattern sets for language "oldName" to
1384 ** "newName" in both the stored patterns, and the pattern set currently being
1385 ** edited in the dialog.
1386 */
RenameHighlightPattern(const char * oldName,const char * newName)1387 void RenameHighlightPattern(const char *oldName, const char *newName)
1388 {
1389     int i;
1390 
1391     for (i=0; i<NPatternSets; i++) {
1392     	if (!strcmp(oldName, PatternSets[i]->languageMode)) {
1393     	    NEditFree(PatternSets[i]->languageMode);
1394     	    PatternSets[i]->languageMode = NEditStrdup(newName);
1395     	}
1396     }
1397     if (HighlightDialog.shell != NULL) {
1398     	if (!strcmp(HighlightDialog.langModeName, oldName)) {
1399     	    NEditFree(HighlightDialog.langModeName);
1400     	    HighlightDialog.langModeName = NEditStrdup(newName);
1401     	}
1402     }
1403 }
1404 
1405 /*
1406 ** Create a pulldown menu pane with the names of the current highlight styles.
1407 ** XmNuserData for each item contains a pointer to the name.
1408 */
createHighlightStylesMenu(Widget parent)1409 static Widget createHighlightStylesMenu(Widget parent)
1410 {
1411     Widget menu;
1412     int i;
1413     XmString s1;
1414 
1415     menu = CreatePulldownMenu(parent, "highlightStyles", NULL, 0);
1416     for (i=0; i<NHighlightStyles; i++) {
1417         XtVaCreateManagedWidget("highlightStyles", xmPushButtonWidgetClass,menu,
1418     	      XmNlabelString, s1=XmStringCreateSimple(HighlightStyles[i]->name),
1419     	      XmNuserData, (void *)HighlightStyles[i]->name, NULL);
1420         XmStringFree(s1);
1421     }
1422     return menu;
1423 }
1424 
createPatternsString(patternSet * patSet,char * indentStr)1425 static char *createPatternsString(patternSet *patSet, char *indentStr)
1426 {
1427     char *outStr, *str;
1428     textBuffer *outBuf;
1429     int pn;
1430     highlightPattern *pat;
1431 
1432     outBuf = BufCreate();
1433     for (pn=0; pn<patSet->nPatterns; pn++) {
1434     	pat = &patSet->patterns[pn];
1435     	BufInsert(outBuf, outBuf->length, indentStr);
1436     	BufInsert(outBuf, outBuf->length, pat->name);
1437     	BufInsert(outBuf, outBuf->length, ":");
1438     	if (pat->startRE != NULL) {
1439     	    BufInsert(outBuf, outBuf->length,
1440     	    	    str=MakeQuotedString(pat->startRE));
1441     	    NEditFree(str);
1442     	}
1443     	BufInsert(outBuf, outBuf->length, ":");
1444     	if (pat->endRE != NULL) {
1445     	    BufInsert(outBuf, outBuf->length, str=MakeQuotedString(pat->endRE));
1446     	    NEditFree(str);
1447     	}
1448     	BufInsert(outBuf, outBuf->length, ":");
1449     	if (pat->errorRE != NULL) {
1450     	    BufInsert(outBuf, outBuf->length,
1451     	    	    str=MakeQuotedString(pat->errorRE));
1452     	    NEditFree(str);
1453     	}
1454     	BufInsert(outBuf, outBuf->length, ":");
1455     	BufInsert(outBuf, outBuf->length, pat->style);
1456     	BufInsert(outBuf, outBuf->length, ":");
1457     	if (pat->subPatternOf != NULL)
1458     	    BufInsert(outBuf, outBuf->length, pat->subPatternOf);
1459     	BufInsert(outBuf, outBuf->length, ":");
1460     	if (pat->flags & DEFER_PARSING)
1461     	    BufInsert(outBuf, outBuf->length, "D");
1462     	if (pat->flags & PARSE_SUBPATS_FROM_START)
1463     	    BufInsert(outBuf, outBuf->length, "R");
1464     	if (pat->flags & COLOR_ONLY)
1465     	    BufInsert(outBuf, outBuf->length, "C");
1466     	BufInsert(outBuf, outBuf->length, "\n");
1467     }
1468     outStr = BufGetAll(outBuf);
1469     BufFree(outBuf);
1470     return outStr;
1471 }
1472 
1473 /*
1474 ** Read in a pattern set character string, and advance *inPtr beyond it.
1475 ** Returns NULL and outputs an error to stderr on failure.
1476 */
readPatternSet(char ** inPtr,int convertOld)1477 static patternSet *readPatternSet(char **inPtr, int convertOld)
1478 {
1479     char *errMsg, *stringStart = *inPtr;
1480     patternSet patSet, *retPatSet;
1481 
1482     /* remove leading whitespace */
1483     *inPtr += strspn(*inPtr, " \t\n");
1484 
1485     /* read language mode field */
1486     patSet.languageMode = ReadSymbolicField(inPtr);
1487     if (patSet.languageMode == NULL)
1488     	return highlightError(stringStart, *inPtr,
1489     	    	"language mode must be specified");
1490     if (!SkipDelimiter(inPtr, &errMsg))
1491     	return highlightError(stringStart, *inPtr, errMsg);
1492 
1493     /* look for "Default" keyword, and if it's there, return the default
1494        pattern set */
1495     if (!strncmp(*inPtr, "Default", 7)) {
1496     	*inPtr += 7;
1497     	retPatSet = readDefaultPatternSet(patSet.languageMode);
1498     	NEditFree(patSet.languageMode);
1499     	if (retPatSet == NULL)
1500     	    return highlightError(stringStart, *inPtr,
1501     	    	    "No default pattern set");
1502     	return retPatSet;
1503     }
1504 
1505     /* read line context field */
1506     if (!ReadNumericField(inPtr, &patSet.lineContext))
1507 	return highlightError(stringStart, *inPtr,
1508 	    	"unreadable line context field");
1509     if (!SkipDelimiter(inPtr, &errMsg))
1510     	return highlightError(stringStart, *inPtr, errMsg);
1511 
1512     /* read character context field */
1513     if (!ReadNumericField(inPtr, &patSet.charContext))
1514 	return highlightError(stringStart, *inPtr,
1515 	    	"unreadable character context field");
1516 
1517     /* read pattern list */
1518     patSet.patterns = readHighlightPatterns(inPtr,
1519    	    True, &errMsg, &patSet.nPatterns);
1520     if (patSet.patterns == NULL)
1521 	return highlightError(stringStart, *inPtr, errMsg);
1522 
1523     /* pattern set was read correctly, make an allocated copy to return */
1524     retPatSet = (patternSet *)NEditMalloc(sizeof(patternSet));
1525     memcpy(retPatSet, &patSet, sizeof(patternSet));
1526 
1527     /* Convert pre-5.1 pattern sets which use old regular expression
1528        syntax to quote braces and use & rather than \0 */
1529     if (convertOld)
1530     	convertOldPatternSet(retPatSet);
1531 
1532     return retPatSet;
1533 }
1534 
1535 /*
1536 ** Parse a set of highlight patterns into an array of highlightPattern
1537 ** structures, and a language mode name.  If unsuccessful, returns NULL with
1538 ** (statically allocated) message in "errMsg".
1539 */
readHighlightPatterns(char ** inPtr,int withBraces,char ** errMsg,int * nPatterns)1540 static highlightPattern *readHighlightPatterns(char **inPtr, int withBraces,
1541     	char **errMsg, int *nPatterns)
1542 {
1543     highlightPattern *pat, *returnedList, patternList[MAX_PATTERNS];
1544 
1545     /* skip over blank space */
1546     *inPtr += strspn(*inPtr, " \t\n");
1547 
1548     /* look for initial brace */
1549     if (withBraces) {
1550 	if (**inPtr != '{') {
1551     	    *errMsg = "pattern list must begin with \"{\"";
1552     	    return False;
1553 	}
1554 	(*inPtr)++;
1555     }
1556 
1557     /*
1558     ** parse each pattern in the list
1559     */
1560     pat = patternList;
1561     while (True) {
1562     	*inPtr += strspn(*inPtr, " \t\n");
1563     	if (**inPtr == '\0') {
1564     	    if (withBraces) {
1565     		*errMsg = "end of pattern list not found";
1566     		return NULL;
1567     	    } else
1568     	    	break;
1569 	} else if (**inPtr == '}') {
1570 	    (*inPtr)++;
1571     	    break;
1572     	}
1573     	if (pat - patternList >= MAX_PATTERNS) {
1574     	    *errMsg = "max number of patterns exceeded\n";
1575     	    return NULL;
1576     	}
1577     	if (!readHighlightPattern(inPtr, errMsg, pat++))
1578     	    return NULL;
1579     }
1580 
1581     /* allocate a more appropriately sized list to return patterns */
1582     *nPatterns = pat - patternList;
1583     returnedList = (highlightPattern *)NEditMalloc(
1584     	    sizeof(highlightPattern) * *nPatterns);
1585     memcpy(returnedList, patternList, sizeof(highlightPattern) * *nPatterns);
1586     return returnedList;
1587 }
1588 
readHighlightPattern(char ** inPtr,char ** errMsg,highlightPattern * pattern)1589 static int readHighlightPattern(char **inPtr, char **errMsg,
1590     	highlightPattern *pattern)
1591 {
1592     /* read the name field */
1593     pattern->name = ReadSymbolicField(inPtr);
1594     if (pattern->name == NULL) {
1595     	*errMsg = "pattern name is required";
1596     	return False;
1597     }
1598     if (!SkipDelimiter(inPtr, errMsg))
1599     	return False;
1600 
1601     /* read the start pattern */
1602     if (!ReadQuotedString(inPtr, errMsg, &pattern->startRE))
1603     	return False;
1604     if (!SkipDelimiter(inPtr, errMsg))
1605     	return False;
1606 
1607     /* read the end pattern */
1608     if (**inPtr == ':')
1609     	pattern->endRE = NULL;
1610     else if (!ReadQuotedString(inPtr, errMsg, &pattern->endRE))
1611     	return False;
1612     if (!SkipDelimiter(inPtr, errMsg))
1613     	return False;
1614 
1615     /* read the error pattern */
1616     if (**inPtr == ':')
1617     	pattern->errorRE = NULL;
1618     else if (!ReadQuotedString(inPtr, errMsg, &pattern->errorRE))
1619     	return False;
1620     if (!SkipDelimiter(inPtr, errMsg))
1621     	return False;
1622 
1623     /* read the style field */
1624     pattern->style = ReadSymbolicField(inPtr);
1625     if (pattern->style == NULL) {
1626     	*errMsg = "style field required in pattern";
1627     	return False;
1628     }
1629     if (!SkipDelimiter(inPtr, errMsg))
1630     	return False;
1631 
1632     /* read the sub-pattern-of field */
1633     pattern->subPatternOf = ReadSymbolicField(inPtr);
1634     if (!SkipDelimiter(inPtr, errMsg))
1635     	return False;
1636 
1637     /* read flags field */
1638     pattern->flags = 0;
1639     for (; **inPtr != '\n' && **inPtr != '}'; (*inPtr)++) {
1640 	if (**inPtr == 'D')
1641 	    pattern->flags |= DEFER_PARSING;
1642 	else if (**inPtr == 'R')
1643 	    pattern->flags |= PARSE_SUBPATS_FROM_START;
1644 	else if (**inPtr == 'C')
1645 	    pattern->flags |= COLOR_ONLY;
1646 	else if (**inPtr != ' ' && **inPtr != '\t') {
1647 	    *errMsg = "unreadable flag field";
1648 	    return False;
1649 	}
1650     }
1651     return True;
1652 }
1653 
1654 /*
1655 ** Given a language mode name, determine if there is a default (built-in)
1656 ** pattern set available for that language mode, and if so, read it and
1657 ** return a new allocated copy of it.  The returned pattern set should be
1658 ** freed by the caller with freePatternSet()
1659 */
readDefaultPatternSet(const char * langModeName)1660 static patternSet *readDefaultPatternSet(const char *langModeName)
1661 {
1662     int i;
1663     size_t modeNameLen;
1664     char *strPtr;
1665 
1666     modeNameLen = strlen(langModeName);
1667     for (i=0; i<(int)XtNumber(DefaultPatternSets); i++) {
1668     	if (!strncmp(langModeName, DefaultPatternSets[i], modeNameLen) &&
1669     	    	DefaultPatternSets[i][modeNameLen] == ':') {
1670     	    strPtr = DefaultPatternSets[i];
1671     	    return readPatternSet(&strPtr, False);
1672     	}
1673     }
1674     return NULL;
1675 }
1676 
1677 /*
1678 ** Return True if patSet exactly matches one of the default pattern sets
1679 */
isDefaultPatternSet(patternSet * patSet)1680 static int isDefaultPatternSet(patternSet *patSet)
1681 {
1682     patternSet *defaultPatSet;
1683     int retVal;
1684 
1685     defaultPatSet = readDefaultPatternSet(patSet->languageMode);
1686     if (defaultPatSet == NULL)
1687     	return False;
1688     retVal = !patternSetsDiffer(patSet, defaultPatSet);
1689     freePatternSet(defaultPatSet);
1690     return retVal;
1691 }
1692 
1693 /*
1694 ** Short-hand functions for formating and outputing errors for
1695 */
highlightError(char * stringStart,char * stoppedAt,const char * message)1696 static patternSet *highlightError(char *stringStart, char *stoppedAt,
1697     	const char *message)
1698 {
1699     ParseError(NULL, stringStart, stoppedAt, "highlight pattern", message);
1700     return NULL;
1701 }
1702 
1703 
styleError(const char * stringStart,const char * stoppedAt,const char * message)1704 static int styleError(const char *stringStart, const char *stoppedAt,
1705         const  char *message)
1706 {
1707     ParseError(NULL, stringStart, stoppedAt, "style specification", message);
1708     return False;
1709 }
1710 
1711 /*
1712 ** Present a dialog for editing highlight style information
1713 */
EditHighlightStyles(const char * initialStyle)1714 void EditHighlightStyles(const char *initialStyle)
1715 {
1716 #define HS_LIST_RIGHT 60
1717 #define HS_LEFT_MARGIN_POS 1
1718 #define HS_RIGHT_MARGIN_POS 99
1719 #define HS_H_MARGIN 10
1720     Widget form, nameLbl, topLbl, colorLbl, bgColorLbl, fontLbl;
1721     Widget fontBox, sep1, okBtn, applyBtn, closeBtn;
1722     XmString s1;
1723     int i, ac;
1724     Arg args[20];
1725 
1726     /* if the dialog is already displayed, just pop it to the top and return */
1727     if (HSDialog.shell != NULL) {
1728 	if (initialStyle != NULL)
1729 	    setStyleByName(initialStyle);
1730     	RaiseDialogWindow(HSDialog.shell);
1731     	return;
1732     }
1733 
1734     /* Copy the list of highlight style information to one that the user
1735        can freely edit (via the dialog and managed-list code) */
1736     HSDialog.highlightStyleList = (highlightStyleRec **)NEditMalloc(
1737     	    sizeof(highlightStyleRec *) * MAX_HIGHLIGHT_STYLES);
1738     for (i=0; i<NHighlightStyles; i++)
1739     	HSDialog.highlightStyleList[i] =
1740     	copyHighlightStyleRec(HighlightStyles[i]);
1741     HSDialog.nHighlightStyles = NHighlightStyles;
1742 
1743     /* Create a form widget in an application shell */
1744     ac = 0;
1745     XtSetArg(args[ac], XmNdeleteResponse, XmDO_NOTHING); ac++;
1746     XtSetArg(args[ac], XmNiconName, "NEdit Text Drawing Styles"); ac++;
1747     XtSetArg(args[ac], XmNtitle, "Text Drawing Styles"); ac++;
1748     HSDialog.shell = CreateWidget(TheAppShell, "textStyles",
1749 	    topLevelShellWidgetClass, args, ac);
1750     AddSmallIcon(HSDialog.shell);
1751     form = XtVaCreateManagedWidget("editHighlightStyles", xmFormWidgetClass,
1752 	    HSDialog.shell, XmNautoUnmanage, False,
1753 	    XmNresizePolicy, XmRESIZE_NONE, NULL);
1754     XtAddCallback(form, XmNdestroyCallback, hsDestroyCB, NULL);
1755     AddMotifCloseCallback(HSDialog.shell, hsCloseCB, NULL);
1756 
1757     topLbl = XtVaCreateManagedWidget("topLabel", xmLabelGadgetClass, form,
1758     	    XmNlabelString, s1=MKSTRING(
1759 "To modify the properties of an existing highlight style, select the name\n\
1760 from the list on the left.  Select \"New\" to add a new style to the list."),
1761 	    XmNmnemonic, 'N',
1762 	    XmNtopAttachment, XmATTACH_POSITION,
1763 	    XmNtopPosition, 2,
1764 	    XmNleftAttachment, XmATTACH_POSITION,
1765 	    XmNleftPosition, HS_LEFT_MARGIN_POS,
1766 	    XmNrightAttachment, XmATTACH_POSITION,
1767 	    XmNrightPosition, HS_RIGHT_MARGIN_POS, NULL);
1768     XmStringFree(s1);
1769 
1770     nameLbl = XtVaCreateManagedWidget("nameLbl", xmLabelGadgetClass, form,
1771     	    XmNlabelString, s1=XmStringCreateSimple("Name:"),
1772     	    XmNmnemonic, 'm',
1773     	    XmNalignment, XmALIGNMENT_BEGINNING,
1774 	    XmNleftAttachment, XmATTACH_POSITION,
1775     	    XmNleftPosition, HS_LIST_RIGHT,
1776 	    XmNtopAttachment, XmATTACH_WIDGET,
1777 	    XmNtopOffset, HS_H_MARGIN,
1778 	    XmNtopWidget, topLbl, NULL);
1779     XmStringFree(s1);
1780 
1781     HSDialog.nameW = XtVaCreateManagedWidget("name", xmTextWidgetClass, form,
1782 	    XmNleftAttachment, XmATTACH_POSITION,
1783 	    XmNleftPosition, HS_LIST_RIGHT,
1784 	    XmNtopAttachment, XmATTACH_WIDGET,
1785 	    XmNtopWidget, nameLbl,
1786 	    XmNrightAttachment, XmATTACH_POSITION,
1787 	    XmNrightPosition, HS_RIGHT_MARGIN_POS, NULL);
1788     RemapDeleteKey(HSDialog.nameW);
1789     XtVaSetValues(nameLbl, XmNuserData, HSDialog.nameW, NULL);
1790 
1791     colorLbl = XtVaCreateManagedWidget("colorLbl", xmLabelGadgetClass, form,
1792     	    XmNlabelString, s1=XmStringCreateSimple("Foreground Color:"),
1793     	    XmNmnemonic, 'C',
1794     	    XmNalignment, XmALIGNMENT_BEGINNING,
1795 	    XmNleftAttachment, XmATTACH_POSITION,
1796     	    XmNleftPosition, HS_LIST_RIGHT,
1797 	    XmNtopAttachment, XmATTACH_WIDGET,
1798 	    XmNtopOffset, HS_H_MARGIN,
1799 	    XmNtopWidget, HSDialog.nameW, NULL);
1800     XmStringFree(s1);
1801 
1802     HSDialog.colorW = XtVaCreateManagedWidget("color", xmTextWidgetClass, form,
1803 	    XmNleftAttachment, XmATTACH_POSITION,
1804 	    XmNleftPosition, HS_LIST_RIGHT,
1805 	    XmNtopAttachment, XmATTACH_WIDGET,
1806 	    XmNtopWidget, colorLbl,
1807 	    XmNrightAttachment, XmATTACH_POSITION,
1808 	    XmNrightPosition, HS_RIGHT_MARGIN_POS, NULL);
1809     RemapDeleteKey(HSDialog.colorW);
1810     XtVaSetValues(colorLbl, XmNuserData, HSDialog.colorW, NULL);
1811 
1812     bgColorLbl = XtVaCreateManagedWidget("bgColorLbl", xmLabelGadgetClass, form,
1813     	    XmNlabelString,
1814     	      s1=XmStringCreateSimple("Background Color (optional)"),
1815     	    XmNmnemonic, 'g',
1816     	    XmNalignment, XmALIGNMENT_BEGINNING,
1817 	    XmNleftAttachment, XmATTACH_POSITION,
1818     	    XmNleftPosition, HS_LIST_RIGHT,
1819 	    XmNtopAttachment, XmATTACH_WIDGET,
1820 	    XmNtopOffset, HS_H_MARGIN,
1821 	    XmNtopWidget, HSDialog.colorW, NULL);
1822     XmStringFree(s1);
1823 
1824     HSDialog.bgColorW = XtVaCreateManagedWidget("bgColor",
1825             xmTextWidgetClass, form,
1826 	    XmNleftAttachment, XmATTACH_POSITION,
1827 	    XmNleftPosition, HS_LIST_RIGHT,
1828 	    XmNtopAttachment, XmATTACH_WIDGET,
1829 	    XmNtopWidget, bgColorLbl,
1830 	    XmNrightAttachment, XmATTACH_POSITION,
1831 	    XmNrightPosition, HS_RIGHT_MARGIN_POS, NULL);
1832     RemapDeleteKey(HSDialog.bgColorW);
1833     XtVaSetValues(bgColorLbl, XmNuserData, HSDialog.bgColorW, NULL);
1834 
1835     fontLbl = XtVaCreateManagedWidget("fontLbl", xmLabelGadgetClass, form,
1836     	    XmNlabelString, s1=XmStringCreateSimple("Font:"),
1837     	    XmNalignment, XmALIGNMENT_BEGINNING,
1838 	    XmNleftAttachment, XmATTACH_POSITION,
1839     	    XmNleftPosition, HS_LIST_RIGHT,
1840 	    XmNtopAttachment, XmATTACH_WIDGET,
1841 	    XmNtopOffset, HS_H_MARGIN,
1842 	    XmNtopWidget, HSDialog.bgColorW, NULL);
1843     XmStringFree(s1);
1844 
1845     fontBox = XtVaCreateManagedWidget("fontBox", xmRowColumnWidgetClass, form,
1846     	    XmNpacking, XmPACK_COLUMN,
1847     	    XmNnumColumns, 2,
1848     	    XmNradioBehavior, True,
1849 	    XmNleftAttachment, XmATTACH_POSITION,
1850     	    XmNleftPosition, HS_LIST_RIGHT,
1851 	    XmNtopAttachment, XmATTACH_WIDGET,
1852 	    XmNtopWidget, fontLbl, NULL);
1853     HSDialog.plainW = XtVaCreateManagedWidget("plain",
1854     	    xmToggleButtonWidgetClass, fontBox,
1855     	    XmNset, True,
1856     	    XmNlabelString, s1=XmStringCreateSimple("Plain"),
1857     	    XmNmnemonic, 'P', NULL);
1858     XmStringFree(s1);
1859     HSDialog.boldW = XtVaCreateManagedWidget("bold",
1860     	    xmToggleButtonWidgetClass, fontBox,
1861     	    XmNlabelString, s1=XmStringCreateSimple("Bold"),
1862     	    XmNmnemonic, 'B', NULL);
1863     XmStringFree(s1);
1864     HSDialog.italicW = XtVaCreateManagedWidget("italic",
1865     	    xmToggleButtonWidgetClass, fontBox,
1866     	    XmNlabelString, s1=XmStringCreateSimple("Italic"),
1867     	    XmNmnemonic, 'I', NULL);
1868     XmStringFree(s1);
1869     HSDialog.boldItalicW = XtVaCreateManagedWidget("boldItalic",
1870     	    xmToggleButtonWidgetClass, fontBox,
1871     	    XmNlabelString, s1=XmStringCreateSimple("Bold Italic"),
1872     	    XmNmnemonic, 'o', NULL);
1873     XmStringFree(s1);
1874 
1875     okBtn = XtVaCreateManagedWidget("ok",xmPushButtonWidgetClass,form,
1876             XmNlabelString, s1=XmStringCreateSimple("OK"),
1877             XmNmarginWidth, BUTTON_WIDTH_MARGIN,
1878     	    XmNleftAttachment, XmATTACH_POSITION,
1879     	    XmNleftPosition, 10,
1880     	    XmNrightAttachment, XmATTACH_POSITION,
1881     	    XmNrightPosition, 30,
1882     	    XmNbottomAttachment, XmATTACH_POSITION,
1883     	    XmNbottomPosition, 99, NULL);
1884     XtAddCallback(okBtn, XmNactivateCallback, hsOkCB, NULL);
1885     XmStringFree(s1);
1886 
1887     applyBtn = XtVaCreateManagedWidget("apply",xmPushButtonWidgetClass,form,
1888     	    XmNlabelString, s1=XmStringCreateSimple("Apply"),
1889     	    XmNmnemonic, 'A',
1890     	    XmNleftAttachment, XmATTACH_POSITION,
1891     	    XmNleftPosition, 40,
1892     	    XmNrightAttachment, XmATTACH_POSITION,
1893     	    XmNrightPosition, 60,
1894     	    XmNbottomAttachment, XmATTACH_POSITION,
1895     	    XmNbottomPosition, 99, NULL);
1896     XtAddCallback(applyBtn, XmNactivateCallback, hsApplyCB, NULL);
1897     XmStringFree(s1);
1898 
1899     closeBtn = XtVaCreateManagedWidget("close",
1900             xmPushButtonWidgetClass, form,
1901     	    XmNlabelString, s1=XmStringCreateSimple("Close"),
1902     	    XmNleftAttachment, XmATTACH_POSITION,
1903     	    XmNleftPosition, 70,
1904     	    XmNrightAttachment, XmATTACH_POSITION,
1905     	    XmNrightPosition, 90,
1906     	    XmNbottomAttachment, XmATTACH_POSITION,
1907     	    XmNbottomPosition, 99,
1908             NULL);
1909     XtAddCallback(closeBtn, XmNactivateCallback, hsCloseCB, NULL);
1910     XmStringFree(s1);
1911 
1912     sep1 = XtVaCreateManagedWidget("sep1", xmSeparatorGadgetClass, form,
1913 	    XmNleftAttachment, XmATTACH_FORM,
1914 	    XmNtopAttachment, XmATTACH_WIDGET,
1915 	    XmNtopWidget, fontBox,
1916 	    XmNtopOffset, HS_H_MARGIN,
1917  	    XmNrightAttachment, XmATTACH_FORM,
1918 	    XmNbottomAttachment, XmATTACH_WIDGET,
1919     	    XmNbottomWidget, closeBtn, 0,
1920 	    XmNbottomOffset, HS_H_MARGIN, NULL);
1921 
1922     ac = 0;
1923     XtSetArg(args[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
1924     XtSetArg(args[ac], XmNtopOffset, HS_H_MARGIN); ac++;
1925     XtSetArg(args[ac], XmNtopWidget, topLbl); ac++;
1926     XtSetArg(args[ac], XmNleftAttachment, XmATTACH_POSITION); ac++;
1927     XtSetArg(args[ac], XmNleftPosition, HS_LEFT_MARGIN_POS); ac++;
1928     XtSetArg(args[ac], XmNrightAttachment, XmATTACH_POSITION); ac++;
1929     XtSetArg(args[ac], XmNrightPosition, HS_LIST_RIGHT-1); ac++;
1930     XtSetArg(args[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
1931     XtSetArg(args[ac], XmNbottomWidget, sep1); ac++;
1932     XtSetArg(args[ac], XmNbottomOffset, HS_H_MARGIN); ac++;
1933     HSDialog.managedListW = CreateManagedList(form, "list", args, ac,
1934     	    (void **)HSDialog.highlightStyleList, &HSDialog.nHighlightStyles,
1935     	    MAX_HIGHLIGHT_STYLES, 20, hsGetDisplayedCB, NULL, hsSetDisplayedCB,
1936     	    form, hsFreeItemCB);
1937     XtVaSetValues(topLbl, XmNuserData, HSDialog.managedListW, NULL);
1938 
1939     /* Set initial default button */
1940     XtVaSetValues(form, XmNdefaultButton, okBtn, NULL);
1941     XtVaSetValues(form, XmNcancelButton, closeBtn, NULL);
1942 
1943     /* If there's a suggestion for an initial selection, make it */
1944     if (initialStyle != NULL)
1945 	setStyleByName(initialStyle);
1946 
1947     /* Handle mnemonic selection of buttons and focus to dialog */
1948     AddDialogMnemonicHandler(form, FALSE);
1949 
1950     /* Realize all of the widgets in the new dialog */
1951     RealizeWithoutForcingPosition(HSDialog.shell);
1952 }
1953 
hsDestroyCB(Widget w,XtPointer clientData,XtPointer callData)1954 static void hsDestroyCB(Widget w, XtPointer clientData, XtPointer callData)
1955 {
1956     int i;
1957 
1958     for (i=0; i<HSDialog.nHighlightStyles; i++)
1959     	freeHighlightStyleRec(HSDialog.highlightStyleList[i]);
1960     NEditFree(HSDialog.highlightStyleList);
1961 }
1962 
hsOkCB(Widget w,XtPointer clientData,XtPointer callData)1963 static void hsOkCB(Widget w, XtPointer clientData, XtPointer callData)
1964 {
1965     if (!updateHSList())
1966     	return;
1967 
1968     /* pop down and destroy the dialog */
1969     XtDestroyWidget(HSDialog.shell);
1970     HSDialog.shell = NULL;
1971 }
1972 
hsApplyCB(Widget w,XtPointer clientData,XtPointer callData)1973 static void hsApplyCB(Widget w, XtPointer clientData, XtPointer callData)
1974 {
1975     updateHSList();
1976 }
1977 
hsCloseCB(Widget w,XtPointer clientData,XtPointer callData)1978 static void hsCloseCB(Widget w, XtPointer clientData, XtPointer callData)
1979 {
1980     /* pop down and destroy the dialog */
1981     XtDestroyWidget(HSDialog.shell);
1982     HSDialog.shell = NULL;
1983 }
1984 
hsGetDisplayedCB(void * oldItem,int explicitRequest,int * abort,void * cbArg)1985 static void *hsGetDisplayedCB(void *oldItem, int explicitRequest, int *abort,
1986     	void *cbArg)
1987 {
1988     highlightStyleRec *hs;
1989 
1990     /* If the dialog is currently displaying the "new" entry and the
1991        fields are empty, that's just fine */
1992     if (oldItem == NULL && hsDialogEmpty())
1993     	return NULL;
1994 
1995     /* If there are no problems reading the data, just return it */
1996     hs = readHSDialogFields(True);
1997     if (hs != NULL)
1998     	return (void *)hs;
1999 
2000     /* If there are problems, and the user didn't ask for the fields to be
2001        read, give more warning */
2002     if (!explicitRequest)
2003     {
2004         if (DialogF(DF_WARN, HSDialog.shell, 2, "Incomplete Style",
2005                 "Discard incomplete entry\nfor current highlight style?",
2006                 "Keep", "Discard") == 2)
2007         {
2008             return oldItem == NULL
2009                     ? NULL
2010                     : (void *)copyHighlightStyleRec((highlightStyleRec *)oldItem);
2011         }
2012     }
2013 
2014     /* Do readHSDialogFields again without "silent" mode to display warning */
2015     hs = readHSDialogFields(False);
2016     *abort = True;
2017     return NULL;
2018 }
2019 
hsSetDisplayedCB(void * item,void * cbArg)2020 static void hsSetDisplayedCB(void *item, void *cbArg)
2021 {
2022     highlightStyleRec *hs = (highlightStyleRec *)item;
2023 
2024     if (item == NULL) {
2025     	XmTextSetString(HSDialog.nameW, "");
2026     	XmTextSetString(HSDialog.colorW, "");
2027     	XmTextSetString(HSDialog.bgColorW, "");
2028     	RadioButtonChangeState(HSDialog.plainW, True, False);
2029     	RadioButtonChangeState(HSDialog.boldW, False, False);
2030     	RadioButtonChangeState(HSDialog.italicW, False, False);
2031     	RadioButtonChangeState(HSDialog.boldItalicW, False, False);
2032     } else {
2033         if (strcmp(hs->name, "Plain") == 0) {
2034             /* you should not be able to delete the reserved style "Plain" */
2035             int i, others = 0;
2036             int nList = HSDialog.nHighlightStyles;
2037             highlightStyleRec **list = HSDialog.highlightStyleList;
2038             /* do we have other styles called Plain? */
2039             for (i = 0; i < nList; i++) {
2040                 if (list[i] != hs && strcmp(list[i]->name, "Plain") == 0) {
2041                       others++;
2042                 }
2043             }
2044             if (others == 0) {
2045                 /* this is the last style entry named "Plain" */
2046                 Widget form = (Widget)cbArg;
2047                 Widget deleteBtn = XtNameToWidget(form, "*delete");
2048                 /* disable delete button */
2049                 if (deleteBtn) {
2050                     XtSetSensitive(deleteBtn, False);
2051                 }
2052             }
2053         }
2054     	XmTextSetString(HSDialog.nameW, hs->name);
2055     	XmTextSetString(HSDialog.colorW, hs->color);
2056     	XmTextSetString(HSDialog.bgColorW, hs->bgColor ? hs->bgColor : "");
2057     	RadioButtonChangeState(HSDialog.plainW, hs->font==PLAIN_FONT, False);
2058     	RadioButtonChangeState(HSDialog.boldW, hs->font==BOLD_FONT, False);
2059     	RadioButtonChangeState(HSDialog.italicW, hs->font==ITALIC_FONT, False);
2060     	RadioButtonChangeState(HSDialog.boldItalicW, hs->font==BOLD_ITALIC_FONT,
2061     	        False);
2062     }
2063 }
2064 
hsFreeItemCB(void * item)2065 static void hsFreeItemCB(void *item)
2066 {
2067     freeHighlightStyleRec((highlightStyleRec *)item);
2068 }
2069 
readHSDialogFields(int silent)2070 static highlightStyleRec *readHSDialogFields(int silent)
2071 {
2072     highlightStyleRec *hs;
2073     Display *display = XtDisplay(HSDialog.shell);
2074     int screenNum = XScreenNumberOfScreen(XtScreen(HSDialog.shell));
2075     XColor rgb;
2076 
2077     /* Allocate a language mode structure to return */
2078     hs = (highlightStyleRec *)NEditMalloc(sizeof(highlightStyleRec));
2079 
2080     /* read the name field */
2081     hs->name = ReadSymbolicFieldTextWidget(HSDialog.nameW,
2082     	    "highlight style name", silent);
2083     if (hs->name == NULL) {
2084     	NEditFree(hs);
2085     	return NULL;
2086     }
2087 
2088     if (*hs->name == '\0')
2089     {
2090         if (!silent)
2091         {
2092             DialogF(DF_WARN, HSDialog.shell, 1, "Highlight Style",
2093                     "Please specify a name\nfor the highlight style", "OK");
2094             XmProcessTraversal(HSDialog.nameW, XmTRAVERSE_CURRENT);
2095         }
2096         NEditFree(hs->name);
2097         NEditFree(hs);
2098         return NULL;
2099     }
2100 
2101     /* read the color field */
2102     hs->color = ReadSymbolicFieldTextWidget(HSDialog.colorW, "color", silent);
2103     if (hs->color == NULL) {
2104     	NEditFree(hs->name);
2105     	NEditFree(hs);
2106     	return NULL;
2107     }
2108 
2109     if (*hs->color == '\0')
2110     {
2111         if (!silent)
2112         {
2113             DialogF(DF_WARN, HSDialog.shell, 1, "Style Color",
2114                     "Please specify a color\nfor the highlight style",
2115                     "OK");
2116             XmProcessTraversal(HSDialog.colorW, XmTRAVERSE_CURRENT);
2117         }
2118         NEditFree(hs->name);
2119         NEditFree(hs->color);
2120         NEditFree(hs);
2121         return NULL;
2122     }
2123 
2124     /* Verify that the color is a valid X color spec */
2125     if (!XParseColor(display, DefaultColormap(display, screenNum), hs->color,
2126             &rgb))
2127     {
2128         if (!silent)
2129         {
2130             DialogF(DF_WARN, HSDialog.shell, 1, "Invalid Color",
2131                     "Invalid X color specification: %s\n",  "OK",
2132                     hs->color);
2133             XmProcessTraversal(HSDialog.colorW, XmTRAVERSE_CURRENT);
2134         }
2135         NEditFree(hs->name);
2136         NEditFree(hs->color);
2137         NEditFree(hs);
2138         return NULL;;
2139     }
2140 
2141     /* read the background color field - this may be empty */
2142     hs->bgColor = ReadSymbolicFieldTextWidget(HSDialog.bgColorW,
2143                         "bgColor", silent);
2144     if (hs->bgColor && *hs->bgColor == '\0') {
2145         NEditFree(hs->bgColor);
2146         hs->bgColor = NULL;
2147     }
2148 
2149     /* Verify that the background color (if present) is a valid X color spec */
2150     if (hs->bgColor && !XParseColor(display, DefaultColormap(display, screenNum),
2151             hs->bgColor, &rgb))
2152     {
2153         if (!silent)
2154         {
2155             DialogF(DF_WARN, HSDialog.shell, 1, "Invalid Color",
2156                     "Invalid X background color specification: %s\n", "OK",
2157                     hs->bgColor);
2158             XmProcessTraversal(HSDialog.bgColorW, XmTRAVERSE_CURRENT);
2159         }
2160         NEditFree(hs->name);
2161         NEditFree(hs->color);
2162         NEditFree(hs->bgColor);
2163         NEditFree(hs);
2164         return NULL;;
2165     }
2166 
2167     /* read the font buttons */
2168     if (XmToggleButtonGetState(HSDialog.boldW))
2169     	hs->font = BOLD_FONT;
2170     else if (XmToggleButtonGetState(HSDialog.italicW))
2171     	hs->font = ITALIC_FONT;
2172     else if (XmToggleButtonGetState(HSDialog.boldItalicW))
2173     	hs->font = BOLD_ITALIC_FONT;
2174     else
2175     	hs->font = PLAIN_FONT;
2176 
2177     return hs;
2178 }
2179 
2180 /*
2181 ** Copy a highlightStyleRec data structure, and all of the allocated memory
2182 ** it contains.
2183 */
copyHighlightStyleRec(highlightStyleRec * hs)2184 static highlightStyleRec *copyHighlightStyleRec(highlightStyleRec *hs)
2185 {
2186     highlightStyleRec *newHS;
2187 
2188     newHS = (highlightStyleRec *)NEditMalloc(sizeof(highlightStyleRec));
2189     newHS->name = (char*)NEditMalloc(strlen(hs->name)+1);
2190     strcpy(newHS->name, hs->name);
2191     if (hs->color == NULL)
2192     	newHS->color = NULL;
2193     else {
2194 	newHS->color = (char*)NEditMalloc(strlen(hs->color)+1);
2195 	strcpy(newHS->color, hs->color);
2196     }
2197     if (hs->bgColor == NULL)
2198     	newHS->bgColor = NULL;
2199     else {
2200 	newHS->bgColor = (char*)NEditMalloc(strlen(hs->bgColor)+1);
2201 	strcpy(newHS->bgColor, hs->bgColor);
2202     }
2203     newHS->font = hs->font;
2204     return newHS;
2205 }
2206 
2207 /*
2208 ** Free all of the allocated data in a highlightStyleRec, including the
2209 ** structure itself.
2210 */
freeHighlightStyleRec(highlightStyleRec * hs)2211 static void freeHighlightStyleRec(highlightStyleRec *hs)
2212 {
2213     NEditFree(hs->name);
2214     NEditFree(hs->color);
2215     NEditFree(hs);
2216 }
2217 
2218 /*
2219 ** Select a particular style in the highlight styles dialog
2220 */
setStyleByName(const char * style)2221 static void setStyleByName(const char *style)
2222 {
2223     int i;
2224 
2225     for (i=0; i<HSDialog.nHighlightStyles; i++) {
2226     	if (!strcmp(HSDialog.highlightStyleList[i]->name, style)) {
2227     	    SelectManagedListItem(HSDialog.managedListW, i);
2228     	    break;
2229     	}
2230     }
2231 }
2232 
2233 /*
2234 ** Return True if the fields of the highlight styles dialog are consistent
2235 ** with a blank "New" style in the dialog.
2236 */
hsDialogEmpty(void)2237 static int hsDialogEmpty(void)
2238 {
2239     return TextWidgetIsBlank(HSDialog.nameW) &&
2240  	    TextWidgetIsBlank(HSDialog.colorW) &&
2241 	    XmToggleButtonGetState(HSDialog.plainW);
2242 }
2243 
2244 /*
2245 ** Apply the changes made in the highlight styles dialog to the stored
2246 ** highlight style information in HighlightStyles
2247 */
updateHSList(void)2248 static int updateHSList(void)
2249 {
2250     WindowInfo *window;
2251     int i;
2252 
2253     /* Get the current contents of the dialog fields */
2254     if (!UpdateManagedList(HSDialog.managedListW, True))
2255     	return False;
2256 
2257     /* Replace the old highlight styles list with the new one from the dialog */
2258     for (i=0; i<NHighlightStyles; i++)
2259     	freeHighlightStyleRec(HighlightStyles[i]);
2260     for (i=0; i<HSDialog.nHighlightStyles; i++)
2261     	HighlightStyles[i] =
2262     	    	copyHighlightStyleRec(HSDialog.highlightStyleList[i]);
2263     NHighlightStyles = HSDialog.nHighlightStyles;
2264 
2265     /* If a syntax highlighting dialog is up, update its menu */
2266     updateHighlightStyleMenu();
2267 
2268     /* Redisplay highlighted windows which use changed style(s) */
2269     for (window=WindowList; window!=NULL; window=window->next)
2270     	UpdateHighlightStyles(window);
2271 
2272     /* Note that preferences have been changed */
2273     MarkPrefsChanged();
2274 
2275     return True;
2276 }
2277 
2278 /*
2279 ** Present a dialog for editing highlight pattern information
2280 */
EditHighlightPatterns(WindowInfo * window)2281 void EditHighlightPatterns(WindowInfo *window)
2282 {
2283 #define BORDER 4
2284 #define LIST_RIGHT 41
2285     Widget form, lmOptMenu, patternsForm, patternsFrame, patternsLbl;
2286     Widget lmForm, contextFrame, contextForm, styleLbl, styleBtn;
2287     Widget okBtn, applyBtn, checkBtn, deleteBtn, closeBtn, helpBtn;
2288     Widget restoreBtn, nameLbl, typeLbl, typeBox, lmBtn, matchBox;
2289     patternSet *patSet;
2290     XmString s1;
2291     int i, n, nPatterns;
2292     Arg args[20];
2293 
2294     /* if the dialog is already displayed, just pop it to the top and return */
2295     if (HighlightDialog.shell != NULL) {
2296     	RaiseDialogWindow(HighlightDialog.shell);
2297     	return;
2298     }
2299 
2300     if (LanguageModeName(0) == NULL)
2301     {
2302         DialogF(DF_WARN, window->shell, 1, "No Language Modes",
2303                 "No Language Modes available for syntax highlighting\n"
2304                 "Add language modes under Preferenses->Language Modes",
2305                 "OK");
2306         return;
2307     }
2308 
2309     /* Decide on an initial language mode */
2310     HighlightDialog.langModeName = NEditStrdup(
2311     	    LanguageModeName(window->languageMode == PLAIN_LANGUAGE_MODE ? 0 :
2312     	    window->languageMode));
2313 
2314     /* Find the associated pattern set (patSet) to edit */
2315     patSet = FindPatternSet(HighlightDialog.langModeName);
2316 
2317     /* Copy the list of patterns to one that the user can freely edit */
2318     HighlightDialog.patterns = (highlightPattern **)NEditMalloc(
2319     	    sizeof(highlightPattern *) * MAX_PATTERNS);
2320     nPatterns = patSet == NULL ? 0 : patSet->nPatterns;
2321     for (i=0; i<nPatterns; i++)
2322     	HighlightDialog.patterns[i] = copyPatternSrc(&patSet->patterns[i],NULL);
2323     HighlightDialog.nPatterns = nPatterns;
2324 
2325 
2326     /* Create a form widget in an application shell */
2327     n = 0;
2328     XtSetArg(args[n], XmNdeleteResponse, XmDO_NOTHING); n++;
2329     XtSetArg(args[n], XmNiconName, "NEdit Highlight Patterns"); n++;
2330     XtSetArg(args[n], XmNtitle, "Syntax Highlighting Patterns"); n++;
2331     HighlightDialog.shell = CreateWidget(TheAppShell, "syntaxHighlight",
2332 	    topLevelShellWidgetClass, args, n);
2333     AddSmallIcon(HighlightDialog.shell);
2334     form = XtVaCreateManagedWidget("editHighlightPatterns",
2335             xmFormWidgetClass, HighlightDialog.shell,
2336             XmNautoUnmanage, False,
2337             XmNresizePolicy, XmRESIZE_NONE,
2338             NULL);
2339     XtAddCallback(form, XmNdestroyCallback, destroyCB, NULL);
2340     AddMotifCloseCallback(HighlightDialog.shell, closeCB, NULL);
2341 
2342     lmForm = XtVaCreateManagedWidget("lmForm", xmFormWidgetClass,
2343     	    form,
2344 	    XmNleftAttachment, XmATTACH_POSITION,
2345 	    XmNleftPosition, 1,
2346 	    XmNtopAttachment, XmATTACH_POSITION,
2347 	    XmNtopPosition, 1,
2348 	    XmNrightAttachment, XmATTACH_POSITION,
2349             XmNrightPosition, 99,
2350             NULL);
2351 
2352     HighlightDialog.lmPulldown = CreateLanguageModeMenu(lmForm, langModeCB,
2353     	    NULL);
2354     n = 0;
2355     XtSetArg(args[n], XmNspacing, 0); n++;
2356     XtSetArg(args[n], XmNmarginWidth, 0); n++;
2357     XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2358     XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2359     XtSetArg(args[n], XmNleftPosition, 50); n++;
2360     XtSetArg(args[n], XmNsubMenuId, HighlightDialog.lmPulldown); n++;
2361     lmOptMenu = XmCreateOptionMenu(lmForm, "langModeOptMenu", args, n);
2362     XtManageChild(lmOptMenu);
2363     HighlightDialog.lmOptMenu = lmOptMenu;
2364 
2365     XtVaCreateManagedWidget("lmLbl", xmLabelGadgetClass, lmForm,
2366     	    XmNlabelString, s1=XmStringCreateSimple("Language Mode:"),
2367     	    XmNmnemonic, 'M',
2368     	    XmNuserData, XtParent(HighlightDialog.lmOptMenu),
2369     	    XmNalignment, XmALIGNMENT_END,
2370 	    XmNrightAttachment, XmATTACH_POSITION,
2371 	    XmNrightPosition, 50,
2372 	    XmNtopAttachment, XmATTACH_FORM,
2373 	    XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
2374 	    XmNbottomWidget, lmOptMenu, NULL);
2375     XmStringFree(s1);
2376 
2377     lmBtn = XtVaCreateManagedWidget("lmBtn", xmPushButtonWidgetClass, lmForm,
2378     	    XmNlabelString, s1=MKSTRING("Add / Modify\nLanguage Mode..."),
2379     	    XmNmnemonic, 'A',
2380     	    XmNrightAttachment, XmATTACH_FORM,
2381     	    XmNtopAttachment, XmATTACH_FORM, NULL);
2382     XtAddCallback(lmBtn, XmNactivateCallback, lmDialogCB, NULL);
2383     XmStringFree(s1);
2384 
2385     okBtn = XtVaCreateManagedWidget("ok", xmPushButtonWidgetClass, form,
2386             XmNlabelString, s1=XmStringCreateSimple("OK"),
2387             XmNmarginWidth, BUTTON_WIDTH_MARGIN,
2388     	    XmNleftAttachment, XmATTACH_POSITION,
2389     	    XmNleftPosition, 1,
2390     	    XmNrightAttachment, XmATTACH_POSITION,
2391     	    XmNrightPosition, 13,
2392     	    XmNbottomAttachment, XmATTACH_FORM,
2393     	    XmNbottomOffset, BORDER, NULL);
2394     XtAddCallback(okBtn, XmNactivateCallback, okCB, NULL);
2395     XmStringFree(s1);
2396 
2397     applyBtn = XtVaCreateManagedWidget("apply", xmPushButtonWidgetClass, form,
2398     	    XmNlabelString, s1=XmStringCreateSimple("Apply"),
2399     	    XmNmnemonic, 'y',
2400     	    XmNleftAttachment, XmATTACH_POSITION,
2401     	    XmNleftPosition, 13,
2402     	    XmNrightAttachment, XmATTACH_POSITION,
2403     	    XmNrightPosition, 26,
2404     	    XmNbottomAttachment, XmATTACH_FORM,
2405     	    XmNbottomOffset, BORDER, NULL);
2406     XtAddCallback(applyBtn, XmNactivateCallback, applyCB, NULL);
2407     XmStringFree(s1);
2408 
2409     checkBtn = XtVaCreateManagedWidget("check", xmPushButtonWidgetClass, form,
2410     	    XmNlabelString, s1=XmStringCreateSimple("Check"),
2411     	    XmNmnemonic, 'k',
2412     	    XmNleftAttachment, XmATTACH_POSITION,
2413     	    XmNleftPosition, 26,
2414     	    XmNrightAttachment, XmATTACH_POSITION,
2415     	    XmNrightPosition, 39,
2416     	    XmNbottomAttachment, XmATTACH_FORM,
2417     	    XmNbottomOffset, BORDER, NULL);
2418     XtAddCallback(checkBtn, XmNactivateCallback, checkCB, NULL);
2419     XmStringFree(s1);
2420 
2421     deleteBtn = XtVaCreateManagedWidget("delete", xmPushButtonWidgetClass, form,
2422     	    XmNlabelString, s1=XmStringCreateSimple("Delete"),
2423     	    XmNmnemonic, 'D',
2424     	    XmNleftAttachment, XmATTACH_POSITION,
2425     	    XmNleftPosition, 39,
2426     	    XmNrightAttachment, XmATTACH_POSITION,
2427     	    XmNrightPosition, 52,
2428     	    XmNbottomAttachment, XmATTACH_FORM,
2429     	    XmNbottomOffset, BORDER, NULL);
2430     XtAddCallback(deleteBtn, XmNactivateCallback, deleteCB, NULL);
2431     XmStringFree(s1);
2432 
2433     restoreBtn = XtVaCreateManagedWidget("restore", xmPushButtonWidgetClass, form,
2434     	    XmNlabelString, s1=XmStringCreateSimple("Restore Defaults"),
2435     	    XmNmnemonic, 'f',
2436     	    XmNleftAttachment, XmATTACH_POSITION,
2437     	    XmNleftPosition, 52,
2438     	    XmNrightAttachment, XmATTACH_POSITION,
2439     	    XmNrightPosition, 73,
2440     	    XmNbottomAttachment, XmATTACH_FORM,
2441     	    XmNbottomOffset, BORDER, NULL);
2442     XtAddCallback(restoreBtn, XmNactivateCallback, restoreCB, NULL);
2443     XmStringFree(s1);
2444 
2445     closeBtn = XtVaCreateManagedWidget("close", xmPushButtonWidgetClass,
2446     	    form,
2447     	    XmNlabelString, s1=XmStringCreateSimple("Close"),
2448     	    XmNleftAttachment, XmATTACH_POSITION,
2449     	    XmNleftPosition, 73,
2450     	    XmNrightAttachment, XmATTACH_POSITION,
2451     	    XmNrightPosition, 86,
2452     	    XmNbottomAttachment, XmATTACH_FORM,
2453     	    XmNbottomOffset, BORDER, NULL);
2454     XtAddCallback(closeBtn, XmNactivateCallback, closeCB, NULL);
2455     XmStringFree(s1);
2456 
2457     helpBtn = XtVaCreateManagedWidget("help", xmPushButtonWidgetClass,
2458     	    form,
2459     	    XmNlabelString, s1=XmStringCreateSimple("Help"),
2460     	    XmNmnemonic, 'H',
2461     	    XmNleftAttachment, XmATTACH_POSITION,
2462     	    XmNleftPosition, 86,
2463     	    XmNrightAttachment, XmATTACH_POSITION,
2464     	    XmNrightPosition, 99,
2465     	    XmNbottomAttachment, XmATTACH_FORM,
2466     	    XmNbottomOffset, BORDER, NULL);
2467     XtAddCallback(helpBtn, XmNactivateCallback, helpCB, NULL);
2468     XmStringFree(s1);
2469 
2470     contextFrame = XtVaCreateManagedWidget("contextFrame", xmFrameWidgetClass,
2471     	    form,
2472 	    XmNleftAttachment, XmATTACH_POSITION,
2473 	    XmNleftPosition, 1,
2474 	    XmNrightAttachment, XmATTACH_POSITION,
2475 	    XmNrightPosition, 99,
2476 	    XmNbottomAttachment, XmATTACH_WIDGET,
2477     	    XmNbottomWidget, okBtn,
2478     	    XmNbottomOffset, BORDER, NULL);
2479     contextForm = XtVaCreateManagedWidget("contextForm", xmFormWidgetClass,
2480 	    contextFrame, NULL);
2481     XtVaCreateManagedWidget("contextLbl", xmLabelGadgetClass, contextFrame,
2482     	    XmNlabelString, s1=XmStringCreateSimple(
2483     	      "Context requirements for incremental re-parsing after changes"),
2484 	    XmNchildType, XmFRAME_TITLE_CHILD, NULL);
2485     XmStringFree(s1);
2486 
2487     HighlightDialog.lineContextW = XtVaCreateManagedWidget("lineContext",
2488     	    xmTextWidgetClass, contextForm,
2489 	    XmNcolumns, 5,
2490 	    XmNmaxLength, 12,
2491 	    XmNleftAttachment, XmATTACH_POSITION,
2492 	    XmNleftPosition, 15,
2493 	    XmNrightAttachment, XmATTACH_POSITION,
2494 	    XmNrightPosition, 25, NULL);
2495     RemapDeleteKey(HighlightDialog.lineContextW);
2496 
2497     XtVaCreateManagedWidget("lineContLbl",
2498     	    xmLabelGadgetClass, contextForm,
2499     	    XmNlabelString, s1=XmStringCreateSimple("lines"),
2500     	    XmNmnemonic, 'l',
2501     	    XmNuserData, HighlightDialog.lineContextW,
2502     	    XmNalignment, XmALIGNMENT_BEGINNING,
2503 	    XmNleftAttachment, XmATTACH_WIDGET,
2504 	    XmNleftWidget, HighlightDialog.lineContextW,
2505 	    XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
2506 	    XmNtopWidget, HighlightDialog.lineContextW,
2507 	    XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
2508     	    XmNbottomWidget, HighlightDialog.lineContextW, NULL);
2509     XmStringFree(s1);
2510 
2511     HighlightDialog.charContextW = XtVaCreateManagedWidget("charContext",
2512     	    xmTextWidgetClass, contextForm,
2513 	    XmNcolumns, 5,
2514 	    XmNmaxLength, 12,
2515 	    XmNleftAttachment, XmATTACH_POSITION,
2516 	    XmNleftPosition, 58,
2517 	    XmNrightAttachment, XmATTACH_POSITION,
2518 	    XmNrightPosition, 68, NULL);
2519     RemapDeleteKey(HighlightDialog.lineContextW);
2520 
2521     XtVaCreateManagedWidget("charContLbl",
2522     	    xmLabelGadgetClass, contextForm,
2523     	    XmNlabelString, s1=XmStringCreateSimple("characters"),
2524     	    XmNmnemonic, 'c',
2525     	    XmNuserData, HighlightDialog.charContextW,
2526     	    XmNalignment, XmALIGNMENT_BEGINNING,
2527 	    XmNleftAttachment, XmATTACH_WIDGET,
2528 	    XmNleftWidget, HighlightDialog.charContextW,
2529 	    XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET,
2530 	    XmNtopWidget, HighlightDialog.charContextW,
2531 	    XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
2532     	    XmNbottomWidget, HighlightDialog.charContextW, NULL);
2533     XmStringFree(s1);
2534 
2535     patternsFrame = XtVaCreateManagedWidget("patternsFrame", xmFrameWidgetClass,
2536     	    form,
2537 	    XmNleftAttachment, XmATTACH_POSITION,
2538 	    XmNleftPosition, 1,
2539 	    XmNtopAttachment, XmATTACH_WIDGET,
2540 	    XmNtopWidget, lmForm,
2541 	    XmNrightAttachment, XmATTACH_POSITION,
2542 	    XmNrightPosition, 99,
2543 	    XmNbottomAttachment, XmATTACH_WIDGET,
2544     	    XmNbottomWidget, contextFrame,
2545     	    XmNbottomOffset, BORDER, NULL);
2546     patternsForm = XtVaCreateManagedWidget("patternsForm", xmFormWidgetClass,
2547 	    patternsFrame, NULL);
2548     patternsLbl = XtVaCreateManagedWidget("patternsLbl", xmLabelGadgetClass,
2549     	    patternsFrame,
2550     	    XmNlabelString, s1=XmStringCreateSimple("Patterns"),
2551     	    XmNmnemonic, 'P',
2552     	    XmNmarginHeight, 0,
2553 	    XmNchildType, XmFRAME_TITLE_CHILD, NULL);
2554     XmStringFree(s1);
2555 
2556     typeLbl = XtVaCreateManagedWidget("typeLbl", xmLabelGadgetClass,
2557     	    patternsForm,
2558     	    XmNlabelString, s1=XmStringCreateSimple("Pattern Type:"),
2559     	    XmNmarginHeight, 0,
2560     	    XmNalignment, XmALIGNMENT_BEGINNING,
2561 	    XmNleftAttachment, XmATTACH_POSITION,
2562     	    XmNleftPosition, LIST_RIGHT,
2563 	    XmNtopAttachment, XmATTACH_FORM, NULL);
2564     XmStringFree(s1);
2565 
2566     typeBox = XtVaCreateManagedWidget("typeBox", xmRowColumnWidgetClass,
2567     	    patternsForm,
2568     	    XmNpacking, XmPACK_COLUMN,
2569     	    XmNradioBehavior, True,
2570 	    XmNleftAttachment, XmATTACH_POSITION,
2571     	    XmNleftPosition, LIST_RIGHT,
2572 	    XmNtopAttachment, XmATTACH_WIDGET,
2573 	    XmNtopWidget, typeLbl, NULL);
2574     HighlightDialog.topLevelW = XtVaCreateManagedWidget("top",
2575     	    xmToggleButtonWidgetClass, typeBox,
2576     	    XmNset, True,
2577     	    XmNmarginHeight, 0,
2578     	    XmNlabelString, s1=XmStringCreateSimple(
2579     	        "Pass-1 (applied to all text when loaded or modified)"),
2580     	    XmNmnemonic, '1', NULL);
2581     XmStringFree(s1);
2582     XtAddCallback(HighlightDialog.topLevelW, XmNvalueChangedCallback,
2583     	    patTypeCB, NULL);
2584     HighlightDialog.deferredW = XtVaCreateManagedWidget("deferred",
2585     	    xmToggleButtonWidgetClass, typeBox,
2586     	    XmNmarginHeight, 0,
2587     	    XmNlabelString, s1=XmStringCreateSimple(
2588     	        "Pass-2 (parsing is deferred until text is exposed)"),
2589     	    XmNmnemonic, '2', NULL);
2590     XmStringFree(s1);
2591     XtAddCallback(HighlightDialog.deferredW, XmNvalueChangedCallback,
2592     	    patTypeCB, NULL);
2593     HighlightDialog.subPatW = XtVaCreateManagedWidget("subPat",
2594     	    xmToggleButtonWidgetClass, typeBox,
2595     	    XmNmarginHeight, 0,
2596     	    XmNlabelString, s1=XmStringCreateSimple(
2597     	    	"Sub-pattern (processed within start & end of parent)"),
2598     	    XmNmnemonic, 'u', NULL);
2599     XmStringFree(s1);
2600     XtAddCallback(HighlightDialog.subPatW, XmNvalueChangedCallback,
2601     	    patTypeCB, NULL);
2602     HighlightDialog.colorPatW = XtVaCreateManagedWidget("color",
2603     	    xmToggleButtonWidgetClass, typeBox,
2604     	    XmNmarginHeight, 0,
2605     	    XmNlabelString, s1=XmStringCreateSimple(
2606     	    	"Coloring for sub-expressions of parent pattern"),
2607     	    XmNmnemonic, 'g', NULL);
2608     XmStringFree(s1);
2609     XtAddCallback(HighlightDialog.colorPatW, XmNvalueChangedCallback,
2610     	    patTypeCB, NULL);
2611 
2612     HighlightDialog.matchLbl = XtVaCreateManagedWidget("matchLbl",
2613     	    xmLabelGadgetClass, patternsForm,
2614     	    XmNlabelString, s1=XmStringCreateSimple("Matching:"),
2615     	    XmNmarginHeight, 0,
2616     	    XmNalignment, XmALIGNMENT_BEGINNING,
2617 	    XmNleftAttachment, XmATTACH_POSITION,
2618     	    XmNleftPosition, LIST_RIGHT,
2619 	    XmNtopAttachment, XmATTACH_WIDGET,
2620 	    XmNtopOffset, BORDER,
2621 	    XmNtopWidget, typeBox, NULL);
2622     XmStringFree(s1);
2623 
2624     matchBox = XtVaCreateManagedWidget("matchBox", xmRowColumnWidgetClass,
2625     	    patternsForm,
2626     	    XmNpacking, XmPACK_COLUMN,
2627     	    XmNradioBehavior, True,
2628 	    XmNleftAttachment, XmATTACH_POSITION,
2629     	    XmNleftPosition, LIST_RIGHT,
2630 	    XmNtopAttachment, XmATTACH_WIDGET,
2631 	    XmNtopWidget, HighlightDialog.matchLbl, NULL);
2632     HighlightDialog.simpleW = XtVaCreateManagedWidget("simple",
2633     	    xmToggleButtonWidgetClass, matchBox,
2634     	    XmNset, True,
2635     	    XmNmarginHeight, 0,
2636     	    XmNlabelString, s1=XmStringCreateSimple(
2637     	    	"Highlight text matching regular expression"),
2638     	    XmNmnemonic, 'x', NULL);
2639     XmStringFree(s1);
2640     XtAddCallback(HighlightDialog.simpleW, XmNvalueChangedCallback,
2641     	    matchTypeCB, NULL);
2642     HighlightDialog.rangeW = XtVaCreateManagedWidget("range",
2643     	    xmToggleButtonWidgetClass, matchBox,
2644     	    XmNmarginHeight, 0,
2645     	    XmNlabelString, s1=XmStringCreateSimple(
2646     	    	"Highlight text between starting and ending REs"),
2647     	    XmNmnemonic, 'b', NULL);
2648     XmStringFree(s1);
2649     XtAddCallback(HighlightDialog.rangeW, XmNvalueChangedCallback,
2650     	    matchTypeCB, NULL);
2651 
2652     nameLbl = XtVaCreateManagedWidget("nameLbl", xmLabelGadgetClass,
2653     	    patternsForm,
2654     	    XmNlabelString, s1=XmStringCreateSimple("Pattern Name"),
2655     	    XmNmnemonic, 'N',
2656     	    XmNrows, 20,
2657     	    XmNalignment, XmALIGNMENT_BEGINNING,
2658 	    XmNleftAttachment, XmATTACH_POSITION,
2659     	    XmNleftPosition, LIST_RIGHT,
2660 	    XmNtopAttachment, XmATTACH_WIDGET,
2661 	    XmNtopWidget, matchBox,
2662 	    XmNtopOffset, BORDER, NULL);
2663     XmStringFree(s1);
2664 
2665     HighlightDialog.nameW = XtVaCreateManagedWidget("name", xmTextWidgetClass,
2666     	    patternsForm,
2667 	    XmNleftAttachment, XmATTACH_POSITION,
2668 	    XmNleftPosition, LIST_RIGHT,
2669 	    XmNtopAttachment, XmATTACH_WIDGET,
2670 	    XmNtopWidget, nameLbl,
2671 	    XmNrightAttachment, XmATTACH_POSITION,
2672 	    XmNrightPosition, (99 + LIST_RIGHT)/2, NULL);
2673     RemapDeleteKey(HighlightDialog.nameW);
2674     XtVaSetValues(nameLbl, XmNuserData, HighlightDialog.nameW, NULL);
2675 
2676     HighlightDialog.parentLbl = XtVaCreateManagedWidget("parentLbl",
2677     	    xmLabelGadgetClass, patternsForm,
2678     	    XmNlabelString, s1=XmStringCreateSimple("Parent Pattern"),
2679     	    XmNmnemonic, 't',
2680     	    XmNrows, 20,
2681     	    XmNalignment, XmALIGNMENT_BEGINNING,
2682 	    XmNleftAttachment, XmATTACH_POSITION,
2683     	    XmNleftPosition, (99 + LIST_RIGHT)/2 + 1,
2684 	    XmNtopAttachment, XmATTACH_WIDGET,
2685 	    XmNtopWidget, matchBox,
2686 	    XmNtopOffset, BORDER, NULL);
2687     XmStringFree(s1);
2688 
2689     HighlightDialog.parentW = XtVaCreateManagedWidget("parent",
2690     	    xmTextWidgetClass, patternsForm,
2691 	    XmNleftAttachment, XmATTACH_POSITION,
2692 	    XmNleftPosition, (99 + LIST_RIGHT)/2 + 1,
2693 	    XmNtopAttachment, XmATTACH_WIDGET,
2694 	    XmNtopWidget, HighlightDialog.parentLbl,
2695 	    XmNrightAttachment, XmATTACH_POSITION,
2696 	    XmNrightPosition, 99, NULL);
2697     RemapDeleteKey(HighlightDialog.parentW);
2698     XtVaSetValues(HighlightDialog.parentLbl, XmNuserData,
2699     	    HighlightDialog.parentW, NULL);
2700 
2701     HighlightDialog.startLbl = XtVaCreateManagedWidget("startLbl",
2702     	    xmLabelGadgetClass, patternsForm,
2703     	    XmNalignment, XmALIGNMENT_BEGINNING,
2704 	    XmNmnemonic, 'R',
2705 	    XmNtopAttachment, XmATTACH_WIDGET,
2706 	    XmNtopWidget, HighlightDialog.parentW,
2707 	    XmNtopOffset, BORDER,
2708 	    XmNleftAttachment, XmATTACH_POSITION,
2709     	    XmNleftPosition, 1, NULL);
2710 
2711     HighlightDialog.errorW = XtVaCreateManagedWidget("error",
2712     	    xmTextWidgetClass, patternsForm,
2713 	    XmNleftAttachment, XmATTACH_POSITION,
2714 	    XmNleftPosition, 1,
2715 	    XmNrightAttachment, XmATTACH_POSITION,
2716 	    XmNrightPosition, 99,
2717 	    XmNbottomAttachment, XmATTACH_POSITION,
2718 	    XmNbottomPosition, 99, NULL);
2719     RemapDeleteKey(HighlightDialog.errorW);
2720 
2721     HighlightDialog.errorLbl = XtVaCreateManagedWidget("errorLbl",
2722     	    xmLabelGadgetClass, patternsForm,
2723     	    XmNlabelString, s1=XmStringCreateSimple(
2724     	    	"Regular Expression Indicating Error in Match (Optional)"),
2725     	    XmNmnemonic, 'o',
2726     	    XmNuserData, HighlightDialog.errorW,
2727     	    XmNalignment, XmALIGNMENT_BEGINNING,
2728 	    XmNleftAttachment, XmATTACH_POSITION,
2729     	    XmNleftPosition, 1,
2730 	    XmNbottomAttachment, XmATTACH_WIDGET,
2731 	    XmNbottomWidget, HighlightDialog.errorW, NULL);
2732     XmStringFree(s1);
2733 
2734     HighlightDialog.endW = XtVaCreateManagedWidget("end",
2735     	    xmTextWidgetClass, patternsForm,
2736 	    XmNleftAttachment, XmATTACH_POSITION,
2737 	    XmNleftPosition, 1,
2738 	    XmNbottomAttachment, XmATTACH_WIDGET,
2739 	    XmNbottomWidget, HighlightDialog.errorLbl,
2740 	    XmNbottomOffset, BORDER,
2741 	    XmNrightAttachment, XmATTACH_POSITION,
2742 	    XmNrightPosition, 99, NULL);
2743     RemapDeleteKey(HighlightDialog.endW);
2744 
2745     HighlightDialog.endLbl = XtVaCreateManagedWidget("endLbl",
2746     	    xmLabelGadgetClass, patternsForm,
2747     	    XmNmnemonic, 'E',
2748     	    XmNuserData, HighlightDialog.endW,
2749     	    XmNalignment, XmALIGNMENT_BEGINNING,
2750 	    XmNleftAttachment, XmATTACH_POSITION,
2751     	    XmNleftPosition, 1,
2752 	    XmNbottomAttachment, XmATTACH_WIDGET,
2753 	    XmNbottomWidget, HighlightDialog.endW, NULL);
2754 
2755     n = 0;
2756     XtSetArg(args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
2757     XtSetArg(args[n], XmNscrollHorizontal, False); n++;
2758     XtSetArg(args[n], XmNwordWrap, True); n++;
2759     XtSetArg(args[n], XmNrows, 3); n++;
2760     XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
2761     XtSetArg(args[n], XmNbottomWidget, HighlightDialog.endLbl); n++;
2762     XtSetArg(args[n], XmNbottomOffset, BORDER); n++;
2763     XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
2764     XtSetArg(args[n], XmNtopWidget, HighlightDialog.startLbl); n++;
2765     XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2766     XtSetArg(args[n], XmNleftPosition, 1); n++;
2767     XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
2768     XtSetArg(args[n], XmNrightPosition, 99); n++;
2769     HighlightDialog.startW = XmCreateScrolledText(patternsForm, "start",args,n);
2770     AddMouseWheelSupport(HighlightDialog.startW);
2771     XtManageChild(HighlightDialog.startW);
2772     MakeSingleLineTextW(HighlightDialog.startW);
2773     RemapDeleteKey(HighlightDialog.startW);
2774     XtVaSetValues(HighlightDialog.startLbl,
2775     		XmNuserData,HighlightDialog.startW, NULL);
2776 
2777     styleBtn = XtVaCreateManagedWidget("styleLbl", xmPushButtonWidgetClass,
2778     	    patternsForm,
2779     	    XmNlabelString, s1=MKSTRING("Add / Modify\nStyle..."),
2780     	    XmNmnemonic, 'i',
2781 	    XmNrightAttachment, XmATTACH_POSITION,
2782     	    XmNrightPosition, LIST_RIGHT-1,
2783 	    XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET,
2784 	    XmNbottomWidget, HighlightDialog.parentW, NULL);
2785     XmStringFree(s1);
2786     XtAddCallback(styleBtn, XmNactivateCallback, styleDialogCB, NULL);
2787 
2788     HighlightDialog.stylePulldown = createHighlightStylesMenu(patternsForm);
2789     n = 0;
2790     XtSetArg(args[n], XmNspacing, 0); n++;
2791     XtSetArg(args[n], XmNmarginWidth, 0); n++;
2792     XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
2793     XtSetArg(args[n], XmNbottomWidget, HighlightDialog.parentW); n++;
2794     XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2795     XtSetArg(args[n], XmNleftPosition, 1); n++;
2796     XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2797     XtSetArg(args[n], XmNrightWidget, styleBtn); n++;
2798     XtSetArg(args[n], XmNsubMenuId, HighlightDialog.stylePulldown); n++;
2799     HighlightDialog.styleOptMenu = XmCreateOptionMenu(patternsForm,
2800     		"styleOptMenu", args, n);
2801     XtManageChild(HighlightDialog.styleOptMenu);
2802 
2803     styleLbl = XtVaCreateManagedWidget("styleLbl", xmLabelGadgetClass,
2804     	    patternsForm,
2805     	    XmNlabelString, s1=XmStringCreateSimple("Highlight Style"),
2806     	    XmNmnemonic, 'S',
2807     	    XmNuserData, XtParent(HighlightDialog.styleOptMenu),
2808     	    XmNalignment, XmALIGNMENT_BEGINNING,
2809 	    XmNleftAttachment, XmATTACH_POSITION,
2810     	    XmNleftPosition, 1,
2811 	    XmNbottomAttachment, XmATTACH_WIDGET,
2812 	    XmNbottomWidget, HighlightDialog.styleOptMenu, NULL);
2813     XmStringFree(s1);
2814 
2815     n = 0;
2816     XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
2817     XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
2818     XtSetArg(args[n], XmNleftPosition, 1); n++;
2819     XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
2820     XtSetArg(args[n], XmNrightPosition, LIST_RIGHT-1); n++;
2821     XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
2822     XtSetArg(args[n], XmNbottomWidget, styleLbl); n++;
2823     XtSetArg(args[n], XmNbottomOffset, BORDER); n++;
2824     HighlightDialog.managedListW = CreateManagedList(patternsForm, "list", args,
2825     	    n, (void **)HighlightDialog.patterns, &HighlightDialog.nPatterns,
2826     	    MAX_PATTERNS, 18, getDisplayedCB, NULL, setDisplayedCB,
2827     	    NULL, freeItemCB);
2828     XtVaSetValues(patternsLbl, XmNuserData, HighlightDialog.managedListW, NULL);
2829 
2830     /* Set initial default button */
2831     XtVaSetValues(form, XmNdefaultButton, okBtn, NULL);
2832     XtVaSetValues(form, XmNcancelButton, closeBtn, NULL);
2833 
2834     /* Handle mnemonic selection of buttons and focus to dialog */
2835     AddDialogMnemonicHandler(form, FALSE);
2836 
2837     /* Fill in the dialog information for the selected language mode */
2838     SetIntText(HighlightDialog.lineContextW, patSet==NULL ? 1 :
2839     	    patSet->lineContext);
2840     SetIntText(HighlightDialog.charContextW, patSet==NULL ? 0 :
2841     	    patSet->charContext);
2842     SetLangModeMenu(HighlightDialog.lmOptMenu, HighlightDialog.langModeName);
2843     updateLabels();
2844 
2845     /* Realize all of the widgets in the new dialog */
2846     RealizeWithoutForcingPosition(HighlightDialog.shell);
2847 }
2848 
2849 /*
2850 ** If a syntax highlighting dialog is up, ask to have the option menu for
2851 ** chosing highlight styles updated (via a call to createHighlightStylesMenu)
2852 */
updateHighlightStyleMenu(void)2853 static void updateHighlightStyleMenu(void)
2854 {
2855     Widget oldMenu;
2856     int patIndex;
2857 
2858     if (HighlightDialog.shell == NULL)
2859     	return;
2860 
2861     oldMenu = HighlightDialog.stylePulldown;
2862     HighlightDialog.stylePulldown = createHighlightStylesMenu(
2863     	    XtParent(XtParent(oldMenu)));
2864     XtVaSetValues(XmOptionButtonGadget(HighlightDialog.styleOptMenu),
2865     	    XmNsubMenuId, HighlightDialog.stylePulldown, NULL);
2866     patIndex = ManagedListSelectedIndex(HighlightDialog.managedListW);
2867     if (patIndex == -1)
2868     	setStyleMenu("Plain");
2869     else
2870     	setStyleMenu(HighlightDialog.patterns[patIndex]->style);
2871 
2872     XtDestroyWidget(oldMenu);
2873 }
2874 
2875 /*
2876 ** If a syntax highlighting dialog is up, ask to have the option menu for
2877 ** chosing language mode updated (via a call to CreateLanguageModeMenu)
2878 */
UpdateLanguageModeMenu(void)2879 void UpdateLanguageModeMenu(void)
2880 {
2881     Widget oldMenu;
2882 
2883     if (HighlightDialog.shell == NULL)
2884     	return;
2885 
2886     oldMenu = HighlightDialog.lmPulldown;
2887     HighlightDialog.lmPulldown = CreateLanguageModeMenu(
2888     	    XtParent(XtParent(oldMenu)), langModeCB, NULL);
2889     XtVaSetValues(XmOptionButtonGadget(HighlightDialog.lmOptMenu),
2890     	    XmNsubMenuId, HighlightDialog.lmPulldown, NULL);
2891     SetLangModeMenu(HighlightDialog.lmOptMenu, HighlightDialog.langModeName);
2892 
2893     XtDestroyWidget(oldMenu);
2894 }
2895 
destroyCB(Widget w,XtPointer clientData,XtPointer callData)2896 static void destroyCB(Widget w, XtPointer clientData, XtPointer callData)
2897 {
2898     int i;
2899 
2900     NEditFree(HighlightDialog.langModeName);
2901     for (i=0; i<HighlightDialog.nPatterns; i++)
2902      	freePatternSrc(HighlightDialog.patterns[i], True);
2903     HighlightDialog.shell = NULL;
2904 }
2905 
langModeCB(Widget w,XtPointer clientData,XtPointer callData)2906 static void langModeCB(Widget w, XtPointer clientData, XtPointer callData)
2907 {
2908     char *modeName;
2909     patternSet *oldPatSet, *newPatSet;
2910     patternSet emptyPatSet = {NULL, 1, 0, 0, NULL};
2911     int i, resp;
2912 
2913     /* Get the newly selected mode name.  If it's the same, do nothing */
2914     XtVaGetValues(w, XmNuserData, &modeName, NULL);
2915     if (!strcmp(modeName, HighlightDialog.langModeName))
2916     	return;
2917 
2918     /* Look up the original version of the patterns being edited */
2919     oldPatSet = FindPatternSet(HighlightDialog.langModeName);
2920     if (oldPatSet == NULL)
2921     	oldPatSet = &emptyPatSet;
2922 
2923     /* Get the current information displayed by the dialog.  If it's bad,
2924        give the user the chance to throw it out or go back and fix it.  If
2925        it has changed, give the user the chance to apply discard or cancel. */
2926     newPatSet = getDialogPatternSet();
2927 
2928     if (newPatSet == NULL)
2929     {
2930         if (DialogF(DF_WARN, HighlightDialog.shell, 2,
2931                 "Incomplete Language Mode", "Discard incomplete entry\n"
2932                 "for current language mode?", "Keep", "Discard") == 1)
2933         {
2934             SetLangModeMenu(HighlightDialog.lmOptMenu,
2935                     HighlightDialog.langModeName);
2936             return;
2937         }
2938     } else if (patternSetsDiffer(oldPatSet, newPatSet))
2939     {
2940         resp = DialogF(DF_WARN, HighlightDialog.shell, 3, "Language Mode",
2941                 "Apply changes for language mode %s?", "Apply Changes",
2942                 "Discard Changes", "Cancel", HighlightDialog.langModeName);
2943         if (resp == 3)
2944         {
2945             SetLangModeMenu(HighlightDialog.lmOptMenu,
2946                     HighlightDialog.langModeName);
2947             return;
2948         }
2949         if (resp == 1)
2950         {
2951             updatePatternSet();
2952         }
2953     }
2954 
2955     if (newPatSet != NULL)
2956     	freePatternSet(newPatSet);
2957 
2958     /* Free the old dialog information */
2959     NEditFree(HighlightDialog.langModeName);
2960     for (i=0; i<HighlightDialog.nPatterns; i++)
2961      	freePatternSrc(HighlightDialog.patterns[i], True);
2962 
2963     /* Fill the dialog with the new language mode information */
2964     HighlightDialog.langModeName = NEditStrdup(modeName);
2965     newPatSet = FindPatternSet(modeName);
2966     if (newPatSet == NULL) {
2967     	HighlightDialog.nPatterns = 0;
2968     	SetIntText(HighlightDialog.lineContextW, 1);
2969     	SetIntText(HighlightDialog.charContextW, 0);
2970     } else {
2971 	for (i=0; i<newPatSet->nPatterns; i++)
2972     	    HighlightDialog.patterns[i] =
2973     		    copyPatternSrc(&newPatSet->patterns[i], NULL);
2974 	HighlightDialog.nPatterns = newPatSet->nPatterns;
2975     	SetIntText(HighlightDialog.lineContextW, newPatSet->lineContext);
2976     	SetIntText(HighlightDialog.charContextW, newPatSet->charContext);
2977     }
2978     ChangeManagedListData(HighlightDialog.managedListW);
2979 }
2980 
lmDialogCB(Widget w,XtPointer clientData,XtPointer callData)2981 static void lmDialogCB(Widget w, XtPointer clientData, XtPointer callData)
2982 {
2983     EditLanguageModes();
2984 }
2985 
styleDialogCB(Widget w,XtPointer clientData,XtPointer callData)2986 static void styleDialogCB(Widget w, XtPointer clientData, XtPointer callData)
2987 {
2988     Widget selectedItem;
2989     char *style;
2990 
2991     XtVaGetValues(HighlightDialog.styleOptMenu,
2992             XmNmenuHistory, &selectedItem,
2993             NULL);
2994     XtVaGetValues(selectedItem,
2995             XmNuserData, &style,
2996             NULL);
2997     EditHighlightStyles(style);
2998 }
2999 
okCB(Widget w,XtPointer clientData,XtPointer callData)3000 static void okCB(Widget w, XtPointer clientData, XtPointer callData)
3001 {
3002     /* change the patterns */
3003     if (!updatePatternSet())
3004     	return;
3005 
3006     /* pop down and destroy the dialog */
3007     CloseAllPopupsFor(HighlightDialog.shell);
3008     XtDestroyWidget(HighlightDialog.shell);
3009 }
3010 
applyCB(Widget w,XtPointer clientData,XtPointer callData)3011 static void applyCB(Widget w, XtPointer clientData, XtPointer callData)
3012 {
3013     /* change the patterns */
3014     updatePatternSet();
3015 }
3016 
checkCB(Widget w,XtPointer clientData,XtPointer callData)3017 static void checkCB(Widget w, XtPointer clientData, XtPointer callData)
3018 {
3019     if (checkHighlightDialogData())
3020     {
3021         DialogF(DF_INF, HighlightDialog.shell, 1, "Pattern compiled",
3022                 "Patterns compiled without error", "OK");
3023     }
3024 }
3025 
restoreCB(Widget w,XtPointer clientData,XtPointer callData)3026 static void restoreCB(Widget w, XtPointer clientData, XtPointer callData)
3027 {
3028     patternSet *defaultPatSet;
3029     int i, psn;
3030 
3031     defaultPatSet = readDefaultPatternSet(HighlightDialog.langModeName);
3032     if (defaultPatSet == NULL)
3033     {
3034         DialogF(DF_WARN, HighlightDialog.shell, 1, "No Default Pattern",
3035                 "There is no default pattern set\nfor language mode %s",
3036                 "OK", HighlightDialog.langModeName);
3037         return;
3038     }
3039 
3040     if (DialogF(DF_WARN, HighlightDialog.shell, 2, "Discard Changes",
3041             "Are you sure you want to discard\n"
3042             "all changes to syntax highlighting\n"
3043             "patterns for language mode %s?", "Discard", "Cancel",
3044             HighlightDialog.langModeName) == 2)
3045     {
3046         return;
3047     }
3048 
3049     /* if a stored version of the pattern set exists, replace it, if it
3050        doesn't, add a new one */
3051     for (psn=0; psn<NPatternSets; psn++)
3052     	if (!strcmp(HighlightDialog.langModeName,
3053     	    	PatternSets[psn]->languageMode))
3054     	    break;
3055     if (psn < NPatternSets) {
3056      	freePatternSet(PatternSets[psn]);
3057    	PatternSets[psn] = defaultPatSet;
3058     } else
3059     	PatternSets[NPatternSets++] = defaultPatSet;
3060 
3061     /* Free the old dialog information */
3062     for (i=0; i<HighlightDialog.nPatterns; i++)
3063      	freePatternSrc(HighlightDialog.patterns[i], True);
3064 
3065     /* Update the dialog */
3066     HighlightDialog.nPatterns = defaultPatSet->nPatterns;
3067     for (i=0; i<defaultPatSet->nPatterns; i++)
3068     	HighlightDialog.patterns[i] =
3069     		copyPatternSrc(&defaultPatSet->patterns[i], NULL);
3070     	SetIntText(HighlightDialog.lineContextW, defaultPatSet->lineContext);
3071     	SetIntText(HighlightDialog.charContextW, defaultPatSet->charContext);
3072     ChangeManagedListData(HighlightDialog.managedListW);
3073 }
3074 
deleteCB(Widget w,XtPointer clientData,XtPointer callData)3075 static void deleteCB(Widget w, XtPointer clientData, XtPointer callData)
3076 {
3077     int i, psn;
3078 
3079     if (DialogF(DF_WARN, HighlightDialog.shell, 2, "Delete Pattern",
3080             "Are you sure you want to delete\n"
3081             "syntax highlighting patterns for\n"
3082             "language mode %s?", "Yes, Delete", "Cancel",
3083             HighlightDialog.langModeName) == 2)
3084     {
3085         return;
3086     }
3087 
3088     /* if a stored version of the pattern set exists, delete it from the list */
3089     for (psn=0; psn<NPatternSets; psn++)
3090     	if (!strcmp(HighlightDialog.langModeName,
3091     	    	PatternSets[psn]->languageMode))
3092     	    break;
3093     if (psn < NPatternSets) {
3094      	freePatternSet(PatternSets[psn]);
3095    	memmove(&PatternSets[psn], &PatternSets[psn+1],
3096    	    	(NPatternSets-1 - psn) * sizeof(patternSet *));
3097     	NPatternSets--;
3098     }
3099 
3100     /* Free the old dialog information */
3101     for (i=0; i<HighlightDialog.nPatterns; i++)
3102      	freePatternSrc(HighlightDialog.patterns[i], True);
3103 
3104     /* Clear out the dialog */
3105     HighlightDialog.nPatterns = 0;
3106     SetIntText(HighlightDialog.lineContextW, 1);
3107     SetIntText(HighlightDialog.charContextW, 0);
3108     ChangeManagedListData(HighlightDialog.managedListW);
3109 }
3110 
closeCB(Widget w,XtPointer clientData,XtPointer callData)3111 static void closeCB(Widget w, XtPointer clientData, XtPointer callData)
3112 {
3113     /* pop down and destroy the dialog */
3114     CloseAllPopupsFor(HighlightDialog.shell);
3115     XtDestroyWidget(HighlightDialog.shell);
3116 }
3117 
helpCB(Widget w,XtPointer clientData,XtPointer callData)3118 static void helpCB(Widget w, XtPointer clientData, XtPointer callData)
3119 {
3120     Help(HELP_PATTERNS);
3121 }
3122 
patTypeCB(Widget w,XtPointer clientData,XtPointer callData)3123 static void patTypeCB(Widget w, XtPointer clientData, XtPointer callData)
3124 {
3125     updateLabels();
3126 }
3127 
matchTypeCB(Widget w,XtPointer clientData,XtPointer callData)3128 static void matchTypeCB(Widget w, XtPointer clientData, XtPointer callData)
3129 {
3130     updateLabels();
3131 }
3132 
getDisplayedCB(void * oldItem,int explicitRequest,int * abort,void * cbArg)3133 static void *getDisplayedCB(void *oldItem, int explicitRequest, int *abort,
3134     	void *cbArg)
3135 {
3136     highlightPattern *pat;
3137 
3138     /* If the dialog is currently displaying the "new" entry and the
3139        fields are empty, that's just fine */
3140     if (oldItem == NULL && dialogEmpty())
3141     	return NULL;
3142 
3143     /* If there are no problems reading the data, just return it */
3144     pat = readDialogFields(True);
3145     if (pat != NULL)
3146     	return (void *)pat;
3147 
3148     /* If there are problems, and the user didn't ask for the fields to be
3149        read, give more warning */
3150     if (!explicitRequest)
3151     {
3152         if (DialogF(DF_WARN, HighlightDialog.shell, 2, "Discard Entry",
3153                 "Discard incomplete entry\nfor current pattern?", "Keep",
3154                 "Discard") == 2)
3155         {
3156             return oldItem == NULL
3157                     ? NULL
3158                     : (void *)copyPatternSrc((highlightPattern *)oldItem, NULL);
3159         }
3160     }
3161 
3162     /* Do readDialogFields again without "silent" mode to display warning */
3163     pat = readDialogFields(False);
3164     *abort = True;
3165     return NULL;
3166 }
3167 
setDisplayedCB(void * item,void * cbArg)3168 static void setDisplayedCB(void *item, void *cbArg)
3169 {
3170     highlightPattern *pat = (highlightPattern *)item;
3171     int isSubpat, isDeferred, isColorOnly, isRange;
3172 
3173     if (item == NULL) {
3174     	XmTextSetString(HighlightDialog.nameW, "");
3175     	XmTextSetString(HighlightDialog.parentW, "");
3176     	XmTextSetString(HighlightDialog.startW, "");
3177     	XmTextSetString(HighlightDialog.endW, "");
3178     	XmTextSetString(HighlightDialog.errorW, "");
3179     	RadioButtonChangeState(HighlightDialog.topLevelW, True, False);
3180     	RadioButtonChangeState(HighlightDialog.deferredW, False, False);
3181     	RadioButtonChangeState(HighlightDialog.subPatW, False, False);
3182     	RadioButtonChangeState(HighlightDialog.colorPatW, False, False);
3183     	RadioButtonChangeState(HighlightDialog.simpleW, True, False);
3184     	RadioButtonChangeState(HighlightDialog.rangeW, False, False);
3185     	setStyleMenu("Plain");
3186     } else {
3187     	isSubpat = pat->subPatternOf != NULL;
3188     	isDeferred = pat->flags & DEFER_PARSING;
3189     	isColorOnly = pat->flags & COLOR_ONLY;
3190     	isRange = pat->endRE != NULL;
3191     	XmTextSetString(HighlightDialog.nameW, pat->name);
3192     	XmTextSetString(HighlightDialog.parentW, pat->subPatternOf);
3193     	XmTextSetString(HighlightDialog.startW, pat->startRE);
3194     	XmTextSetString(HighlightDialog.endW, pat->endRE);
3195     	XmTextSetString(HighlightDialog.errorW, pat->errorRE);
3196     	RadioButtonChangeState(HighlightDialog.topLevelW,
3197     	    	!isSubpat && !isDeferred, False);
3198     	RadioButtonChangeState(HighlightDialog.deferredW,
3199     	    	!isSubpat && isDeferred, False);
3200     	RadioButtonChangeState(HighlightDialog.subPatW,
3201     	    	isSubpat && !isColorOnly, False);
3202     	RadioButtonChangeState(HighlightDialog.colorPatW,
3203     	    	isSubpat && isColorOnly, False);
3204     	RadioButtonChangeState(HighlightDialog.simpleW, !isRange, False);
3205     	RadioButtonChangeState(HighlightDialog.rangeW, isRange, False);
3206     	setStyleMenu(pat->style);
3207     }
3208     updateLabels();
3209 }
3210 
freeItemCB(void * item)3211 static void freeItemCB(void *item)
3212 {
3213     freePatternSrc((highlightPattern *)item, True);
3214 }
3215 
3216 /*
3217 ** Do a test compile of the patterns currently displayed in the highlight
3218 ** patterns dialog, and display warning dialogs if there are problems
3219 */
checkHighlightDialogData(void)3220 static int checkHighlightDialogData(void)
3221 {
3222     patternSet *patSet;
3223     int result;
3224 
3225     /* Get the pattern information from the dialog */
3226     patSet = getDialogPatternSet();
3227     if (patSet == NULL)
3228     	return False;
3229 
3230     /* Compile the patterns  */
3231     result = patSet->nPatterns == 0 ? True : TestHighlightPatterns(patSet);
3232     freePatternSet(patSet);
3233     return result;
3234 }
3235 
3236 /*
3237 ** Update the text field labels and sensitivity of various fields, based on
3238 ** the settings of the Pattern Type and Matching radio buttons in the highlight
3239 ** patterns dialog.
3240 */
updateLabels(void)3241 static void updateLabels(void)
3242 {
3243     char *startLbl, *endLbl;
3244     int endSense, errSense, matchSense, parentSense;
3245     XmString s1;
3246 
3247     if (XmToggleButtonGetState(HighlightDialog.colorPatW)) {
3248 	startLbl =  "Sub-expressions to Highlight in Parent's Starting \
3249 Regular Expression (\\1, &, etc.)";
3250 	endLbl = "Sub-expressions to Highlight in Parent Pattern's Ending \
3251 Regular Expression";
3252     	endSense = True;
3253     	errSense = False;
3254     	matchSense = False;
3255     	parentSense = True;
3256     } else {
3257     	endLbl = "Ending Regular Expression";
3258     	matchSense = True;
3259     	parentSense = XmToggleButtonGetState(HighlightDialog.subPatW);
3260     	if (XmToggleButtonGetState(HighlightDialog.simpleW)) {
3261     	    startLbl = "Regular Expression to Match";
3262     	    endSense = False;
3263     	    errSense = False;
3264     	} else {
3265     	    startLbl = "Starting Regular Expression";
3266     	    endSense = True;
3267     	    errSense = True;
3268 	}
3269     }
3270 
3271     XtSetSensitive(HighlightDialog.parentLbl, parentSense);
3272     XtSetSensitive(HighlightDialog.parentW, parentSense);
3273     XtSetSensitive(HighlightDialog.endW, endSense);
3274     XtSetSensitive(HighlightDialog.endLbl, endSense);
3275     XtSetSensitive(HighlightDialog.errorW, errSense);
3276     XtSetSensitive(HighlightDialog.errorLbl, errSense);
3277     XtSetSensitive(HighlightDialog.errorLbl, errSense);
3278     XtSetSensitive(HighlightDialog.simpleW, matchSense);
3279     XtSetSensitive(HighlightDialog.rangeW, matchSense);
3280     XtSetSensitive(HighlightDialog.matchLbl, matchSense);
3281     XtVaSetValues(HighlightDialog.startLbl, XmNlabelString,
3282     	    s1=XmStringCreateSimple(startLbl), NULL);
3283     XmStringFree(s1);
3284     XtVaSetValues(HighlightDialog.endLbl, XmNlabelString,
3285     	    s1=XmStringCreateSimple(endLbl), NULL);
3286     XmStringFree(s1);
3287 }
3288 
3289 /*
3290 ** Set the styles menu in the currently displayed highlight dialog to show
3291 ** a particular style
3292 */
setStyleMenu(const char * styleName)3293 static void setStyleMenu(const char *styleName)
3294 {
3295     int i;
3296     Cardinal nItems;
3297     WidgetList items;
3298     Widget selectedItem;
3299     char *itemStyle;
3300 
3301     XtVaGetValues(HighlightDialog.stylePulldown, XmNchildren, &items,
3302     	    XmNnumChildren, &nItems, NULL);
3303     if (nItems == 0)
3304     	return;
3305     selectedItem = items[0];
3306     for (i=0; i<(int)nItems; i++) {
3307     	XtVaGetValues(items[i], XmNuserData, &itemStyle, NULL);
3308     	if (!strcmp(itemStyle, styleName)) {
3309     	    selectedItem = items[i];
3310     	    break;
3311     	}
3312     }
3313     XtVaSetValues(HighlightDialog.styleOptMenu, XmNmenuHistory, selectedItem, NULL);
3314 }
3315 
3316 /*
3317 ** Read the pattern fields of the highlight dialog, and produce an allocated
3318 ** highlightPattern structure reflecting the contents, or pop up dialogs
3319 ** telling the user what's wrong (Passing "silent" as True, suppresses these
3320 ** dialogs).  Returns NULL on error.
3321 */
readDialogFields(int silent)3322 static highlightPattern *readDialogFields(int silent)
3323 {
3324     highlightPattern *pat;
3325     char *inPtr, *outPtr, *style;
3326     Widget selectedItem;
3327     int colorOnly;
3328 
3329     /* Allocate a pattern source structure to return, zero out fields
3330        so that the whole pattern can be freed on error with freePatternSrc */
3331     pat = (highlightPattern *)NEditMalloc(sizeof(highlightPattern));
3332     pat->endRE = NULL;
3333     pat->errorRE = NULL;
3334     pat->style = NULL;
3335     pat->subPatternOf = NULL;
3336 
3337     /* read the type buttons */
3338     pat->flags = 0;
3339     colorOnly = XmToggleButtonGetState(HighlightDialog.colorPatW);
3340     if (XmToggleButtonGetState(HighlightDialog.deferredW))
3341     	pat->flags |= DEFER_PARSING;
3342     else if (colorOnly)
3343     	pat->flags = COLOR_ONLY;
3344 
3345     /* read the name field */
3346     pat->name = ReadSymbolicFieldTextWidget(HighlightDialog.nameW,
3347     	    "highlight pattern name", silent);
3348     if (pat->name == NULL) {
3349     	NEditFree(pat);
3350     	return NULL;
3351     }
3352 
3353     if (*pat->name == '\0')
3354     {
3355         if (!silent)
3356         {
3357             DialogF(DF_WARN, HighlightDialog.shell, 1, "Pattern Name",
3358                     "Please specify a name\nfor the pattern", "OK");
3359             XmProcessTraversal(HighlightDialog.nameW, XmTRAVERSE_CURRENT);
3360         }
3361         NEditFree(pat->name);
3362         NEditFree(pat);
3363         return NULL;
3364     }
3365 
3366     /* read the startRE field */
3367     pat->startRE = XmTextGetString(HighlightDialog.startW);
3368     if (*pat->startRE == '\0')
3369     {
3370         if (!silent)
3371         {
3372             DialogF(DF_WARN, HighlightDialog.shell, 1, "Matching Regex",
3373                     "Please specify a regular\nexpression to match", "OK");
3374             XmProcessTraversal(HighlightDialog.startW, XmTRAVERSE_CURRENT);
3375         }
3376         freePatternSrc(pat, True);
3377         return NULL;
3378     }
3379 
3380     /* Make sure coloring patterns contain only sub-expression references
3381        and put it in replacement regular-expression form */
3382     if (colorOnly)
3383     {
3384         for (inPtr=pat->startRE, outPtr=pat->startRE; *inPtr!='\0'; inPtr++)
3385         {
3386             if (*inPtr!=' ' && *inPtr!='\t')
3387             {
3388                 *outPtr++ = *inPtr;
3389             }
3390         }
3391 
3392         *outPtr = '\0';
3393         if (strspn(pat->startRE, "&\\123456789 \t") != strlen(pat->startRE)
3394                 || (*pat->startRE != '\\' && *pat->startRE != '&')
3395                 || strstr(pat->startRE, "\\\\") != NULL)
3396         {
3397             if (!silent)
3398             {
3399                 DialogF(DF_WARN, HighlightDialog.shell, 1, "Pattern Error",
3400                         "The expression field in patterns which specify highlighting for\n"
3401                         "a parent, must contain only sub-expression references in regular\n"
3402                         "expression replacement form (&\\1\\2 etc.).  See Help -> Regular\n"
3403                         "Expressions and Help -> Syntax Highlighting for more information",
3404                         "OK");
3405                 XmProcessTraversal(HighlightDialog.startW, XmTRAVERSE_CURRENT);
3406             }
3407             freePatternSrc(pat, True);
3408             return NULL;
3409         }
3410     }
3411 
3412     /* read the parent field */
3413     if (XmToggleButtonGetState(HighlightDialog.subPatW) || colorOnly)
3414     {
3415         if (TextWidgetIsBlank(HighlightDialog.parentW))
3416         {
3417             if (!silent)
3418             {
3419                 DialogF(DF_WARN, HighlightDialog.shell, 1,
3420                         "Specify Parent Pattern",
3421                         "Please specify a parent pattern", "OK");
3422                 XmProcessTraversal(HighlightDialog.parentW, XmTRAVERSE_CURRENT);
3423             }
3424             freePatternSrc(pat, True);
3425             return NULL;
3426         }
3427         pat->subPatternOf = XmTextGetString(HighlightDialog.parentW);
3428     }
3429 
3430     /* read the styles option menu */
3431     XtVaGetValues(HighlightDialog.styleOptMenu, XmNmenuHistory, &selectedItem, NULL);
3432     XtVaGetValues(selectedItem, XmNuserData, &style, NULL);
3433     pat->style = (char*)NEditMalloc(strlen(style) + 1);
3434     strcpy(pat->style, style);
3435 
3436 
3437     /* read the endRE field */
3438     if (colorOnly || XmToggleButtonGetState(HighlightDialog.rangeW))
3439     {
3440         pat->endRE = XmTextGetString(HighlightDialog.endW);
3441         if (!colorOnly && *pat->endRE == '\0')
3442         {
3443             if (!silent)
3444             {
3445                 DialogF(DF_WARN, HighlightDialog.shell, 1, "Specify Regex",
3446                         "Please specify an ending\nregular expression",
3447                         "OK");
3448                 XmProcessTraversal(HighlightDialog.endW, XmTRAVERSE_CURRENT);
3449             }
3450             freePatternSrc(pat, True);
3451             return NULL;
3452         }
3453     }
3454 
3455     /* read the errorRE field */
3456     if (XmToggleButtonGetState(HighlightDialog.rangeW)) {
3457 	pat->errorRE = XmTextGetString(HighlightDialog.errorW);
3458 	if (*pat->errorRE == '\0') {
3459             NEditFree(pat->errorRE);
3460             pat->errorRE = NULL;
3461 	}
3462     }
3463     return pat;
3464 }
3465 
3466 /*
3467 ** Returns true if the pattern fields of the highlight dialog are set to
3468 ** the default ("New" pattern) state.
3469 */
dialogEmpty(void)3470 static int dialogEmpty(void)
3471 {
3472     return TextWidgetIsBlank(HighlightDialog.nameW) &&
3473 	    XmToggleButtonGetState(HighlightDialog.topLevelW) &&
3474 	    XmToggleButtonGetState(HighlightDialog.simpleW) &&
3475 	    TextWidgetIsBlank(HighlightDialog.parentW) &&
3476 	    TextWidgetIsBlank(HighlightDialog.startW) &&
3477 	    TextWidgetIsBlank(HighlightDialog.endW) &&
3478 	    TextWidgetIsBlank(HighlightDialog.errorW);
3479 }
3480 
3481 /*
3482 ** Update the pattern set being edited in the Syntax Highlighting dialog
3483 ** with the information that the dialog is currently displaying, and
3484 ** apply changes to any window which is currently using the patterns.
3485 */
updatePatternSet(void)3486 static int updatePatternSet(void)
3487 {
3488     patternSet *patSet;
3489     WindowInfo *window;
3490     int psn, oldNum = -1;
3491 
3492 
3493     /* Make sure the patterns are valid and compile */
3494     if (!checkHighlightDialogData())
3495     	return False;
3496 
3497     /* Get the current data */
3498     patSet = getDialogPatternSet();
3499     if (patSet == NULL)
3500     	return False;
3501 
3502     /* Find the pattern being modified */
3503     for (psn=0; psn<NPatternSets; psn++)
3504     	if (!strcmp(HighlightDialog.langModeName,
3505     	    	PatternSets[psn]->languageMode))
3506     	    break;
3507 
3508     /* If it's a new pattern, add it at the end, otherwise free the
3509        existing pattern set and replace it */
3510     if (psn == NPatternSets) {
3511     	PatternSets[NPatternSets++] = patSet;
3512         oldNum = 0;
3513     } else {
3514         oldNum = PatternSets[psn]->nPatterns;
3515 	freePatternSet(PatternSets[psn]);
3516 	PatternSets[psn] = patSet;
3517     }
3518 
3519     /* Find windows that are currently using this pattern set and
3520        re-do the highlighting */
3521     for (window = WindowList; window != NULL; window = window->next) {
3522         if (patSet->nPatterns > 0) {
3523             if (window->languageMode != PLAIN_LANGUAGE_MODE
3524                     && 0 == strcmp(LanguageModeName(window->languageMode),
3525                         patSet->languageMode)) {
3526                 /*  The user worked on the current document's language mode, so
3527                     we have to make some changes immediately. For inactive
3528                     modes, the changes will be activated on activation.  */
3529                 if (oldNum == 0) {
3530                     /*  Highlighting (including menu entry) was deactivated in
3531                         this function or in preferences.c::reapplyLanguageMode()
3532                         if the old set had no patterns, so reactivate menu entry. */
3533                     if (IsTopDocument(window)) {
3534                         XtSetSensitive(window->highlightItem, True);
3535                     }
3536 
3537                     /*  Reactivate highlighting if it's default  */
3538                     window->highlightSyntax = GetPrefHighlightSyntax();
3539                 }
3540 
3541                 if (window->highlightSyntax) {
3542                     StopHighlighting(window);
3543                     if (IsTopDocument(window)) {
3544                         XtSetSensitive(window->highlightItem, True);
3545                         SetToggleButtonState(window, window->highlightItem,
3546                                 True, False);
3547                     }
3548                     StartHighlighting(window, True);
3549                 }
3550             }
3551         } else {
3552             /*  No pattern in pattern set. This will probably not happen much,
3553                 but you never know.  */
3554             StopHighlighting(window);
3555             window->highlightSyntax = False;
3556 
3557             if (IsTopDocument(window)) {
3558                 XtSetSensitive(window->highlightItem, False);
3559                 SetToggleButtonState(window, window->highlightItem, False, False);
3560             }
3561         }
3562     }
3563 
3564     /* Note that preferences have been changed */
3565     MarkPrefsChanged();
3566 
3567     return True;
3568 }
3569 
3570 /*
3571 ** Get the current information that the user has entered in the syntax
3572 ** highlighting dialog.  Return NULL if the data is currently invalid
3573 */
getDialogPatternSet(void)3574 static patternSet *getDialogPatternSet(void)
3575 {
3576     int i, lineContext, charContext;
3577     patternSet *patSet;
3578 
3579     /* Get the current contents of the "patterns" dialog fields */
3580     if (!UpdateManagedList(HighlightDialog.managedListW, True))
3581     	return NULL;
3582 
3583     /* Get the line and character context values */
3584     if (GetIntTextWarn(HighlightDialog.lineContextW, &lineContext,
3585     	    "context lines", True) != TEXT_READ_OK)
3586     	return NULL;
3587     if (GetIntTextWarn(HighlightDialog.charContextW, &charContext,
3588     	    "context lines", True) != TEXT_READ_OK)
3589     	return NULL;
3590 
3591     /* Allocate a new pattern set structure and copy the fields read from the
3592        dialog, including the modified pattern list into it */
3593     patSet = (patternSet *)NEditMalloc(sizeof(patternSet));
3594     patSet->languageMode = NEditStrdup(HighlightDialog.langModeName);
3595     patSet->lineContext = lineContext;
3596     patSet->charContext = charContext;
3597     patSet->nPatterns = HighlightDialog.nPatterns;
3598     patSet->patterns = (highlightPattern *)NEditMalloc(sizeof(highlightPattern) *
3599     	    HighlightDialog.nPatterns);
3600     for (i=0; i<HighlightDialog.nPatterns; i++)
3601     	copyPatternSrc(HighlightDialog.patterns[i], &patSet->patterns[i]);
3602     return patSet;
3603 }
3604 
3605 /*
3606 ** Return True if "patSet1" and "patSet2" differ
3607 */
patternSetsDiffer(patternSet * patSet1,patternSet * patSet2)3608 static int patternSetsDiffer(patternSet *patSet1, patternSet *patSet2)
3609 {
3610     int i;
3611     highlightPattern *pat1, *pat2;
3612 
3613     if (patSet1->lineContext != patSet2->lineContext)
3614     	return True;
3615     if (patSet1->charContext != patSet2->charContext)
3616     	return True;
3617     if (patSet1->nPatterns != patSet2->nPatterns)
3618     	return True;
3619     for (i=0; i<patSet2->nPatterns; i++) {
3620     	pat1 = &patSet1->patterns[i];
3621     	pat2 = &patSet2->patterns[i];
3622     	if (pat1->flags != pat2->flags)
3623     	    return True;
3624     	if (AllocatedStringsDiffer(pat1->name, pat2->name))
3625     	    return True;
3626     	if (AllocatedStringsDiffer(pat1->startRE, pat2->startRE))
3627     	    return True;
3628     	if (AllocatedStringsDiffer(pat1->endRE, pat2->endRE))
3629     	    return True;
3630     	if (AllocatedStringsDiffer(pat1->errorRE, pat2->errorRE))
3631     	    return True;
3632     	if (AllocatedStringsDiffer(pat1->style, pat2->style))
3633     	    return True;
3634     	if (AllocatedStringsDiffer(pat1->subPatternOf, pat2->subPatternOf))
3635     	    return True;
3636     }
3637     return False;
3638 }
3639 
3640 /*
3641 ** Copy a highlight pattern data structure and all of the allocated data
3642 ** it contains.  If "copyTo" is non-null, use that as the top-level structure,
3643 ** otherwise allocate a new highlightPattern structure and return it as the
3644 ** function value.
3645 */
copyPatternSrc(highlightPattern * pat,highlightPattern * copyTo)3646 static highlightPattern *copyPatternSrc(highlightPattern *pat,
3647     	highlightPattern *copyTo)
3648 {
3649     highlightPattern *newPat;
3650 
3651     if (copyTo == NULL)
3652     	newPat = (highlightPattern *)NEditMalloc(sizeof(highlightPattern));
3653     else
3654     	newPat = copyTo;
3655     newPat->name = NEditStrdup(pat->name);
3656     newPat->startRE = NEditStrdup(pat->startRE);
3657     newPat->endRE = NEditStrdup(pat->endRE);
3658     newPat->errorRE = NEditStrdup(pat->errorRE);
3659     newPat->style = NEditStrdup(pat->style);
3660     newPat->subPatternOf = NEditStrdup(pat->subPatternOf);
3661     newPat->flags = pat->flags;
3662     return newPat;
3663 }
3664 
3665 /*
3666 ** Free the allocated memory contained in a highlightPattern data structure
3667 ** If "freeStruct" is true, free the structure itself as well.
3668 */
freePatternSrc(highlightPattern * pat,int freeStruct)3669 static void freePatternSrc(highlightPattern *pat, int freeStruct)
3670 {
3671     NEditFree(pat->name);
3672     NEditFree(pat->startRE);
3673     NEditFree(pat->endRE);
3674     NEditFree(pat->errorRE);
3675     NEditFree(pat->style);
3676     NEditFree(pat->subPatternOf);
3677     if (freeStruct)
3678     	NEditFree(pat);
3679 }
3680 
3681 /*
3682 ** Free the allocated memory contained in a patternSet data structure
3683 ** If "freeStruct" is true, free the structure itself as well.
3684 */
freePatternSet(patternSet * p)3685 static void freePatternSet(patternSet *p)
3686 {
3687     int i;
3688 
3689     for (i=0; i<p->nPatterns; i++)
3690     	freePatternSrc(&p->patterns[i], False);
3691     NEditFree(p->languageMode);
3692     NEditFree(p->patterns);
3693     NEditFree(p);
3694 }
3695 
3696 #if 0
3697 /*
3698 ** Free the allocated memory contained in a patternSet data structure
3699 ** If "freeStruct" is true, free the structure itself as well.
3700 */
3701 static int lookupNamedPattern(patternSet *p, char *patternName)
3702 {
3703     int i;
3704 
3705     for (i=0; i<p->nPatterns; i++)
3706       if (strcmp(p->patterns[i].name, patternName))
3707               return i;
3708     return -1;
3709 }
3710 #endif
3711 
3712 /*
3713 ** Find the index into the HighlightStyles array corresponding to "styleName".
3714 ** If styleName is not found, return -1.
3715 */
lookupNamedStyle(const char * styleName)3716 static int lookupNamedStyle(const char *styleName)
3717 {
3718     int i;
3719 
3720     for (i = 0; i < NHighlightStyles; i++)
3721     {
3722         if (!strcmp(styleName, HighlightStyles[i]->name))
3723         {
3724             return i;
3725         }
3726     }
3727 
3728     return -1;
3729 }
3730 
3731 /*
3732 ** Returns a unique number of a given style name
3733 */
IndexOfNamedStyle(const char * styleName)3734 int IndexOfNamedStyle(const char *styleName)
3735 {
3736     return lookupNamedStyle(styleName);
3737 }
3738 
3739 /*
3740 ** Write the string representation of int "i" to a static area, and
3741 ** return a pointer to it.
3742 */
intToStr(int i)3743 static char *intToStr(int i)
3744 {
3745     static char outBuf[12];
3746 
3747     sprintf(outBuf, "%d", i);
3748     return outBuf;
3749 }
3750