NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
LexOthers.cxx
Go to the documentation of this file.
1// Scintilla source code edit control
6// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
7// The License.txt file describes the conditions under which this software may be distributed.
8
9#include <stdlib.h>
10#include <string.h>
11#include <stdio.h>
12#include <stdarg.h>
13#include <assert.h>
14#include <ctype.h>
15
16#include <string>
17#include <map>
18
19#include "ILexer.h"
20#include "Scintilla.h"
21#include "SciLexer.h"
22
23#include "WordList.h"
24#include "LexAccessor.h"
25#include "Accessor.h"
26#include "StyleContext.h"
27#include "CharacterSet.h"
28#include "LexerModule.h"
29#include "OptionSet.h"
30
31#ifdef SCI_NAMESPACE
32using namespace Scintilla;
33#endif
34
35static bool strstart(const char *haystack, const char *needle) {
36 return strncmp(haystack, needle, strlen(needle)) == 0;
37}
38
39static bool Is0To9(char ch) {
40 return (ch >= '0') && (ch <= '9');
41}
42
43static bool Is1To9(char ch) {
44 return (ch >= '1') && (ch <= '9');
45}
46
47static bool IsAlphabetic(int ch) {
48 return isascii(ch) && isalpha(ch);
49}
50
51static inline bool AtEOL(Accessor &styler, unsigned int i) {
52 return (styler[i] == '\n') ||
53 ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
54}
55
56// Tests for BATCH Operators
57static bool IsBOperator(char ch) {
58 return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') ||
59 (ch == '|') || (ch == '?') || (ch == '*');
60}
61
62// Tests for BATCH Separators
63static bool IsBSeparator(char ch) {
64 return (ch == '\\') || (ch == '.') || (ch == ';') ||
65 (ch == '\"') || (ch == '\'') || (ch == '/');
66}
67
69 char *lineBuffer,
70 unsigned int lengthLine,
71 unsigned int startLine,
72 unsigned int endPos,
73 WordList *keywordlists[],
74 Accessor &styler) {
75
76 unsigned int offset = 0; // Line Buffer Offset
77 unsigned int cmdLoc; // External Command / Program Location
78 char wordBuffer[81]; // Word Buffer - large to catch long paths
79 unsigned int wbl; // Word Buffer Length
80 unsigned int wbo; // Word Buffer Offset - also Special Keyword Buffer Length
81 WordList &keywords = *keywordlists[0]; // Internal Commands
82 WordList &keywords2 = *keywordlists[1]; // External Commands (optional)
83
84 // CHOICE, ECHO, GOTO, PROMPT and SET have Default Text that may contain Regular Keywords
85 // Toggling Regular Keyword Checking off improves readability
86 // Other Regular Keywords and External Commands / Programs might also benefit from toggling
87 // Need a more robust algorithm to properly toggle Regular Keyword Checking
88 bool continueProcessing = true; // Used to toggle Regular Keyword Checking
89 // Special Keywords are those that allow certain characters without whitespace after the command
90 // Examples are: cd. cd\ md. rd. dir| dir> echo: echo. path=
91 // Special Keyword Buffer used to determine if the first n characters is a Keyword
92 char sKeywordBuffer[10]; // Special Keyword Buffer
93 bool sKeywordFound; // Exit Special Keyword for-loop if found
94
95 // Skip initial spaces
96 while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
97 offset++;
98 }
99 // Colorize Default Text
100 styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
101 // Set External Command / Program Location
102 cmdLoc = offset;
103
104 // Check for Fake Label (Comment) or Real Label - return if found
105 if (lineBuffer[offset] == ':') {
106 if (lineBuffer[offset + 1] == ':') {
107 // Colorize Fake Label (Comment) - :: is similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm
108 styler.ColourTo(endPos, SCE_BAT_COMMENT);
109 } else {
110 // Colorize Real Label
111 styler.ColourTo(endPos, SCE_BAT_LABEL);
112 }
113 return;
114 // Check for Drive Change (Drive Change is internal command) - return if found
115 } else if ((IsAlphabetic(lineBuffer[offset])) &&
116 (lineBuffer[offset + 1] == ':') &&
117 ((isspacechar(lineBuffer[offset + 2])) ||
118 (((lineBuffer[offset + 2] == '\\')) &&
119 (isspacechar(lineBuffer[offset + 3]))))) {
120 // Colorize Regular Keyword
121 styler.ColourTo(endPos, SCE_BAT_WORD);
122 return;
123 }
124
125 // Check for Hide Command (@ECHO OFF/ON)
126 if (lineBuffer[offset] == '@') {
127 styler.ColourTo(startLine + offset, SCE_BAT_HIDE);
128 offset++;
129 }
130 // Skip next spaces
131 while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
132 offset++;
133 }
134
135 // Read remainder of line word-at-a-time or remainder-of-word-at-a-time
136 while (offset < lengthLine) {
137 if (offset > startLine) {
138 // Colorize Default Text
139 styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
140 }
141 // Copy word from Line Buffer into Word Buffer
142 wbl = 0;
143 for (; offset < lengthLine && wbl < 80 &&
144 !isspacechar(lineBuffer[offset]); wbl++, offset++) {
145 wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
146 }
147 wordBuffer[wbl] = '\0';
148 wbo = 0;
149
150 // Check for Comment - return if found
151 if (CompareCaseInsensitive(wordBuffer, "rem") == 0) {
152 styler.ColourTo(endPos, SCE_BAT_COMMENT);
153 return;
154 }
155 // Check for Separator
156 if (IsBSeparator(wordBuffer[0])) {
157 // Check for External Command / Program
158 if ((cmdLoc == offset - wbl) &&
159 ((wordBuffer[0] == ':') ||
160 (wordBuffer[0] == '\\') ||
161 (wordBuffer[0] == '.'))) {
162 // Reset Offset to re-process remainder of word
163 offset -= (wbl - 1);
164 // Colorize External Command / Program
165 if (!keywords2) {
166 styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
167 } else if (keywords2.InList(wordBuffer)) {
168 styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
169 } else {
170 styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
171 }
172 // Reset External Command / Program Location
173 cmdLoc = offset;
174 } else {
175 // Reset Offset to re-process remainder of word
176 offset -= (wbl - 1);
177 // Colorize Default Text
178 styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
179 }
180 // Check for Regular Keyword in list
181 } else if ((keywords.InList(wordBuffer)) &&
182 (continueProcessing)) {
183 // ECHO, GOTO, PROMPT and SET require no further Regular Keyword Checking
184 if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) ||
185 (CompareCaseInsensitive(wordBuffer, "goto") == 0) ||
186 (CompareCaseInsensitive(wordBuffer, "prompt") == 0) ||
187 (CompareCaseInsensitive(wordBuffer, "set") == 0)) {
188 continueProcessing = false;
189 }
190 // Identify External Command / Program Location for ERRORLEVEL, and EXIST
191 if ((CompareCaseInsensitive(wordBuffer, "errorlevel") == 0) ||
192 (CompareCaseInsensitive(wordBuffer, "exist") == 0)) {
193 // Reset External Command / Program Location
194 cmdLoc = offset;
195 // Skip next spaces
196 while ((cmdLoc < lengthLine) &&
197 (isspacechar(lineBuffer[cmdLoc]))) {
198 cmdLoc++;
199 }
200 // Skip comparison
201 while ((cmdLoc < lengthLine) &&
202 (!isspacechar(lineBuffer[cmdLoc]))) {
203 cmdLoc++;
204 }
205 // Skip next spaces
206 while ((cmdLoc < lengthLine) &&
207 (isspacechar(lineBuffer[cmdLoc]))) {
208 cmdLoc++;
209 }
210 // Identify External Command / Program Location for CALL, DO, LOADHIGH and LH
211 } else if ((CompareCaseInsensitive(wordBuffer, "call") == 0) ||
212 (CompareCaseInsensitive(wordBuffer, "do") == 0) ||
213 (CompareCaseInsensitive(wordBuffer, "loadhigh") == 0) ||
214 (CompareCaseInsensitive(wordBuffer, "lh") == 0)) {
215 // Reset External Command / Program Location
216 cmdLoc = offset;
217 // Skip next spaces
218 while ((cmdLoc < lengthLine) &&
219 (isspacechar(lineBuffer[cmdLoc]))) {
220 cmdLoc++;
221 }
222 }
223 // Colorize Regular keyword
224 styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD);
225 // No need to Reset Offset
226 // Check for Special Keyword in list, External Command / Program, or Default Text
227 } else if ((wordBuffer[0] != '%') &&
228 (wordBuffer[0] != '!') &&
229 (!IsBOperator(wordBuffer[0])) &&
230 (continueProcessing)) {
231 // Check for Special Keyword
232 // Affected Commands are in Length range 2-6
233 // Good that ERRORLEVEL, EXIST, CALL, DO, LOADHIGH, and LH are unaffected
234 sKeywordFound = false;
235 for (unsigned int keywordLength = 2; keywordLength < wbl && keywordLength < 7 && !sKeywordFound; keywordLength++) {
236 wbo = 0;
237 // Copy Keyword Length from Word Buffer into Special Keyword Buffer
238 for (; wbo < keywordLength; wbo++) {
239 sKeywordBuffer[wbo] = static_cast<char>(wordBuffer[wbo]);
240 }
241 sKeywordBuffer[wbo] = '\0';
242 // Check for Special Keyword in list
243 if ((keywords.InList(sKeywordBuffer)) &&
244 ((IsBOperator(wordBuffer[wbo])) ||
245 (IsBSeparator(wordBuffer[wbo])))) {
246 sKeywordFound = true;
247 // ECHO requires no further Regular Keyword Checking
248 if (CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) {
249 continueProcessing = false;
250 }
251 // Colorize Special Keyword as Regular Keyword
252 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_WORD);
253 // Reset Offset to re-process remainder of word
254 offset -= (wbl - wbo);
255 }
256 }
257 // Check for External Command / Program or Default Text
258 if (!sKeywordFound) {
259 wbo = 0;
260 // Check for External Command / Program
261 if (cmdLoc == offset - wbl) {
262 // Read up to %, Operator or Separator
263 while ((wbo < wbl) &&
264 (wordBuffer[wbo] != '%') &&
265 (wordBuffer[wbo] != '!') &&
266 (!IsBOperator(wordBuffer[wbo])) &&
267 (!IsBSeparator(wordBuffer[wbo]))) {
268 wbo++;
269 }
270 // Reset External Command / Program Location
271 cmdLoc = offset - (wbl - wbo);
272 // Reset Offset to re-process remainder of word
273 offset -= (wbl - wbo);
274 // CHOICE requires no further Regular Keyword Checking
275 if (CompareCaseInsensitive(wordBuffer, "choice") == 0) {
276 continueProcessing = false;
277 }
278 // Check for START (and its switches) - What follows is External Command \ Program
279 if (CompareCaseInsensitive(wordBuffer, "start") == 0) {
280 // Reset External Command / Program Location
281 cmdLoc = offset;
282 // Skip next spaces
283 while ((cmdLoc < lengthLine) &&
284 (isspacechar(lineBuffer[cmdLoc]))) {
285 cmdLoc++;
286 }
287 // Reset External Command / Program Location if command switch detected
288 if (lineBuffer[cmdLoc] == '/') {
289 // Skip command switch
290 while ((cmdLoc < lengthLine) &&
291 (!isspacechar(lineBuffer[cmdLoc]))) {
292 cmdLoc++;
293 }
294 // Skip next spaces
295 while ((cmdLoc < lengthLine) &&
296 (isspacechar(lineBuffer[cmdLoc]))) {
297 cmdLoc++;
298 }
299 }
300 }
301 // Colorize External Command / Program
302 if (!keywords2) {
303 styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
304 } else if (keywords2.InList(wordBuffer)) {
305 styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND);
306 } else {
307 styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
308 }
309 // No need to Reset Offset
310 // Check for Default Text
311 } else {
312 // Read up to %, Operator or Separator
313 while ((wbo < wbl) &&
314 (wordBuffer[wbo] != '%') &&
315 (wordBuffer[wbo] != '!') &&
316 (!IsBOperator(wordBuffer[wbo])) &&
317 (!IsBSeparator(wordBuffer[wbo]))) {
318 wbo++;
319 }
320 // Colorize Default Text
321 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT);
322 // Reset Offset to re-process remainder of word
323 offset -= (wbl - wbo);
324 }
325 }
326 // Check for Argument (%n), Environment Variable (%x...%) or Local Variable (%%a)
327 } else if (wordBuffer[0] == '%') {
328 // Colorize Default Text
329 styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT);
330 wbo++;
331 // Search to end of word for second % (can be a long path)
332 while ((wbo < wbl) &&
333 (wordBuffer[wbo] != '%') &&
334 (!IsBOperator(wordBuffer[wbo])) &&
335 (!IsBSeparator(wordBuffer[wbo]))) {
336 wbo++;
337 }
338 // Check for Argument (%n) or (%*)
339 if (((Is0To9(wordBuffer[1])) || (wordBuffer[1] == '*')) &&
340 (wordBuffer[wbo] != '%')) {
341 // Check for External Command / Program
342 if (cmdLoc == offset - wbl) {
343 cmdLoc = offset - (wbl - 2);
344 }
345 // Colorize Argument
346 styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_IDENTIFIER);
347 // Reset Offset to re-process remainder of word
348 offset -= (wbl - 2);
349 // Check for Expanded Argument (%~...) / Variable (%%~...)
350 } else if (((wbl > 1) && (wordBuffer[1] == '~')) ||
351 ((wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] == '~'))) {
352 // Check for External Command / Program
353 if (cmdLoc == offset - wbl) {
354 cmdLoc = offset - (wbl - wbo);
355 }
356 // Colorize Expanded Argument / Variable
357 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER);
358 // Reset Offset to re-process remainder of word
359 offset -= (wbl - wbo);
360 // Check for Environment Variable (%x...%)
361 } else if ((wordBuffer[1] != '%') &&
362 (wordBuffer[wbo] == '%')) {
363 wbo++;
364 // Check for External Command / Program
365 if (cmdLoc == offset - wbl) {
366 cmdLoc = offset - (wbl - wbo);
367 }
368 // Colorize Environment Variable
369 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER);
370 // Reset Offset to re-process remainder of word
371 offset -= (wbl - wbo);
372 // Check for Local Variable (%%a)
373 } else if (
374 (wbl > 2) &&
375 (wordBuffer[1] == '%') &&
376 (wordBuffer[2] != '%') &&
377 (!IsBOperator(wordBuffer[2])) &&
378 (!IsBSeparator(wordBuffer[2]))) {
379 // Check for External Command / Program
380 if (cmdLoc == offset - wbl) {
381 cmdLoc = offset - (wbl - 3);
382 }
383 // Colorize Local Variable
384 styler.ColourTo(startLine + offset - 1 - (wbl - 3), SCE_BAT_IDENTIFIER);
385 // Reset Offset to re-process remainder of word
386 offset -= (wbl - 3);
387 }
388 // Check for Environment Variable (!x...!)
389 } else if (wordBuffer[0] == '!') {
390 // Colorize Default Text
391 styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT);
392 wbo++;
393 // Search to end of word for second ! (can be a long path)
394 while ((wbo < wbl) &&
395 (wordBuffer[wbo] != '!') &&
396 (!IsBOperator(wordBuffer[wbo])) &&
397 (!IsBSeparator(wordBuffer[wbo]))) {
398 wbo++;
399 }
400 if (wordBuffer[wbo] == '!') {
401 wbo++;
402 // Check for External Command / Program
403 if (cmdLoc == offset - wbl) {
404 cmdLoc = offset - (wbl - wbo);
405 }
406 // Colorize Environment Variable
407 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER);
408 // Reset Offset to re-process remainder of word
409 offset -= (wbl - wbo);
410 }
411 // Check for Operator
412 } else if (IsBOperator(wordBuffer[0])) {
413 // Colorize Default Text
414 styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT);
415 // Check for Comparison Operator
416 if ((wordBuffer[0] == '=') && (wordBuffer[1] == '=')) {
417 // Identify External Command / Program Location for IF
418 cmdLoc = offset;
419 // Skip next spaces
420 while ((cmdLoc < lengthLine) &&
421 (isspacechar(lineBuffer[cmdLoc]))) {
422 cmdLoc++;
423 }
424 // Colorize Comparison Operator
425 styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_BAT_OPERATOR);
426 // Reset Offset to re-process remainder of word
427 offset -= (wbl - 2);
428 // Check for Pipe Operator
429 } else if (wordBuffer[0] == '|') {
430 // Reset External Command / Program Location
431 cmdLoc = offset - wbl + 1;
432 // Skip next spaces
433 while ((cmdLoc < lengthLine) &&
434 (isspacechar(lineBuffer[cmdLoc]))) {
435 cmdLoc++;
436 }
437 // Colorize Pipe Operator
438 styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR);
439 // Reset Offset to re-process remainder of word
440 offset -= (wbl - 1);
441 // Check for Other Operator
442 } else {
443 // Check for > Operator
444 if (wordBuffer[0] == '>') {
445 // Turn Keyword and External Command / Program checking back on
446 continueProcessing = true;
447 }
448 // Colorize Other Operator
449 styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_BAT_OPERATOR);
450 // Reset Offset to re-process remainder of word
451 offset -= (wbl - 1);
452 }
453 // Check for Default Text
454 } else {
455 // Read up to %, Operator or Separator
456 while ((wbo < wbl) &&
457 (wordBuffer[wbo] != '%') &&
458 (wordBuffer[wbo] != '!') &&
459 (!IsBOperator(wordBuffer[wbo])) &&
460 (!IsBSeparator(wordBuffer[wbo]))) {
461 wbo++;
462 }
463 // Colorize Default Text
464 styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_DEFAULT);
465 // Reset Offset to re-process remainder of word
466 offset -= (wbl - wbo);
467 }
468 // Skip next spaces - nothing happens if Offset was Reset
469 while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
470 offset++;
471 }
472 }
473 // Colorize Default Text for remainder of line - currently not lexed
474 styler.ColourTo(endPos, SCE_BAT_DEFAULT);
475}
476
478 unsigned int startPos,
479 int length,
480 int /*initStyle*/,
481 WordList *keywordlists[],
482 Accessor &styler) {
483
484 char lineBuffer[1024];
485
486 styler.StartAt(startPos);
487 styler.StartSegment(startPos);
488 unsigned int linePos = 0;
489 unsigned int startLine = startPos;
490 for (unsigned int i = startPos; i < startPos + length; i++) {
491 lineBuffer[linePos++] = styler[i];
492 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
493 // End of line (or of line buffer) met, colourise it
494 lineBuffer[linePos] = '\0';
495 ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywordlists, styler);
496 linePos = 0;
497 startLine = i + 1;
498 }
499 }
500 if (linePos > 0) { // Last line does not have ending characters
501 lineBuffer[linePos] = '\0';
502 ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
503 keywordlists, styler);
504 }
505}
506
507#define DIFF_BUFFER_START_SIZE 16
508// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE
509// characters of each line to classify the line.
510
511static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
512 // It is needed to remember the current state to recognize starting
513 // comment lines before the first "diff " or "--- ". If a real
514 // difference starts then each line starting with ' ' is a whitespace
515 // otherwise it is considered a comment (Only in..., Binary file...)
516 if (0 == strncmp(lineBuffer, "diff ", 5)) {
517 styler.ColourTo(endLine, SCE_DIFF_COMMAND);
518 } else if (0 == strncmp(lineBuffer, "Index: ", 7)) { // For subversion's diff
519 styler.ColourTo(endLine, SCE_DIFF_COMMAND);
520 } else if (0 == strncmp(lineBuffer, "---", 3) && lineBuffer[3] != '-') {
521 // In a context diff, --- appears in both the header and the position markers
522 if (lineBuffer[3] == ' ' && atoi(lineBuffer + 4) && !strchr(lineBuffer, '/'))
523 styler.ColourTo(endLine, SCE_DIFF_POSITION);
524 else if (lineBuffer[3] == '\r' || lineBuffer[3] == '\n')
525 styler.ColourTo(endLine, SCE_DIFF_POSITION);
526 else
527 styler.ColourTo(endLine, SCE_DIFF_HEADER);
528 } else if (0 == strncmp(lineBuffer, "+++ ", 4)) {
529 // I don't know of any diff where "+++ " is a position marker, but for
530 // consistency, do the same as with "--- " and "*** ".
531 if (atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
532 styler.ColourTo(endLine, SCE_DIFF_POSITION);
533 else
534 styler.ColourTo(endLine, SCE_DIFF_HEADER);
535 } else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff
536 styler.ColourTo(endLine, SCE_DIFF_HEADER);
537 } else if (0 == strncmp(lineBuffer, "***", 3)) {
538 // In a context diff, *** appears in both the header and the position markers.
539 // Also ******** is a chunk header, but here it's treated as part of the
540 // position marker since there is no separate style for a chunk header.
541 if (lineBuffer[3] == ' ' && atoi(lineBuffer+4) && !strchr(lineBuffer, '/'))
542 styler.ColourTo(endLine, SCE_DIFF_POSITION);
543 else if (lineBuffer[3] == '*')
544 styler.ColourTo(endLine, SCE_DIFF_POSITION);
545 else
546 styler.ColourTo(endLine, SCE_DIFF_HEADER);
547 } else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib
548 styler.ColourTo(endLine, SCE_DIFF_HEADER);
549 } else if (lineBuffer[0] == '@') {
550 styler.ColourTo(endLine, SCE_DIFF_POSITION);
551 } else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') {
552 styler.ColourTo(endLine, SCE_DIFF_POSITION);
553 } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
554 styler.ColourTo(endLine, SCE_DIFF_DELETED);
555 } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
556 styler.ColourTo(endLine, SCE_DIFF_ADDED);
557 } else if (lineBuffer[0] == '!') {
558 styler.ColourTo(endLine, SCE_DIFF_CHANGED);
559 } else if (lineBuffer[0] != ' ') {
560 styler.ColourTo(endLine, SCE_DIFF_COMMENT);
561 } else {
562 styler.ColourTo(endLine, SCE_DIFF_DEFAULT);
563 }
564}
565
566static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
567 char lineBuffer[DIFF_BUFFER_START_SIZE];
568 styler.StartAt(startPos);
569 styler.StartSegment(startPos);
570 unsigned int linePos = 0;
571 for (unsigned int i = startPos; i < startPos + length; i++) {
572 if (AtEOL(styler, i)) {
573 if (linePos < DIFF_BUFFER_START_SIZE) {
574 lineBuffer[linePos] = 0;
575 }
576 ColouriseDiffLine(lineBuffer, i, styler);
577 linePos = 0;
578 } else if (linePos < DIFF_BUFFER_START_SIZE - 1) {
579 lineBuffer[linePos++] = styler[i];
580 } else if (linePos == DIFF_BUFFER_START_SIZE - 1) {
581 lineBuffer[linePos++] = 0;
582 }
583 }
584 if (linePos > 0) { // Last line does not have ending characters
585 if (linePos < DIFF_BUFFER_START_SIZE) {
586 lineBuffer[linePos] = 0;
587 }
588 ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
589 }
590}
591
592static void FoldDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
593 int curLine = styler.GetLine(startPos);
594 int curLineStart = styler.LineStart(curLine);
595 int prevLevel = curLine > 0 ? styler.LevelAt(curLine - 1) : SC_FOLDLEVELBASE;
596 int nextLevel;
597
598 do {
599 int lineType = styler.StyleAt(curLineStart);
600 if (lineType == SCE_DIFF_COMMAND)
601 nextLevel = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
602 else if (lineType == SCE_DIFF_HEADER)
603 nextLevel = (SC_FOLDLEVELBASE + 1) | SC_FOLDLEVELHEADERFLAG;
604 else if (lineType == SCE_DIFF_POSITION && styler[curLineStart] != '-')
605 nextLevel = (SC_FOLDLEVELBASE + 2) | SC_FOLDLEVELHEADERFLAG;
606 else if (prevLevel & SC_FOLDLEVELHEADERFLAG)
607 nextLevel = (prevLevel & SC_FOLDLEVELNUMBERMASK) + 1;
608 else
609 nextLevel = prevLevel;
610
611 if ((nextLevel & SC_FOLDLEVELHEADERFLAG) && (nextLevel == prevLevel))
612 styler.SetLevel(curLine-1, prevLevel & ~SC_FOLDLEVELHEADERFLAG);
613
614 styler.SetLevel(curLine, nextLevel);
615 prevLevel = nextLevel;
616
617 curLineStart = styler.LineStart(++curLine);
618 } while (static_cast<int>(startPos) + length > curLineStart);
619}
620
621static void ColourisePoLine(
622 char *lineBuffer,
623 unsigned int lengthLine,
624 unsigned int startLine,
625 unsigned int endPos,
626 Accessor &styler) {
627
628 unsigned int i = 0;
629 static unsigned int state = SCE_PO_DEFAULT;
630 unsigned int state_start = SCE_PO_DEFAULT;
631
632 while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
633 i++;
634 if (i < lengthLine) {
635 if (lineBuffer[i] == '#') {
636 // check if the comment contains any flags ("#, ") and
637 // then whether the flags contain "fuzzy"
638 if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy"))
639 styler.ColourTo(endPos, SCE_PO_FUZZY);
640 else
641 styler.ColourTo(endPos, SCE_PO_COMMENT);
642 } else {
643 if (lineBuffer[0] == '"') {
644 // line continuation, use previous style
645 styler.ColourTo(endPos, state);
646 return;
647 // this implicitly also matches "msgid_plural"
648 } else if (strstart(lineBuffer, "msgid")) {
649 state_start = SCE_PO_MSGID;
650 state = SCE_PO_MSGID_TEXT;
651 } else if (strstart(lineBuffer, "msgstr")) {
652 state_start = SCE_PO_MSGSTR;
653 state = SCE_PO_MSGSTR_TEXT;
654 } else if (strstart(lineBuffer, "msgctxt")) {
655 state_start = SCE_PO_MSGCTXT;
656 state = SCE_PO_MSGCTXT_TEXT;
657 }
658 if (state_start != SCE_PO_DEFAULT) {
659 // find the next space
660 while ((i < lengthLine) && ! isspacechar(lineBuffer[i]))
661 i++;
662 styler.ColourTo(startLine + i - 1, state_start);
663 styler.ColourTo(startLine + i, SCE_PO_DEFAULT);
664 styler.ColourTo(endPos, state);
665 }
666 }
667 } else {
668 styler.ColourTo(endPos, SCE_PO_DEFAULT);
669 }
670}
671
672static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
673 char lineBuffer[1024];
674 styler.StartAt(startPos);
675 styler.StartSegment(startPos);
676 unsigned int linePos = 0;
677 unsigned int startLine = startPos;
678 for (unsigned int i = startPos; i < startPos + length; i++) {
679 lineBuffer[linePos++] = styler[i];
680 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
681 // End of line (or of line buffer) met, colourise it
682 lineBuffer[linePos] = '\0';
683 ColourisePoLine(lineBuffer, linePos, startLine, i, styler);
684 linePos = 0;
685 startLine = i + 1;
686 }
687 }
688 if (linePos > 0) { // Last line does not have ending characters
689 ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
690 }
691}
692
693static inline bool isassignchar(unsigned char ch) {
694 return (ch == '=') || (ch == ':');
695}
696
698 char *lineBuffer,
699 unsigned int lengthLine,
700 unsigned int startLine,
701 unsigned int endPos,
702 Accessor &styler,
703 bool allowInitialSpaces) {
704
705 unsigned int i = 0;
706 if (allowInitialSpaces) {
707 while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
708 i++;
709 } else {
710 if (isspacechar(lineBuffer[i])) // don't allow initial spaces
711 i = lengthLine;
712 }
713
714 if (i < lengthLine) {
715 if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
716 styler.ColourTo(endPos, SCE_PROPS_COMMENT);
717 } else if (lineBuffer[i] == '[') {
718 styler.ColourTo(endPos, SCE_PROPS_SECTION);
719 } else if (lineBuffer[i] == '@') {
720 styler.ColourTo(startLine + i, SCE_PROPS_DEFVAL);
721 if (isassignchar(lineBuffer[i++]))
722 styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
723 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
724 } else {
725 // Search for the '=' character
726 while ((i < lengthLine) && !isassignchar(lineBuffer[i]))
727 i++;
728 if ((i < lengthLine) && isassignchar(lineBuffer[i])) {
729 styler.ColourTo(startLine + i - 1, SCE_PROPS_KEY);
730 styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
731 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
732 } else {
733 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
734 }
735 }
736 } else {
737 styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
738 }
739}
740
741static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
742 char lineBuffer[1024];
743 styler.StartAt(startPos);
744 styler.StartSegment(startPos);
745 unsigned int linePos = 0;
746 unsigned int startLine = startPos;
747
748 // property lexer.props.allow.initial.spaces
749 // For properties files, set to 0 to style all lines that start with whitespace in the default style.
750 // This is not suitable for SciTE .properties files which use indentation for flow control but
751 // can be used for RFC2822 text where indentation is used for continuation lines.
752 bool allowInitialSpaces = styler.GetPropertyInt("lexer.props.allow.initial.spaces", 1) != 0;
753
754 for (unsigned int i = startPos; i < startPos + length; i++) {
755 lineBuffer[linePos++] = styler[i];
756 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
757 // End of line (or of line buffer) met, colourise it
758 lineBuffer[linePos] = '\0';
759 ColourisePropsLine(lineBuffer, linePos, startLine, i, styler, allowInitialSpaces);
760 linePos = 0;
761 startLine = i + 1;
762 }
763 }
764 if (linePos > 0) { // Last line does not have ending characters
765 ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler, allowInitialSpaces);
766 }
767}
768
769// adaption by ksc, using the "} else {" trick of 1.53
770// 030721
771static void FoldPropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
772 bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
773
774 unsigned int endPos = startPos + length;
775 int visibleChars = 0;
776 int lineCurrent = styler.GetLine(startPos);
777
778 char chNext = styler[startPos];
779 int styleNext = styler.StyleAt(startPos);
780 bool headerPoint = false;
781 int lev;
782
783 for (unsigned int i = startPos; i < endPos; i++) {
784 char ch = chNext;
785 chNext = styler[i+1];
786
787 int style = styleNext;
788 styleNext = styler.StyleAt(i + 1);
789 bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
790
791 if (style == SCE_PROPS_SECTION) {
792 headerPoint = true;
793 }
794
795 if (atEOL) {
796 lev = SC_FOLDLEVELBASE;
797
798 if (lineCurrent > 0) {
799 int levelPrevious = styler.LevelAt(lineCurrent - 1);
800
801 if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
802 lev = SC_FOLDLEVELBASE + 1;
803 } else {
804 lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
805 }
806 }
807
808 if (headerPoint) {
809 lev = SC_FOLDLEVELBASE;
810 }
811 if (visibleChars == 0 && foldCompact)
812 lev |= SC_FOLDLEVELWHITEFLAG;
813
814 if (headerPoint) {
815 lev |= SC_FOLDLEVELHEADERFLAG;
816 }
817 if (lev != styler.LevelAt(lineCurrent)) {
818 styler.SetLevel(lineCurrent, lev);
819 }
820
821 lineCurrent++;
822 visibleChars = 0;
823 headerPoint = false;
824 }
825 if (!isspacechar(ch))
826 visibleChars++;
827 }
828
829 if (lineCurrent > 0) {
830 int levelPrevious = styler.LevelAt(lineCurrent - 1);
831 if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
832 lev = SC_FOLDLEVELBASE + 1;
833 } else {
834 lev = levelPrevious & SC_FOLDLEVELNUMBERMASK;
835 }
836 } else {
837 lev = SC_FOLDLEVELBASE;
838 }
839 int flagsNext = styler.LevelAt(lineCurrent);
840 styler.SetLevel(lineCurrent, lev | (flagsNext & ~SC_FOLDLEVELNUMBERMASK));
841}
842
844 char *lineBuffer,
845 unsigned int lengthLine,
846 unsigned int startLine,
847 unsigned int endPos,
848 Accessor &styler) {
849
850 unsigned int i = 0;
851 int lastNonSpace = -1;
852 unsigned int state = SCE_MAKE_DEFAULT;
853 bool bSpecial = false;
854
855 // check for a tab character in column 0 indicating a command
856 bool bCommand = false;
857 if ((lengthLine > 0) && (lineBuffer[0] == '\t'))
858 bCommand = true;
859
860 // Skip initial spaces
861 while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
862 i++;
863 }
864 if (lineBuffer[i] == '#') { // Comment
865 styler.ColourTo(endPos, SCE_MAKE_COMMENT);
866 return;
867 }
868 if (lineBuffer[i] == '!') { // Special directive
869 styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
870 return;
871 }
872 int varCount = 0;
873 while (i < lengthLine) {
874 if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
875 styler.ColourTo(startLine + i - 1, state);
876 state = SCE_MAKE_IDENTIFIER;
877 varCount++;
878 } else if (state == SCE_MAKE_IDENTIFIER && lineBuffer[i] == ')') {
879 if (--varCount == 0) {
880 styler.ColourTo(startLine + i, state);
881 state = SCE_MAKE_DEFAULT;
882 }
883 }
884
885 // skip identifier and target styling if this is a command line
886 if (!bSpecial && !bCommand) {
887 if (lineBuffer[i] == ':') {
888 if (((i + 1) < lengthLine) && (lineBuffer[i + 1] == '=')) {
889 // it's a ':=', so style as an identifier
890 if (lastNonSpace >= 0)
891 styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
892 styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
893 styler.ColourTo(startLine + i + 1, SCE_MAKE_OPERATOR);
894 } else {
895 // We should check that no colouring was made since the beginning of the line,
896 // to avoid colouring stuff like /OUT:file
897 if (lastNonSpace >= 0)
898 styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
899 styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
900 styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
901 }
902 bSpecial = true; // Only react to the first ':' of the line
903 state = SCE_MAKE_DEFAULT;
904 } else if (lineBuffer[i] == '=') {
905 if (lastNonSpace >= 0)
906 styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
907 styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
908 styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
909 bSpecial = true; // Only react to the first '=' of the line
910 state = SCE_MAKE_DEFAULT;
911 }
912 }
913 if (!isspacechar(lineBuffer[i])) {
914 lastNonSpace = i;
915 }
916 i++;
917 }
918 if (state == SCE_MAKE_IDENTIFIER) {
919 styler.ColourTo(endPos, SCE_MAKE_IDEOL); // Error, variable reference not ended
920 } else {
921 styler.ColourTo(endPos, SCE_MAKE_DEFAULT);
922 }
923}
924
925static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
926 char lineBuffer[1024];
927 styler.StartAt(startPos);
928 styler.StartSegment(startPos);
929 unsigned int linePos = 0;
930 unsigned int startLine = startPos;
931 for (unsigned int i = startPos; i < startPos + length; i++) {
932 lineBuffer[linePos++] = styler[i];
933 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
934 // End of line (or of line buffer) met, colourise it
935 lineBuffer[linePos] = '\0';
936 ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
937 linePos = 0;
938 startLine = i + 1;
939 }
940 }
941 if (linePos > 0) { // Last line does not have ending characters
942 ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
943 }
944}
945
946static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine, int &startValue) {
947 if (lineBuffer[0] == '>') {
948 // Command or return status
949 return SCE_ERR_CMD;
950 } else if (lineBuffer[0] == '<') {
951 // Diff removal.
953 } else if (lineBuffer[0] == '!') {
955 } else if (lineBuffer[0] == '+') {
956 if (strstart(lineBuffer, "+++ ")) {
958 } else {
960 }
961 } else if (lineBuffer[0] == '-') {
962 if (strstart(lineBuffer, "--- ")) {
964 } else {
966 }
967 } else if (strstart(lineBuffer, "cf90-")) {
968 // Absoft Pro Fortran 90/95 v8.2 error and/or warning message
969 return SCE_ERR_ABSF;
970 } else if (strstart(lineBuffer, "fortcom:")) {
971 // Intel Fortran Compiler v8.0 error/warning message
972 return SCE_ERR_IFORT;
973 } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
974 return SCE_ERR_PYTHON;
975 } else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) {
976 return SCE_ERR_PHP;
977 } else if ((strstart(lineBuffer, "Error ") ||
978 strstart(lineBuffer, "Warning ")) &&
979 strstr(lineBuffer, " at (") &&
980 strstr(lineBuffer, ") : ") &&
981 (strstr(lineBuffer, " at (") < strstr(lineBuffer, ") : "))) {
982 // Intel Fortran Compiler error/warning message
983 return SCE_ERR_IFC;
984 } else if (strstart(lineBuffer, "Error ")) {
985 // Borland error message
986 return SCE_ERR_BORLAND;
987 } else if (strstart(lineBuffer, "Warning ")) {
988 // Borland warning message
989 return SCE_ERR_BORLAND;
990 } else if (strstr(lineBuffer, "at line ") &&
991 (strstr(lineBuffer, "at line ") < (lineBuffer + lengthLine)) &&
992 strstr(lineBuffer, "file ") &&
993 (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
994 // Lua 4 error message
995 return SCE_ERR_LUA;
996 } else if (strstr(lineBuffer, " at ") &&
997 (strstr(lineBuffer, " at ") < (lineBuffer + lengthLine)) &&
998 strstr(lineBuffer, " line ") &&
999 (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) &&
1000 (strstr(lineBuffer, " at ") < (strstr(lineBuffer, " line ")))) {
1001 // perl error message
1002 return SCE_ERR_PERL;
1003 } else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
1004 strstr(lineBuffer, ":line ")) {
1005 // A .NET traceback
1006 return SCE_ERR_NET;
1007 } else if (strstart(lineBuffer, "Line ") &&
1008 strstr(lineBuffer, ", file ")) {
1009 // Essential Lahey Fortran error message
1010 return SCE_ERR_ELF;
1011 } else if (strstart(lineBuffer, "line ") &&
1012 strstr(lineBuffer, " column ")) {
1013 // HTML tidy style: line 42 column 1
1014 return SCE_ERR_TIDY;
1015 } else if (strstart(lineBuffer, "\tat ") &&
1016 strstr(lineBuffer, "(") &&
1017 strstr(lineBuffer, ".java:")) {
1018 // Java stack back trace
1019 return SCE_ERR_JAVA_STACK;
1020 } else {
1021 // Look for one of the following formats:
1022 // GCC: <filename>:<line>:<message>
1023 // Microsoft: <filename>(<line>) :<message>
1024 // Common: <filename>(<line>): warning|error|note|remark|catastrophic|fatal
1025 // Common: <filename>(<line>) warning|error|note|remark|catastrophic|fatal
1026 // Microsoft: <filename>(<line>,<column>)<message>
1027 // CTags: \t<message>
1028 // Lua 5 traceback: \t<filename>:<line>:<message>
1029 // Lua 5.1: <exe>: <filename>:<line>:<message>
1030 bool initialTab = (lineBuffer[0] == '\t');
1031 bool initialColonPart = false;
1032 enum { stInitial,
1033 stGccStart, stGccDigit, stGccColumn, stGcc,
1034 stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
1035 stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
1036 stUnrecognized
1037 } state = stInitial;
1038 for (unsigned int i = 0; i < lengthLine; i++) {
1039 char ch = lineBuffer[i];
1040 char chNext = ' ';
1041 if ((i + 1) < lengthLine)
1042 chNext = lineBuffer[i + 1];
1043 if (state == stInitial) {
1044 if (ch == ':') {
1045 // May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix)
1046 if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) {
1047 // This check is not completely accurate as may be on
1048 // GTK+ with a file name that includes ':'.
1049 state = stGccStart;
1050 } else if (chNext == ' ') { // indicates a Lua 5.1 error message
1051 initialColonPart = true;
1052 }
1053 } else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) {
1054 // May be Microsoft
1055 // Check against '0' often removes phone numbers
1056 state = stMsStart;
1057 } else if ((ch == '\t') && (!initialTab)) {
1058 // May be CTags
1059 state = stCtagsStart;
1060 }
1061 } else if (state == stGccStart) { // <filename>:
1062 state = Is1To9(ch) ? stGccDigit : stUnrecognized;
1063 } else if (state == stGccDigit) { // <filename>:<line>
1064 if (ch == ':') {
1065 state = stGccColumn; // :9.*: is GCC
1066 startValue = i + 1;
1067 } else if (!Is0To9(ch)) {
1068 state = stUnrecognized;
1069 }
1070 } else if (state == stGccColumn) { // <filename>:<line>:<column>
1071 if (!Is0To9(ch)) {
1072 state = stGcc;
1073 if (ch == ':')
1074 startValue = i + 1;
1075 break;
1076 }
1077 } else if (state == stMsStart) { // <filename>(
1078 state = Is0To9(ch) ? stMsDigit : stUnrecognized;
1079 } else if (state == stMsDigit) { // <filename>(<line>
1080 if (ch == ',') {
1081 state = stMsDigitComma;
1082 } else if (ch == ')') {
1083 state = stMsBracket;
1084 } else if ((ch != ' ') && !Is0To9(ch)) {
1085 state = stUnrecognized;
1086 }
1087 } else if (state == stMsBracket) { // <filename>(<line>)
1088 if ((ch == ' ') && (chNext == ':')) {
1089 state = stMsVc;
1090 } else if ((ch == ':' && chNext == ' ') || (ch == ' ')) {
1091 // Possibly Delphi.. don't test against chNext as it's one of the strings below.
1092 char word[512];
1093 unsigned int j, chPos;
1094 unsigned numstep;
1095 chPos = 0;
1096 if (ch == ' ')
1097 numstep = 1; // ch was ' ', handle as if it's a delphi errorline, only add 1 to i.
1098 else
1099 numstep = 2; // otherwise add 2.
1100 for (j = i + numstep; j < lengthLine && IsAlphabetic(lineBuffer[j]) && chPos < sizeof(word) - 1; j++)
1101 word[chPos++] = lineBuffer[j];
1102 word[chPos] = 0;
1103 if (!CompareCaseInsensitive(word, "error") || !CompareCaseInsensitive(word, "warning") ||
1104 !CompareCaseInsensitive(word, "fatal") || !CompareCaseInsensitive(word, "catastrophic") ||
1105 !CompareCaseInsensitive(word, "note") || !CompareCaseInsensitive(word, "remark")) {
1106 state = stMsVc;
1107 } else
1108 state = stUnrecognized;
1109 } else {
1110 state = stUnrecognized;
1111 }
1112 } else if (state == stMsDigitComma) { // <filename>(<line>,
1113 if (ch == ')') {
1114 state = stMsDotNet;
1115 break;
1116 } else if ((ch != ' ') && !Is0To9(ch)) {
1117 state = stUnrecognized;
1118 }
1119 } else if (state == stCtagsStart) {
1120 if ((lineBuffer[i - 1] == '\t') &&
1121 ((ch == '/' && lineBuffer[i + 1] == '^') || Is0To9(ch))) {
1122 state = stCtags;
1123 break;
1124 } else if ((ch == '/') && (lineBuffer[i + 1] == '^')) {
1125 state = stCtagsStartString;
1126 }
1127 } else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) {
1128 state = stCtagsStringDollar;
1129 break;
1130 }
1131 }
1132 if (state == stGcc) {
1133 return initialColonPart ? SCE_ERR_LUA : SCE_ERR_GCC;
1134 } else if ((state == stMsVc) || (state == stMsDotNet)) {
1135 return SCE_ERR_MS;
1136 } else if ((state == stCtagsStringDollar) || (state == stCtags)) {
1137 return SCE_ERR_CTAG;
1138 } else {
1139 return SCE_ERR_DEFAULT;
1140 }
1141 }
1142}
1143
1145 char *lineBuffer,
1146 unsigned int lengthLine,
1147 unsigned int endPos,
1148 Accessor &styler,
1149 bool valueSeparate) {
1150 int startValue = -1;
1151 int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue);
1152 if (valueSeparate && (startValue >= 0)) {
1153 styler.ColourTo(endPos - (lengthLine - startValue), style);
1154 styler.ColourTo(endPos, SCE_ERR_VALUE);
1155 } else {
1156 styler.ColourTo(endPos, style);
1157 }
1158}
1159
1160static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
1161 char lineBuffer[10000];
1162 styler.StartAt(startPos);
1163 styler.StartSegment(startPos);
1164 unsigned int linePos = 0;
1165
1166 // property lexer.errorlist.value.separate
1167 // For lines in the output pane that are matches from Find in Files or GCC-style
1168 // diagnostics, style the path and line number separately from the rest of the
1169 // line with style 21 used for the rest of the line.
1170 // This allows matched text to be more easily distinguished from its location.
1171 bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0;
1172 for (unsigned int i = startPos; i < startPos + length; i++) {
1173 lineBuffer[linePos++] = styler[i];
1174 if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
1175 // End of line (or of line buffer) met, colourise it
1176 lineBuffer[linePos] = '\0';
1177 ColouriseErrorListLine(lineBuffer, linePos, i, styler, valueSeparate);
1178 linePos = 0;
1179 }
1180 }
1181 if (linePos > 0) { // Last line does not have ending characters
1182 ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler, valueSeparate);
1183 }
1184}
1185
1186static bool latexIsSpecial(int ch) {
1187 return (ch == '#') || (ch == '$') || (ch == '%') || (ch == '&') || (ch == '_') ||
1188 (ch == '{') || (ch == '}') || (ch == ' ');
1189}
1190
1191static bool latexIsBlank(int ch) {
1192 return (ch == ' ') || (ch == '\t');
1193}
1194
1195static bool latexIsBlankAndNL(int ch) {
1196 return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n');
1197}
1198
1199static bool latexIsLetter(int ch) {
1200 return isascii(ch) && isalpha(ch);
1201}
1202
1203static bool latexIsTagValid(int &i, int l, Accessor &styler) {
1204 while (i < l) {
1205 if (styler.SafeGetCharAt(i) == '{') {
1206 while (i < l) {
1207 i++;
1208 if (styler.SafeGetCharAt(i) == '}') {
1209 return true;
1210 } else if (!latexIsLetter(styler.SafeGetCharAt(i)) &&
1211 styler.SafeGetCharAt(i)!='*') {
1212 return false;
1213 }
1214 }
1215 } else if (!latexIsBlank(styler.SafeGetCharAt(i))) {
1216 return false;
1217 }
1218 i++;
1219 }
1220 return false;
1221}
1222
1223static bool latexNextNotBlankIs(int i, int l, Accessor &styler, char needle) {
1224 char ch;
1225 while (i < l) {
1226 ch = styler.SafeGetCharAt(i);
1227 if (!latexIsBlankAndNL(ch) && ch != '*') {
1228 if (ch == needle)
1229 return true;
1230 else
1231 return false;
1232 }
1233 i++;
1234 }
1235 return false;
1236}
1237
1238static bool latexLastWordIs(int start, Accessor &styler, const char *needle) {
1239 unsigned int i = 0;
1240 unsigned int l = static_cast<unsigned int>(strlen(needle));
1241 int ini = start-l+1;
1242 char s[32];
1243
1244 while (i < l && i < 32) {
1245 s[i] = styler.SafeGetCharAt(ini + i);
1246 i++;
1247 }
1248 s[i] = '\0';
1249
1250 return (strcmp(s, needle) == 0);
1251}
1252
1253static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
1254 WordList *[], Accessor &styler) {
1255
1256 styler.StartAt(startPos);
1257
1258 int state = initStyle;
1259 char chNext = styler.SafeGetCharAt(startPos);
1260 styler.StartSegment(startPos);
1261 int lengthDoc = startPos + length;
1262 char chVerbatimDelim = '\0';
1263
1264 for (int i = startPos; i < lengthDoc; i++) {
1265 char ch = chNext;
1266 chNext = styler.SafeGetCharAt(i + 1);
1267
1268 if (styler.IsLeadByte(ch)) {
1269 i++;
1270 chNext = styler.SafeGetCharAt(i + 1);
1271 continue;
1272 }
1273
1274 switch (state) {
1275 case SCE_L_DEFAULT :
1276 switch (ch) {
1277 case '\\' :
1278 styler.ColourTo(i - 1, state);
1279 if (latexIsSpecial(chNext)) {
1280 state = SCE_L_SPECIAL;
1281 } else {
1282 if (latexIsLetter(chNext)) {
1283 state = SCE_L_COMMAND;
1284 } else {
1285 if (chNext == '(' || chNext == '[') {
1286 styler.ColourTo(i-1, state);
1287 styler.ColourTo(i+1, SCE_L_SHORTCMD);
1288 state = SCE_L_MATH;
1289 if (chNext == '[')
1290 state = SCE_L_MATH2;
1291 i++;
1292 chNext = styler.SafeGetCharAt(i+1);
1293 } else {
1294 state = SCE_L_SHORTCMD;
1295 }
1296 }
1297 }
1298 break;
1299 case '$' :
1300 styler.ColourTo(i - 1, state);
1301 state = SCE_L_MATH;
1302 if (chNext == '$') {
1303 state = SCE_L_MATH2;
1304 i++;
1305 chNext = styler.SafeGetCharAt(i + 1);
1306 }
1307 break;
1308 case '%' :
1309 styler.ColourTo(i - 1, state);
1310 state = SCE_L_COMMENT;
1311 break;
1312 }
1313 break;
1314 case SCE_L_ERROR:
1315 styler.ColourTo(i-1, state);
1316 state = SCE_L_DEFAULT;
1317 break;
1318 case SCE_L_SPECIAL:
1319 case SCE_L_SHORTCMD:
1320 styler.ColourTo(i, state);
1321 state = SCE_L_DEFAULT;
1322 break;
1323 case SCE_L_COMMAND :
1324 if (!latexIsLetter(chNext)) {
1325 styler.ColourTo(i, state);
1326 state = SCE_L_DEFAULT;
1327 if (latexNextNotBlankIs(i+1, lengthDoc, styler, '[' )) {
1328 state = SCE_L_CMDOPT;
1329 } else if (latexLastWordIs(i, styler, "\\begin")) {
1330 state = SCE_L_TAG;
1331 } else if (latexLastWordIs(i, styler, "\\end")) {
1332 state = SCE_L_TAG2;
1333 } else if (latexLastWordIs(i, styler, "\\verb") &&
1334 chNext != '*' && chNext != ' ') {
1335 chVerbatimDelim = chNext;
1336 state = SCE_L_VERBATIM;
1337 }
1338 }
1339 break;
1340 case SCE_L_CMDOPT :
1341 if (ch == ']') {
1342 styler.ColourTo(i, state);
1343 state = SCE_L_DEFAULT;
1344 }
1345 break;
1346 case SCE_L_TAG :
1347 if (latexIsTagValid(i, lengthDoc, styler)) {
1348 styler.ColourTo(i, state);
1349 state = SCE_L_DEFAULT;
1350 if (latexLastWordIs(i, styler, "{verbatim}")) {
1351 state = SCE_L_VERBATIM;
1352 } else if (latexLastWordIs(i, styler, "{comment}")) {
1353 state = SCE_L_COMMENT2;
1354 } else if (latexLastWordIs(i, styler, "{math}")) {
1355 state = SCE_L_MATH;
1356 } else if (latexLastWordIs(i, styler, "{displaymath}")) {
1357 state = SCE_L_MATH2;
1358 } else if (latexLastWordIs(i, styler, "{equation}")) {
1359 state = SCE_L_MATH2;
1360 }
1361 } else {
1362 state = SCE_L_ERROR;
1363 styler.ColourTo(i, state);
1364 state = SCE_L_DEFAULT;
1365 }
1366 chNext = styler.SafeGetCharAt(i+1);
1367 break;
1368 case SCE_L_TAG2 :
1369 if (latexIsTagValid(i, lengthDoc, styler)) {
1370 styler.ColourTo(i, state);
1371 state = SCE_L_DEFAULT;
1372 } else {
1373 state = SCE_L_ERROR;
1374 }
1375 chNext = styler.SafeGetCharAt(i+1);
1376 break;
1377 case SCE_L_MATH :
1378 if (ch == '$') {
1379 styler.ColourTo(i, state);
1380 state = SCE_L_DEFAULT;
1381 } else if (ch == '\\' && chNext == ')') {
1382 styler.ColourTo(i-1, state);
1383 styler.ColourTo(i+1, SCE_L_SHORTCMD);
1384 i++;
1385 chNext = styler.SafeGetCharAt(i+1);
1386 state = SCE_L_DEFAULT;
1387 } else if (ch == '\\') {
1388 int match = i + 3;
1389 if (latexLastWordIs(match, styler, "\\end")) {
1390 match++;
1391 if (latexIsTagValid(match, lengthDoc, styler)) {
1392 if (latexLastWordIs(match, styler, "{math}")) {
1393 styler.ColourTo(i-1, state);
1394 state = SCE_L_COMMAND;
1395 }
1396 }
1397 }
1398 }
1399
1400 break;
1401 case SCE_L_MATH2 :
1402 if (ch == '$') {
1403 if (chNext == '$') {
1404 i++;
1405 chNext = styler.SafeGetCharAt(i + 1);
1406 styler.ColourTo(i, state);
1407 state = SCE_L_DEFAULT;
1408 } else {
1409 styler.ColourTo(i, SCE_L_ERROR);
1410 state = SCE_L_DEFAULT;
1411 }
1412 } else if (ch == '\\' && chNext == ']') {
1413 styler.ColourTo(i-1, state);
1414 styler.ColourTo(i+1, SCE_L_SHORTCMD);
1415 i++;
1416 chNext = styler.SafeGetCharAt(i+1);
1417 state = SCE_L_DEFAULT;
1418 } else if (ch == '\\') {
1419 int match = i + 3;
1420 if (latexLastWordIs(match, styler, "\\end")) {
1421 match++;
1422 if (latexIsTagValid(match, lengthDoc, styler)) {
1423 if (latexLastWordIs(match, styler, "{displaymath}")) {
1424 styler.ColourTo(i-1, state);
1425 state = SCE_L_COMMAND;
1426 } else if (latexLastWordIs(match, styler, "{equation}")) {
1427 styler.ColourTo(i-1, state);
1428 state = SCE_L_COMMAND;
1429 }
1430 }
1431 }
1432 }
1433 break;
1434 case SCE_L_COMMENT :
1435 if (ch == '\r' || ch == '\n') {
1436 styler.ColourTo(i - 1, state);
1437 state = SCE_L_DEFAULT;
1438 }
1439 break;
1440 case SCE_L_COMMENT2 :
1441 if (ch == '\\') {
1442 int match = i + 3;
1443 if (latexLastWordIs(match, styler, "\\end")) {
1444 match++;
1445 if (latexIsTagValid(match, lengthDoc, styler)) {
1446 if (latexLastWordIs(match, styler, "{comment}")) {
1447 styler.ColourTo(i-1, state);
1448 state = SCE_L_COMMAND;
1449 }
1450 }
1451 }
1452 }
1453 break;
1454 case SCE_L_VERBATIM :
1455 if (ch == '\\') {
1456 int match = i + 3;
1457 if (latexLastWordIs(match, styler, "\\end")) {
1458 match++;
1459 if (latexIsTagValid(match, lengthDoc, styler)) {
1460 if (latexLastWordIs(match, styler, "{verbatim}")) {
1461 styler.ColourTo(i-1, state);
1462 state = SCE_L_COMMAND;
1463 }
1464 }
1465 }
1466 } else if (chNext == chVerbatimDelim) {
1467 styler.ColourTo(i+1, state);
1468 state = SCE_L_DEFAULT;
1469 chVerbatimDelim = '\0';
1470 } else if (chVerbatimDelim != '\0' && (ch == '\n' || ch == '\r')) {
1471 styler.ColourTo(i, SCE_L_ERROR);
1472 state = SCE_L_DEFAULT;
1473 chVerbatimDelim = '\0';
1474 }
1475 break;
1476 }
1477 }
1478 styler.ColourTo(lengthDoc-1, state);
1479}
1480
1481static const char *const batchWordListDesc[] = {
1482 "Internal Commands",
1483 "External Commands",
1484 0
1485};
1486
1487static const char *const emptyWordListDesc[] = {
1488 0
1489};
1490
1491static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
1492 Accessor &styler) {
1493 // Null language means all style bytes are 0 so just mark the end - no need to fill in.
1494 if (length > 0) {
1495 styler.StartAt(startPos + length - 1);
1496 styler.StartSegment(startPos + length - 1);
1497 styler.ColourTo(startPos + length - 1, 0);
1498 }
1499}
1500
1501/*
1502#define SCE_NSCR_DEFAULT 0
1503#define SCE_NSCR_IDENTIFIER 1
1504#define SCE_NSCR_COMMENT_LINE 2
1505#define SCE_NSCR_COMMENT_BLOCK 3
1506#define SCE_NSCR_COMMAND 4
1507#define SCE_NSCR_OPTION 5
1508#define SCE_NSCR_FUNCTION 6
1509#define SCE_NSCR_METHOD 7
1510#define SCE_NSCR_CONSTANTS 8
1511#define SCE_NSCR_PREDEFS 9
1512#define SCE_NSCR_STRING 10
1513#define SCE_NSCR_STRING_PARSER 11
1514#define SCE_NSCR_DEFAULT_VARS 12
1515#define SCE_NSCR_OPERATORS 13
1516#define SCE_NSCR_OPERATOR_KEYWORDS 14
1517#define SCE_NSCR_PROCEDURES 15
1518#define SCE_NSCR_INCLUDES 16
1519#define SCE_NSCR_NUMBERS 17
1520#define SCE_NSCR_CUSTOM_FUNCTION 18
1521#define SCE_NSCR_CLUSTER 19
1522#define SCE_NSCR_DOCCOMMENT_LINE 20
1523#define SCE_NSCR_DOCCOMMENT_BLOCK 21
1524#define SCE_NSCR_DOCKEYWORD 22
1525#define SCE_NSCR_INSTALL 23
1526#define SCE_NSCR_PROCEDURE_COMMANDS 24
1527
1528#define SCE_NPRC_DEFAULT SCE_NSCR_DEFAULT
1529#define SCE_NPRC_IDENTIFIER SCE_NSCR_IDENTIFIER
1530#define SCE_NPRC_COMMENT_LINE SCE_NSCR_COMMENT_LINE
1531#define SCE_NPRC_COMMENT_BLOCK SCE_NSCR_COMMENT_BLOCK
1532#define SCE_NPRC_COMMAND SCE_NSCR_COMMAND
1533#define SCE_NPRC_OPTION SCE_NSCR_OPTION
1534#define SCE_NPRC_FUNCTION SCE_NSCR_FUNCTION
1535#define SCE_NPRC_METHOD SCE_NSCR_METHOD
1536#define SCE_NPRC_CONSTANTS SCE_NSCR_CONSTANTS
1537#define SCE_NPRC_PREDEFS SCE_NSCR_PREDEFS
1538#define SCE_NPRC_STRING SCE_NSCR_STRING
1539#define SCE_NPRC_STRING_PARSER SCE_NSCR_STRING_PARSER
1540#define SCE_NPRC_DEFAULT_VARS SCE_NSCR_DEFAULT_VARS
1541#define SCE_NPRC_OPERATORS SCE_NSCR_OPERATORS
1542#define SCE_NPRC_OPERATOR_KEYWORDS SCE_NSCR_OPERATOR_KEYWORDS
1543#define SCE_NPRC_PROCEDURES SCE_NSCR_PROCEDURES
1544#define SCE_NPRC_INCLUDES SCE_NSCR_INCLUDES
1545#define SCE_NPRC_NUMBERS SCE_NSCR_NUMBERS
1546#define SCE_NPRC_CUSTOM_FUNCTION SCE_NSCR_CUSTOM_FUNCTION
1547#define SCE_NPRC_CLUSTER SCE_NSCR_CLUSTER
1548#define SCE_NPRC_DOCCOMMENT_LINE SCE_NSCR_DOCCOMMENT_LINE
1549#define SCE_NPRC_DOCCOMMENT_BLOCK SCE_NSCR_DOCCOMMENT_BLOCK
1550#define SCE_NPRC_DOCKEYWORD SCE_NSCR_DOCKEYWORD
1551#define SCE_NPRC_FLAGS 23
1552
1553
1554#define SCE_TXTADV_DEFAULT 0
1555#define SCE_TXTADV_MODIFIER 1
1556#define SCE_TXTADV_ITALIC 2
1557#define SCE_TXTADV_BOLD 3
1558#define SCE_TXTADV_BOLD_ITALIC 4
1559#define SCE_TXTADV_UNDERLINE 5
1560#define SCE_TXTADV_STRIKETHROUGH 6
1561#define SCE_TXTADV_URL 7
1562#define SCE_TXTADV_HEAD 8
1563#define SCE_TXTADV_BIGHEAD 9
1564
1565
1566*/
1567
1568/* Nested comments require keeping the value of the nesting level for every
1569 position in the document. But since scintilla always styles line by line,
1570 we only need to store one value per line. The non-negative number indicates
1571 nesting level at the end of the line.
1572*/
1573
1574// Underscore, letter, digit and universal alphas from C99 Appendix D.
1575
1576static bool IsWordStart(int ch) {
1577 return (isascii(ch) && (isalpha(ch) || ch == '_' || ch == '\'')) || !isascii(ch);
1578}
1579
1580static bool IsWord(int ch) {
1581 return (isascii(ch) && (isalnum(ch) || ch == '_')) || !isascii(ch);
1582}
1583
1584static bool IsOperator(int ch)
1585{
1586 if (IsAlphaNumeric(ch))
1587 return false;
1588 if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
1589 ch == '^' || ch == ')' || ch == '(' || ch == '?' ||
1590 ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
1591 ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
1592 ch == '<' || ch == '>' || ch == ',' || ch == '!' ||
1593 ch == '&' || ch == '%' || ch == '\\')
1594 return true;
1595 return false;
1596}
1597/*
1598static bool IsDoxygen(int ch) {
1599 if (isascii(ch) && islower(ch))
1600 return true;
1601 if (ch == '$' || ch == '@' || ch == '\\' ||
1602 ch == '&' || ch == '#' || ch == '<' || ch == '>' ||
1603 ch == '{' || ch == '}' || ch == '[' || ch == ']')
1604 return true;
1605 return false;
1606}*/
1607
1608static bool IsStringSuffix(int ch) {
1609 return ch == 'c' || ch == 'w' || ch == 'd';
1610}
1611
1612static bool IsStreamCommentStyle(int style) {
1613 return style == SCE_D_COMMENT ||
1614 style == SCE_D_COMMENTDOC ||
1615 style == SCE_D_COMMENTDOCKEYWORD ||
1617}
1618
1619// An individual named option for use in an OptionSet
1620
1621// Options used for LexerNSCR
1623 bool fold;
1629 std::string foldExplicitEnd;
1634 fold = false;
1635 foldSyntaxBased = true;
1636 foldComment = false;
1637 foldCommentMultiline = true;
1638 foldCommentExplicit = true;
1639 foldExplicitStart = "";
1640 foldExplicitEnd = "";
1641 foldExplicitAnywhere = false;
1642 foldCompact = false;
1643 foldAtElse = true;
1644 }
1645};
1646
1647static const char * const NSCRWordLists[] = {
1648 "Commands",
1649 "Options",
1650 "Functions",
1651 "Methods",
1652 "Predefined variables",
1653 "Constants",
1654 "Special predefs",
1655 "Operator keywords",
1656 "Documentation keywords",
1657 "Procedure commands",
1658 0
1659 };
1660
1661struct OptionSetNSCR : public OptionSet<OptionsNSCR> {
1663 DefineProperty("fold", &OptionsNSCR::fold);
1664
1665 DefineProperty("fold.nscr.syntax.based", &OptionsNSCR::foldSyntaxBased,
1666 "Set this property to 0 to disable syntax based folding.");
1667
1668 DefineProperty("fold.comment", &OptionsNSCR::foldComment);
1669
1670 DefineProperty("fold.nscr.comment.multiline", &OptionsNSCR::foldCommentMultiline,
1671 "Set this property to 0 to disable folding multi-line comments when fold.comment=1.");
1672
1673 DefineProperty("fold.nscr.comment.explicit", &OptionsNSCR::foldCommentExplicit,
1674 "Set this property to 0 to disable folding explicit fold points when fold.comment=1.");
1675
1676 DefineProperty("fold.nscr.explicit.start", &OptionsNSCR::foldExplicitStart,
1677 "The string to use for explicit fold start points, replacing the standard //{.");
1678
1679 DefineProperty("fold.nscr.explicit.end", &OptionsNSCR::foldExplicitEnd,
1680 "The string to use for explicit fold end points, replacing the standard //}.");
1681
1682 DefineProperty("fold.nscr.explicit.anywhere", &OptionsNSCR::foldExplicitAnywhere,
1683 "Set this property to 1 to enable explicit fold points anywhere, not just in line comments.");
1684
1685 DefineProperty("fold.compact", &OptionsNSCR::foldCompact);
1686
1687 DefineProperty("fold.at.else", &OptionsNSCR::foldAtElse);
1688
1689 DefineWordListSets(NSCRWordLists);
1690 }
1691};
1692
1693class LexerNSCR : public ILexer {
1696 WordList optionWords;
1698 WordList methodWords;
1699 WordList defVarWords;
1701 WordList preDefWords;
1703 WordList docKeyWords;
1707
1708 /*
1709 "Commands",
1710 "Options",
1711 "Functions",
1712 "Predefined variables",
1713 "Constants",
1714 "Special predefs",
1715 "Operator keywords",
1716 0,
1717 */
1720public:
1721 LexerNSCR(bool caseSensitive_) :
1722 caseSensitive(caseSensitive_) {
1723 defVarWords.Set("x y z t");
1724 }
1725 virtual ~LexerNSCR() {
1726 }
1727 void SCI_METHOD Release() {
1728 delete this;
1729 }
1730 int SCI_METHOD Version() const {
1731 return lvOriginal;
1732 }
1733 const char * SCI_METHOD PropertyNames() {
1734 return osNSCR.PropertyNames();
1735 }
1736 int SCI_METHOD PropertyType(const char *name) {
1737 return osNSCR.PropertyType(name);
1738 }
1739 const char * SCI_METHOD DescribeProperty(const char *name) {
1740 return osNSCR.DescribeProperty(name);
1741 }
1742 int SCI_METHOD PropertySet(const char *key, const char *val);
1743 const char * SCI_METHOD DescribeWordListSets() {
1744 return osNSCR.DescribeWordListSets();
1745 }
1746 int SCI_METHOD WordListSet(int n, const char *wl);
1747 void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
1748 void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
1749
1750 void * SCI_METHOD PrivateCall(int, void *) {
1751 return 0;
1752 }
1753
1754 static ILexer *LexerFactoryNSCR() {
1755 return new LexerNSCR(true);
1756 }
1758 return new LexerNSCR(false);
1759 }
1760};
1761
1762int SCI_METHOD LexerNSCR::PropertySet(const char *key, const char *val) {
1763 if (osNSCR.PropertySet(&options, key, val)) {
1764 return 0;
1765 }
1766 return -1;
1767}
1768
1769int SCI_METHOD LexerNSCR::WordListSet(int n, const char *wl) {
1770 WordList *wordListN = 0;
1771 switch (n) {
1772 case 0:
1773 wordListN = &commandWords;
1774 break;
1775 case 1:
1776 wordListN = &optionWords;
1777 break;
1778 case 2:
1779 wordListN = &functionWords;
1780 break;
1781 case 3:
1782 wordListN = &methodWords;
1783 break;
1784 case 4:
1785 {
1786 std::string words = wl;
1787
1788 if (words.find(';') != std::string::npos)
1789 {
1790 blockStartWords.Set(words.substr(0, words.find(';')).c_str());
1791 blockEndWords.Set(words.substr(words.find(';')+1).c_str());
1792 }
1793
1794 }
1795 return 0;
1796 case 5:
1797 wordListN = &constantWords;
1798 break;
1799 case 6:
1800 wordListN = &preDefWords;
1801 break;
1802 case 7:
1803 wordListN = &operatorWords;
1804 break;
1805 case 8:
1806 wordListN = &docKeyWords;
1807 break;
1808 case 9:
1809 wordListN = &procedureCommandWords;
1810 break;
1811 }
1812 int firstModification = -1;
1813 if (wordListN) {
1814 WordList wlNew;
1815 wlNew.Set(wl);
1816 if (*wordListN != wlNew) {
1817 wordListN->Set(wl);
1818 firstModification = 0;
1819 }
1820 }
1821 return firstModification;
1822}
1823
1824void SCI_METHOD LexerNSCR::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
1825{
1826 LexAccessor styler(pAccess);
1827 int nInstallStart = -1;
1828
1829 if (startPos > 0 && (styler.StyleAt(startPos) == SCE_NSCR_INSTALL || styler.StyleAt(startPos-1) == SCE_NSCR_INSTALL || styler.StyleAt(startPos) == SCE_NSCR_PROCEDURE_COMMANDS || styler.StyleAt(startPos-1) == SCE_NSCR_PROCEDURE_COMMANDS))
1830 {
1831 startPos--;
1832 length++;
1833
1834 while (startPos > 0 && (styler.StyleAt(startPos) == SCE_NSCR_INSTALL || styler.StyleAt(startPos) == SCE_NSCR_PROCEDURE_COMMANDS))
1835 {
1836 startPos--;
1837 length++;
1838 }
1839
1840 while (startPos+length < styler.Length() && (styler.StyleAt(startPos+length) == SCE_NSCR_INSTALL || styler.StyleAt(startPos+length) == SCE_NSCR_PROCEDURE_COMMANDS))
1841 length++;
1842
1843 initStyle = styler.StyleAt(startPos);
1844
1845 //if (initStyle == SCE_NSCR_INSTALL)
1846 // initStyle = SCE_NSCR_DEFAULT;
1847 }
1848
1849 int styleBeforeDCKeyword = SCE_NSCR_DEFAULT;
1850
1851 StyleContext sc(startPos, length, initStyle, styler);
1852
1853 int curLine = styler.GetLine(startPos);
1854 int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
1855 bool numFloat = false; // Float literals have '+' and '-' signs
1856 bool numHex = false;
1857 bool possibleMethod = false;
1858
1859 for (; sc.More(); sc.Forward()) {
1860
1861 if (sc.atLineStart) {
1862 curLine = styler.GetLine(sc.currentPos);
1863 styler.SetLineState(curLine, curNcLevel);
1864 }
1865
1866 // Determine if the current state should terminate.
1867 switch (sc.state) {
1868 case SCE_NSCR_OPERATORS:
1869 sc.SetState(SCE_NSCR_DEFAULT);
1870 break;
1872 if (sc.ch == '>')
1873 {
1874 sc.ForwardSetState(SCE_NSCR_DEFAULT);
1875 }
1876 break;
1877 case SCE_NSCR_NUMBERS:
1878 // We accept almost anything because of hex. and number suffixes
1879 if (isdigit(sc.ch))
1880 {
1881 continue;
1882 }
1883 else if (sc.ch == '.' && sc.chNext != '.' && !numFloat)
1884 {
1885 // Don't parse 0..2 as number.
1886 numFloat=true;
1887 continue;
1888 }
1889 else if (( sc.ch == '-' || sc.ch == '+' )
1890 && (sc.chPrev == 'e' || sc.chPrev == 'E' ))
1891 {
1892 // Parse exponent sign in float literals: 2e+10 0x2e+10
1893 continue;
1894 }
1895 else if (( sc.ch == 'e' || sc.ch == 'E' )
1896 && (sc.chNext == '+' || sc.chNext == '-' || isdigit(sc.chNext)))
1897 {
1898 // Parse exponent sign in float literals: 2e+10 0x2e+10
1899 continue;
1900 }
1901 else if (sc.ch == 'i' && !isdigit(sc.chNext))
1902 {
1903 // Parse complex numbers
1904 continue;
1905 }
1906 else
1907 {
1908 sc.SetState(SCE_NSCR_DEFAULT);
1909 }
1910 break;
1912 if (!IsWord(sc.ch) && sc.ch != '~')
1913 {
1914 sc.SetState(SCE_NSCR_DEFAULT);
1915 }
1916 break;
1918 if (!IsWord(sc.ch))
1919 {
1920 // reverse identify the currently marched identifiers depending on the word list
1921 char s[1000];
1922 if (caseSensitive)
1923 {
1924 sc.GetCurrent(s, sizeof(s));
1925 }
1926 else
1927 {
1928 sc.GetCurrentLowered(s, sizeof(s));
1929 }
1930 /*
1931 "Commands",
1932 "Options",
1933 "Functions",
1934 "Methods",
1935 "Predefined variables",
1936 "Constants",
1937 "Special predefs",
1938 "Operator keywords",
1939 0,
1940 */
1941 if (commandWords.InList(s) && nInstallStart == -1)
1942 {
1943 sc.ChangeState(SCE_NSCR_COMMAND);
1944 }
1945 else if (functionWords.InList(s) && sc.ch == '(')
1946 {
1947 sc.ChangeState(SCE_NSCR_FUNCTION);
1948 }
1949 else if (methodWords.InList(s) && possibleMethod)
1950 {
1951 sc.ChangeState(SCE_NSCR_METHOD);
1952 }
1953 else if (defVarWords.InList(s))
1954 {
1955 sc.ChangeState(SCE_NSCR_DEFAULT_VARS);
1956 }
1957 else if (constantWords.InList(s))
1958 {
1959 sc.ChangeState(SCE_NSCR_CONSTANTS);
1960 }
1961 else if (preDefWords.InList(s))
1962 {
1963 sc.ChangeState(SCE_NSCR_PREDEFS);
1964 }
1965 else if (operatorWords.InList(s))
1966 {
1967 sc.ChangeState(SCE_NSCR_OPERATOR_KEYWORDS);
1968 }
1969 else if (procedureCommandWords.InList(s))
1970 {
1971 sc.ChangeState(SCE_NSCR_PROCEDURE_COMMANDS);
1972 }
1973 else if (sc.ch == '(')
1974 {
1975 sc.ChangeState(SCE_NSCR_CUSTOM_FUNCTION);
1976 }
1977 else if (sc.ch == '{')
1978 {
1979 sc.ChangeState(SCE_NSCR_CLUSTER);
1980 }
1981 else if (optionWords.InList(s))
1982 {
1983 sc.ChangeState(SCE_NSCR_OPTION);
1984 }
1985 possibleMethod = false;
1986 sc.SetState(SCE_NSCR_DEFAULT);
1987 }
1988 break;
1991 if (sc.Match('*', '#')) {
1992 sc.Forward();
1993 sc.ForwardSetState(SCE_NSCR_DEFAULT);
1994 }
1995 break;
1996 case SCE_NSCR_INCLUDES:
1999 if (sc.atLineStart) {
2000 sc.SetState(SCE_NSCR_DEFAULT);
2001 }
2002 break;
2003 case SCE_NSCR_STRING:
2004 if (sc.ch == '\\')
2005 {
2006 if (sc.chNext == '"' || sc.chNext == '\\')
2007 {
2008 sc.Forward();
2009 }
2010 }
2011 else if (sc.ch == '"')
2012 {
2013 sc.ForwardSetState(SCE_NSCR_DEFAULT);
2014 }
2015 break;
2016 case SCE_NSCR_FUNCTION:
2018 if (sc.ch == ' ' || sc.ch == '(' || sc.atLineStart)
2019 {
2020 sc.SetState(SCE_NSCR_DEFAULT);
2021 }
2022 break;
2023 }
2024
2025 // Forward search for documentation keywords
2026 if ((sc.state == SCE_NSCR_DOCCOMMENT_LINE || sc.state == SCE_NSCR_DOCCOMMENT_BLOCK) && sc.Match('\\'))
2027 {
2028 int nCurrentState = sc.state;
2029 sc.SetState(SCE_NSCR_DEFAULT);
2030 sc.Forward();
2031
2032 while (sc.More() && IsWord(sc.ch))
2033 sc.Forward();
2034
2035 char s[1000];
2036 sc.GetCurrent(s, sizeof(s));
2037
2038 if (docKeyWords.InList(s))
2039 sc.ChangeState(SCE_NSCR_DOCKEYWORD);
2040 else
2041 sc.ChangeState(nCurrentState);
2042
2043 sc.SetState(nCurrentState);
2044 }
2045
2046 // Determine if a new state should be entered.
2047 if (sc.state == SCE_NSCR_DEFAULT)
2048 {
2049 if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)))
2050 {
2051 sc.SetState(SCE_NSCR_NUMBERS);
2052 numFloat = sc.ch == '.';
2053 }
2054 else if (sc.ch == '.' && IsWordStart(static_cast<char>(sc.chNext)))
2055 possibleMethod = true;
2056 else if (IsWordStart(static_cast<char>(sc.ch)))
2057 {
2058 sc.SetState(SCE_NSCR_IDENTIFIER);
2059 }
2060 else if (sc.ch == '$')
2061 {
2062 sc.SetState(SCE_NSCR_PROCEDURES);
2063 }
2064 else if (sc.Match("#*!"))
2065 {
2066 sc.SetState(SCE_NSCR_DOCCOMMENT_BLOCK);
2067 sc.Forward(); // Eat the * so it isn't used for the end of the comment
2068 }
2069 else if (sc.Match("##!"))
2070 {
2071 sc.SetState(SCE_NSCR_DOCCOMMENT_LINE);
2072 sc.Forward();
2073 }
2074 else if (sc.Match('#', '*'))
2075 {
2076 sc.SetState(SCE_NSCR_COMMENT_BLOCK);
2077 sc.Forward(); // Eat the * so it isn't used for the end of the comment
2078 }
2079 else if (sc.Match('#', '#'))
2080 {
2081 sc.SetState(SCE_NSCR_COMMENT_LINE);
2082 sc.Forward();
2083 }
2084 else if (sc.ch == '"')
2085 {
2086 sc.SetState(SCE_NSCR_STRING);
2087 }
2088 else if (sc.ch == '#')
2089 {
2090 sc.SetState(SCE_NSCR_STRING_PARSER);
2091 }
2092 else if (sc.ch == '@')
2093 {
2094 sc.SetState(SCE_NSCR_INCLUDES);
2095 }
2096 else if (IsOperator(static_cast<char>(sc.ch)))
2097 {
2098 if (sc.ch == '<'
2099 && (sc.Match("<wp>") || sc.Match("<this>") || sc.Match("<loadpath>") || sc.Match("<savepath>") || sc.Match("<plotpath>") || sc.Match("<procpath>") || sc.Match("<scriptpath>")))
2100 {
2101 sc.SetState(SCE_NSCR_OPERATOR_KEYWORDS);
2102 }
2103 else if ((sc.ch == '<') && sc.Match("<install>"))
2104 {
2105 nInstallStart = sc.currentPos;
2106 }
2107 else if ((sc.ch == '<') && sc.Match("<endinstall>") && nInstallStart != -1)
2108 {
2109 styler.Flush();
2110 styler.StartAt(nInstallStart);
2111 styler.StartSegment(nInstallStart);
2112
2113 for (int i = nInstallStart; i <= sc.currentPos; i++)
2114 {
2115 if (styler.StyleAt(i) == SCE_NSCR_PROCEDURE_COMMANDS)
2116 {
2117 styler.ColourTo(i-1, SCE_NSCR_INSTALL);
2118
2119 while (styler.StyleAt(i+1) == SCE_NSCR_PROCEDURE_COMMANDS)
2120 i++;
2121
2122 styler.ColourTo(i, SCE_NSCR_PROCEDURE_COMMANDS);
2123 }
2124 }
2125
2126 styler.ColourTo(sc.currentPos+11, SCE_NSCR_INSTALL);
2127 sc.Forward(11);
2128 //sc.SetState(SCE_NSCR_DEFAULT);
2129 nInstallStart = -1;
2130 }
2131 else
2132 {
2133 sc.SetState(SCE_NSCR_OPERATORS);
2134 }
2135 }
2136 }
2137 }
2138 sc.Complete();
2139}
2140
2141// Store both the current line's fold level and the next lines in the
2142// level store to make it easy to pick up with each increment
2143// and to make it possible to fiddle the current level for "} else {".
2144
2145void SCI_METHOD LexerNSCR::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
2146{
2147
2148 if (!options.fold)
2149 return;
2150
2151 LexAccessor styler(pAccess);
2152
2153 unsigned int endPos = startPos + length;
2154 int visibleChars = 0;
2155 int lineCurrent = styler.GetLine(startPos);
2156 int levelCurrent = SC_FOLDLEVELBASE;
2157 if (lineCurrent > 0)
2158 levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
2159 int levelMinCurrent = levelCurrent;
2160 int levelNext = levelCurrent;
2161 char chNext = styler[startPos];
2162 int styleNext = styler.StyleAt(startPos);
2163 int style = initStyle;
2164 bool foldAtElse = options.foldAtElse;
2165 bool foundElse = false;
2166 const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
2167 for (unsigned int i = startPos; i < endPos; i++)
2168 {
2169 char ch = chNext;
2170 chNext = styler.SafeGetCharAt(i + 1);
2171 int stylePrev = style;
2172 style = styleNext;
2173 styleNext = styler.StyleAt(i + 1);
2174 bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
2176 {
2177 if (!(stylePrev == SCE_NSCR_COMMENT_BLOCK))
2178 {
2179 levelNext++;
2180 }
2181 else if (!(styleNext == SCE_NSCR_COMMENT_BLOCK) && !atEOL)
2182 {
2183 // Comments don't end at end of line and the next character may be unstyled.
2184 levelNext--;
2185 }
2186 }
2188 {
2189 if (userDefinedFoldMarkers)
2190 {
2191 if (styler.Match(i, options.foldExplicitStart.c_str()))
2192 {
2193 levelNext++;
2194 }
2195 else if (styler.Match(i, options.foldExplicitEnd.c_str()))
2196 {
2197 levelNext--;
2198 }
2199 }
2200 else
2201 {
2202 if ((ch == '#') && (chNext == '#')) //##{
2203 {
2204 char chNext2 = styler.SafeGetCharAt(i + 2);
2205 if (chNext2 == '{')
2206 {
2207 levelNext++;
2208 }
2209 else if (chNext2 == '}')
2210 {
2211 levelNext--;
2212 }
2213 }
2214 }
2215 }
2217 {
2218 bool isCommand = style == SCE_NSCR_COMMAND || style == SCE_NSCR_PROCEDURE_COMMANDS;
2219 std::string current;
2220 size_t n = i;
2221
2222 // Get the current snippet until another style or the next
2223 // non-visible character
2224 while (styler.StyleAt(n) == style && isgraph(styler.SafeGetCharAt(n)))
2225 {
2226 current += styler.SafeGetCharAt(n);
2227 n++;
2228 }
2229
2230 if (blockEndWords.InList(current.c_str()) && isCommand == (current.front() != '<'))
2231 {
2232 levelNext--;
2233 foundElse = false;
2234 }
2235 else if (styler.SafeGetCharAt(i-1) != 'd'
2236 && styler.SafeGetCharAt(i-1) != 'e'
2237 && blockStartWords.InList(current.c_str())
2238 && isCommand == (current.front() != '<'))
2239 {
2240 // Measure the minimum before a '{' to allow
2241 // folding on "} else {"
2242 /*if (levelMinCurrent > levelNext)
2243 {
2244 levelMinCurrent = levelNext;
2245 }*/
2246 levelNext++;
2247 }
2248 /*else if (styler.Match(i, "else"))
2249 {
2250 foundElse = true;
2251 int lev = levelCurrent | (levelNext-1) << 16;
2252
2253 //if (visibleChars == 0 && options.foldCompact)
2254 // lev |= SC_FOLDLEVELWHITEFLAG;
2255 //if (levelMinCurrent < levelNext-1)
2256 // lev |= SC_FOLDLEVELHEADERFLAG;
2257 if (lev != styler.LevelAt(lineCurrent-1))
2258 {
2259 styler.SetLevel(lineCurrent-1, lev);
2260 }
2261 }*/
2262 }
2263 if (atEOL || (i == endPos-1))
2264 {
2266 { // Handle nested comments
2267 int nc;
2268 nc = styler.GetLineState(lineCurrent);
2269 nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0;
2270 levelNext += nc;
2271 }
2272 int levelUse = levelCurrent;
2273 if (options.foldSyntaxBased && foldAtElse)
2274 {
2275 levelUse = levelMinCurrent;
2276 }
2277 int lev = levelUse | levelNext << 16;
2278 if (visibleChars == 0 && options.foldCompact)
2279 lev |= SC_FOLDLEVELWHITEFLAG;
2280 if (levelUse < levelNext || foundElse)
2281 lev |= SC_FOLDLEVELHEADERFLAG;
2282 if (lev != styler.LevelAt(lineCurrent))
2283 {
2284 styler.SetLevel(lineCurrent, lev);
2285 }
2286 lineCurrent++;
2287 levelCurrent = levelNext;
2288 levelMinCurrent = levelCurrent;
2289 visibleChars = 0;
2290 foundElse = false;
2291 }
2292 if (!IsASpace(ch))
2293 visibleChars++;
2294 }
2295}
2296
2297
2298
2300 bool fold;
2306 std::string foldExplicitEnd;
2311 fold = false;
2312 foldSyntaxBased = true;
2313 foldComment = false;
2314 foldCommentMultiline = true;
2315 foldCommentExplicit = true;
2316 foldExplicitStart = "";
2317 foldExplicitEnd = "";
2318 foldExplicitAnywhere = false;
2319 foldCompact = false;
2320 foldAtElse = true;
2321 }
2322};
2323
2324static const char * const NPRCWordLists[] = {
2325 "Commands",
2326 "Options",
2327 "Functions",
2328 "Methods",
2329 "Predefined variables",
2330 "Constants",
2331 "Special predefs",
2332 "Operator keywords",
2333 "Documentation keywords",
2334 0
2335 };
2336
2337struct OptionSetNPRC : public OptionSet<OptionsNPRC> {
2339 DefineProperty("fold", &OptionsNPRC::fold);
2340
2341 DefineProperty("fold.nscr.syntax.based", &OptionsNPRC::foldSyntaxBased,
2342 "Set this property to 0 to disable syntax based folding.");
2343
2344 DefineProperty("fold.comment", &OptionsNPRC::foldComment);
2345
2346 DefineProperty("fold.nscr.comment.multiline", &OptionsNPRC::foldCommentMultiline,
2347 "Set this property to 0 to disable folding multi-line comments when fold.comment=1.");
2348
2349 DefineProperty("fold.nscr.comment.explicit", &OptionsNPRC::foldCommentExplicit,
2350 "Set this property to 0 to disable folding explicit fold points when fold.comment=1.");
2351
2352 DefineProperty("fold.nscr.explicit.start", &OptionsNPRC::foldExplicitStart,
2353 "The string to use for explicit fold start points, replacing the standard //{.");
2354
2355 DefineProperty("fold.nscr.explicit.end", &OptionsNPRC::foldExplicitEnd,
2356 "The string to use for explicit fold end points, replacing the standard //}.");
2357
2358 DefineProperty("fold.nscr.explicit.anywhere", &OptionsNPRC::foldExplicitAnywhere,
2359 "Set this property to 1 to enable explicit fold points anywhere, not just in line comments.");
2360
2361 DefineProperty("fold.compact", &OptionsNPRC::foldCompact);
2362
2363 DefineProperty("fold.at.else", &OptionsNPRC::foldAtElse);
2364
2365 DefineWordListSets(NPRCWordLists);
2366 }
2367};
2368
2369class LexerNPRC : public ILexer {
2372 WordList optionWords;
2374 WordList methodWords;
2375 WordList defVarWords;
2377 WordList preDefWords;
2379 WordList docKeyWords;
2382 /*
2383 "Commands",
2384 "Options",
2385 "Functions",
2386 "Predefined variables",
2387 "Constants",
2388 "Special predefs",
2389 "Operator keywords",
2390 0,
2391 */
2394public:
2395 LexerNPRC(bool caseSensitive_) :
2396 caseSensitive(caseSensitive_) {
2397 defVarWords.Set("x y z t");
2398 }
2399 virtual ~LexerNPRC() {
2400 }
2401 void SCI_METHOD Release() {
2402 delete this;
2403 }
2404 int SCI_METHOD Version() const {
2405 return lvOriginal;
2406 }
2407 const char * SCI_METHOD PropertyNames() {
2408 return osNPRC.PropertyNames();
2409 }
2410 int SCI_METHOD PropertyType(const char *name) {
2411 return osNPRC.PropertyType(name);
2412 }
2413 const char * SCI_METHOD DescribeProperty(const char *name) {
2414 return osNPRC.DescribeProperty(name);
2415 }
2416 int SCI_METHOD PropertySet(const char *key, const char *val);
2417 const char * SCI_METHOD DescribeWordListSets() {
2418 return osNPRC.DescribeWordListSets();
2419 }
2420 int SCI_METHOD WordListSet(int n, const char *wl);
2421 void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
2422 void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
2423
2424 void * SCI_METHOD PrivateCall(int, void *) {
2425 return 0;
2426 }
2427
2428 static ILexer *LexerFactoryNPRC() {
2429 return new LexerNPRC(true);
2430 }
2432 return new LexerNPRC(false);
2433 }
2434};
2435
2436int SCI_METHOD LexerNPRC::PropertySet(const char *key, const char *val) {
2437 if (osNPRC.PropertySet(&options, key, val)) {
2438 return 0;
2439 }
2440 return -1;
2441}
2442
2443int SCI_METHOD LexerNPRC::WordListSet(int n, const char *wl) {
2444 WordList *wordListN = 0;
2445 switch (n) {
2446 case 0:
2447 wordListN = &commandWords;
2448 break;
2449 case 1:
2450 wordListN = &optionWords;
2451 break;
2452 case 2:
2453 wordListN = &functionWords;
2454 break;
2455 case 3:
2456 wordListN = &methodWords;
2457 break;
2458 case 4:
2459 {
2460 std::string words = wl;
2461
2462 if (words.find(';') != std::string::npos)
2463 {
2464 blockStartWords.Set(words.substr(0, words.find(';')).c_str());
2465 blockEndWords.Set(words.substr(words.find(';')+1).c_str());
2466 }
2467
2468 }
2469 return 0;
2470 case 5:
2471 wordListN = &constantWords;
2472 break;
2473 case 6:
2474 wordListN = &preDefWords;
2475 break;
2476 case 7:
2477 wordListN = &operatorWords;
2478 break;
2479 case 8:
2480 wordListN = &docKeyWords;
2481 break;
2482 }
2483 int firstModification = -1;
2484 if (wordListN) {
2485 WordList wlNew;
2486 wlNew.Set(wl);
2487 if (*wordListN != wlNew) {
2488 wordListN->Set(wl);
2489 firstModification = 0;
2490 }
2491 }
2492 return firstModification;
2493}
2494
2495void SCI_METHOD LexerNPRC::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
2496{
2497 LexAccessor styler(pAccess);
2498
2499 int styleBeforeDCKeyword = SCE_NPRC_DEFAULT;
2500
2501 StyleContext sc(startPos, length, initStyle, styler);
2502
2503 int curLine = styler.GetLine(startPos);
2504 int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
2505 bool numFloat = false; // Float literals have '+' and '-' signs
2506 bool numHex = false;
2507 bool possibleMethod = false;
2508
2509 for (; sc.More(); sc.Forward()) {
2510
2511 if (sc.atLineStart) {
2512 curLine = styler.GetLine(sc.currentPos);
2513 styler.SetLineState(curLine, curNcLevel);
2514 }
2515
2516 // Determine if the current state should terminate.
2517 switch (sc.state) {
2518 case SCE_NPRC_OPERATORS:
2519 sc.SetState(SCE_NPRC_DEFAULT);
2520 break;
2522 if (sc.ch == '>')
2523 {
2524 sc.ForwardSetState(SCE_NPRC_DEFAULT);
2525 }
2526 break;
2527 case SCE_NPRC_NUMBERS:
2528 // We accept almost anything because of hex. and number suffixes
2529 if (isdigit(sc.ch))
2530 {
2531 continue;
2532 }
2533 else if (sc.ch == '.' && sc.chNext != '.' && !numFloat)
2534 {
2535 // Don't parse 0..2 as number.
2536 numFloat=true;
2537 continue;
2538 }
2539 else if (( sc.ch == '-' || sc.ch == '+' )
2540 && (sc.chPrev == 'e' || sc.chPrev == 'E' ))
2541 {
2542 // Parse exponent sign in float literals: 2e+10 0x2e+10
2543 continue;
2544 }
2545 else if (( sc.ch == 'e' || sc.ch == 'E' )
2546 && (sc.chNext == '+' || sc.chNext == '-' || isdigit(sc.chNext)))
2547 {
2548 // Parse exponent sign in float literals: 2e+10 0x2e+10
2549 continue;
2550 }
2551 else if (sc.ch == 'i' && !isdigit(sc.chNext))
2552 {
2553 // Parse complex numbers
2554 continue;
2555 }
2556 else
2557 {
2558 sc.SetState(SCE_NPRC_DEFAULT);
2559 }
2560 break;
2562 if (!IsWord(sc.ch) && sc.ch != '~')
2563 {
2564 sc.SetState(SCE_NPRC_DEFAULT);
2565 }
2566 break;
2568 if (!IsWord(sc.ch))
2569 {
2570 // reverse identify the currently marched identifiers depending on the word list
2571 char s[1000];
2572 if (caseSensitive)
2573 {
2574 sc.GetCurrent(s, sizeof(s));
2575 }
2576 else
2577 {
2578 sc.GetCurrentLowered(s, sizeof(s));
2579 }
2580 /*
2581 "Commands",
2582 "Options",
2583 "Functions",
2584 "Predefined variables",
2585 "Constants",
2586 "Special predefs",
2587 "Operator keywords",
2588 0,
2589 */
2590 if (commandWords.InList(s))
2591 {
2592 sc.ChangeState(SCE_NPRC_COMMAND);
2593 }
2594 else if (functionWords.InList(s) && sc.ch == '(')
2595 {
2596 sc.ChangeState(SCE_NPRC_FUNCTION);
2597 }
2598 else if (methodWords.InList(s) && possibleMethod)
2599 {
2600 sc.ChangeState(SCE_NPRC_METHOD);
2601 }
2602 else if (defVarWords.InList(s))
2603 {
2604 sc.ChangeState(SCE_NPRC_DEFAULT_VARS);
2605 }
2606 else if (constantWords.InList(s))
2607 {
2608 sc.ChangeState(SCE_NPRC_CONSTANTS);
2609 }
2610 else if (preDefWords.InList(s))
2611 {
2612 sc.ChangeState(SCE_NPRC_PREDEFS);
2613 }
2614 else if (operatorWords.InList(s))
2615 {
2616 sc.ChangeState(SCE_NPRC_OPERATOR_KEYWORDS);
2617 }
2618 else if (sc.ch == '(')
2619 {
2620 sc.ChangeState(SCE_NPRC_CUSTOM_FUNCTION);
2621 }
2622 else if (sc.ch == '{')
2623 {
2624 sc.ChangeState(SCE_NPRC_CLUSTER);
2625 }
2626 else if (optionWords.InList(s))
2627 {
2628 sc.ChangeState(SCE_NPRC_OPTION);
2629 }
2630 sc.SetState(SCE_NPRC_DEFAULT);
2631 possibleMethod = false;
2632 }
2633 break;
2636 if (sc.Match('*', '#')) {
2637 sc.Forward();
2638 sc.ForwardSetState(SCE_NPRC_DEFAULT);
2639 }
2640 break;
2641 case SCE_NPRC_INCLUDES:
2642 case SCE_NPRC_FLAGS:
2645 if (sc.atLineStart) {
2646 sc.SetState(SCE_NSCR_DEFAULT);
2647 }
2648 break;
2649 case SCE_NPRC_STRING:
2650 if (sc.ch == '\\')
2651 {
2652 if (sc.chNext == '"' || sc.chNext == '\\')
2653 {
2654 sc.Forward();
2655 }
2656 }
2657 else if (sc.ch == '"')
2658 {
2659 sc.ForwardSetState(SCE_NPRC_DEFAULT);
2660 }
2661 break;
2662 case SCE_NPRC_FUNCTION:
2664 if (sc.ch == ' ' || sc.ch == '(' || sc.atLineStart)
2665 {
2666 sc.SetState(SCE_NPRC_DEFAULT);
2667 }
2668 break;
2669 }
2670
2671 // Forward search for documentation keywords
2672 if ((sc.state == SCE_NPRC_DOCCOMMENT_LINE || sc.state == SCE_NPRC_DOCCOMMENT_BLOCK) && sc.Match('\\'))
2673 {
2674 int nCurrentState = sc.state;
2675 sc.SetState(SCE_NPRC_DEFAULT);
2676 sc.Forward();
2677
2678 while (sc.More() && IsWord(sc.ch))
2679 sc.Forward();
2680
2681 char s[1000];
2682 sc.GetCurrent(s, sizeof(s));
2683
2684 if (docKeyWords.InList(s))
2685 sc.ChangeState(SCE_NPRC_DOCKEYWORD);
2686 else
2687 sc.ChangeState(nCurrentState);
2688
2689 sc.SetState(nCurrentState);
2690 }
2691
2692 // Determine if a new state should be entered.
2693 if (sc.state == SCE_NPRC_DEFAULT)
2694 {
2695 if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)))
2696 {
2697 sc.SetState(SCE_NSCR_NUMBERS);
2698 numFloat = sc.ch == '.';
2699 }
2700 else if (sc.ch == '.' && IsWordStart(static_cast<char>(sc.chNext)))
2701 possibleMethod = true;
2702 else if (IsWordStart(static_cast<char>(sc.ch)))
2703 {
2704 sc.SetState(SCE_NPRC_IDENTIFIER);
2705 }
2706 else if (sc.ch == '$')
2707 {
2708 sc.SetState(SCE_NPRC_PROCEDURES);
2709 }
2710 else if (sc.Match("#*!"))
2711 {
2712 sc.SetState(SCE_NPRC_DOCCOMMENT_BLOCK);
2713 sc.Forward(); // Eat the * so it isn't used for the end of the comment
2714 }
2715 else if (sc.Match("##!"))
2716 {
2717 sc.SetState(SCE_NPRC_DOCCOMMENT_LINE);
2718 sc.Forward();
2719 }
2720 else if (sc.Match('#', '*'))
2721 {
2722 sc.SetState(SCE_NPRC_COMMENT_BLOCK);
2723 sc.Forward(); // Eat the * so it isn't used for the end of the comment
2724 }
2725 else if (sc.Match('#', '#'))
2726 {
2727 sc.SetState(SCE_NPRC_COMMENT_LINE);
2728 sc.Forward();
2729 }
2730 else if (sc.ch == '"')
2731 {
2732 sc.SetState(SCE_NPRC_STRING);
2733 }
2734 else if (sc.ch == '#')
2735 {
2736 sc.SetState(SCE_NPRC_STRING_PARSER);
2737 }
2738 else if (sc.ch == '@')
2739 {
2740 sc.SetState(SCE_NPRC_INCLUDES);
2741 }
2742 else if (IsOperator(static_cast<char>(sc.ch)))
2743 {
2744 if (sc.ch == '<'
2745 && (sc.Match("<wp>") || sc.Match("<this>") || sc.Match("<loadpath>") || sc.Match("<savepath>") || sc.Match("<plotpath>") || sc.Match("<procpath>") || sc.Match("<scriptpath>")))
2746 {
2747 sc.SetState(SCE_NPRC_OPERATOR_KEYWORDS);
2748 }
2749 else if (sc.ch == ':' && sc.chNext == ':')
2750 {
2751 sc.SetState(SCE_NPRC_FLAGS);
2752 }
2753 else
2754 {
2755 sc.SetState(SCE_NPRC_OPERATORS);
2756 }
2757 }
2758 }
2759 }
2760 sc.Complete();
2761}
2762
2763// Store both the current line's fold level and the next lines in the
2764// level store to make it easy to pick up with each increment
2765// and to make it possible to fiddle the current level for "} else {".
2766
2767void SCI_METHOD LexerNPRC::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
2768{
2769
2770 if (!options.fold)
2771 return;
2772
2773 LexAccessor styler(pAccess);
2774
2775 unsigned int endPos = startPos + length;
2776 int visibleChars = 0;
2777 int lineCurrent = styler.GetLine(startPos);
2778 int levelCurrent = SC_FOLDLEVELBASE;
2779 if (lineCurrent > 0)
2780 levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
2781 int levelMinCurrent = levelCurrent;
2782 int levelNext = levelCurrent;
2783 char chNext = styler[startPos];
2784 int styleNext = styler.StyleAt(startPos);
2785 int style = initStyle;
2786 bool foldAtElse = options.foldAtElse;
2787 bool foundElse = false;
2788 const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
2789 for (unsigned int i = startPos; i < endPos; i++)
2790 {
2791 char ch = chNext;
2792 chNext = styler.SafeGetCharAt(i + 1);
2793 int stylePrev = style;
2794 style = styleNext;
2795 styleNext = styler.StyleAt(i + 1);
2796 bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
2798 {
2799 if (!(stylePrev == SCE_NPRC_COMMENT_BLOCK))
2800 {
2801 levelNext++;
2802 }
2803 else if (!(styleNext == SCE_NPRC_COMMENT_BLOCK) && !atEOL)
2804 {
2805 // Comments don't end at end of line and the next character may be unstyled.
2806 levelNext--;
2807 }
2808 }
2810 {
2811 if (userDefinedFoldMarkers)
2812 {
2813 if (styler.Match(i, options.foldExplicitStart.c_str()))
2814 {
2815 levelNext++;
2816 }
2817 else if (styler.Match(i, options.foldExplicitEnd.c_str()))
2818 {
2819 levelNext--;
2820 }
2821 }
2822 else
2823 {
2824 if ((ch == '#') && (chNext == '#')) //##{
2825 {
2826 char chNext2 = styler.SafeGetCharAt(i + 2);
2827 if (chNext2 == '{')
2828 {
2829 levelNext++;
2830 }
2831 else if (chNext2 == '}')
2832 {
2833 levelNext--;
2834 }
2835 }
2836 }
2837 }
2838 if (options.foldSyntaxBased && (style == SCE_NPRC_IDENTIFIER || style == SCE_NPRC_COMMAND))
2839 {
2840 std::string current;
2841 size_t n = i;
2842
2843 // Get the current snippet until another style or the next
2844 // non-visible character
2845 while (styler.StyleAt(n) == style && isgraph(styler.SafeGetCharAt(n)))
2846 {
2847 current += styler.SafeGetCharAt(n);
2848 n++;
2849 }
2850
2851 if (blockEndWords.InList(current.c_str()))
2852 {
2853 levelNext--;
2854 foundElse = false;
2855 }
2856 else if (styler.SafeGetCharAt(i-1) != 'd'
2857 && styler.SafeGetCharAt(i-1) != 'e'
2858 && blockStartWords.InList(current.c_str()))
2859 {
2860 // Measure the minimum before a '{' to allow
2861 // folding on "} else {"
2862 /*if (levelMinCurrent > levelNext)
2863 {
2864 levelMinCurrent = levelNext;
2865 }*/
2866 levelNext++;
2867 }
2868 /*else if (styler.Match(i, "else"))
2869 {
2870 foundElse = true;
2871 int lev = levelCurrent | (levelNext-1) << 16;
2872
2873 //if (visibleChars == 0 && options.foldCompact)
2874 // lev |= SC_FOLDLEVELWHITEFLAG;
2875 //if (levelMinCurrent < levelNext-1)
2876 // lev |= SC_FOLDLEVELHEADERFLAG;
2877 if (lev != styler.LevelAt(lineCurrent-1))
2878 {
2879 styler.SetLevel(lineCurrent-1, lev);
2880 }
2881 }*/
2882 }
2883 if (atEOL || (i == endPos-1))
2884 {
2886 { // Handle nested comments
2887 int nc;
2888 nc = styler.GetLineState(lineCurrent);
2889 nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0;
2890 levelNext += nc;
2891 }
2892 int levelUse = levelCurrent;
2893 if (options.foldSyntaxBased && foldAtElse)
2894 {
2895 levelUse = levelMinCurrent;
2896 }
2897 int lev = levelUse | levelNext << 16;
2898 if (visibleChars == 0 && options.foldCompact)
2899 lev |= SC_FOLDLEVELWHITEFLAG;
2900 if (levelUse < levelNext || foundElse)
2901 lev |= SC_FOLDLEVELHEADERFLAG;
2902 if (lev != styler.LevelAt(lineCurrent))
2903 {
2904 styler.SetLevel(lineCurrent, lev);
2905 }
2906 lineCurrent++;
2907 levelCurrent = levelNext;
2908 levelMinCurrent = levelCurrent;
2909 visibleChars = 0;
2910 foundElse = false;
2911 }
2912 if (!IsASpace(ch))
2913 visibleChars++;
2914 }
2915}
2916
2917
2918
2919
2920class LexerTXTADV : public ILexer {
2922 /*WordList keywords;
2923 WordList keywords2;
2924 WordList keywords3;
2925 WordList keywords4;
2926 WordList keywords5;
2927 WordList keywords6;
2928 WordList keywords7;
2929 WordList keywords8;*/
2930 /*
2931 "Commands",
2932 "Options",
2933 "Functions",
2934 "Predefined variables",
2935 "Constants",
2936 "Special predefs",
2937 "Operator keywords",
2938 0,
2939 */
2940 //OptionsNSCR options;
2941 //OptionSetNSCR osNSCR;
2942public:
2943 LexerTXTADV(bool caseSensitive_) :
2944 caseSensitive(caseSensitive_) {
2945 }
2946 virtual ~LexerTXTADV() {
2947 }
2948 void SCI_METHOD Release() {
2949 delete this;
2950 }
2951 int SCI_METHOD Version() const {
2952 return lvOriginal;
2953 }
2954 const char * SCI_METHOD PropertyNames() {
2955 return "";
2956 }
2957 int SCI_METHOD PropertyType(const char *name) {
2958 return 0;
2959 }
2960 const char * SCI_METHOD DescribeProperty(const char *name) {
2961 return "";
2962 }
2963 int SCI_METHOD PropertySet(const char *key, const char *val) {return 0;}
2964 const char * SCI_METHOD DescribeWordListSets() {
2965 return "";
2966 }
2967 int SCI_METHOD WordListSet(int n, const char *wl) {return 0;}
2968 void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
2969 void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {return;};
2970
2971 void * SCI_METHOD PrivateCall(int, void *) {
2972 return 0;
2973 }
2974
2975 static ILexer *LexerFactoryTXTADV() {
2976 return new LexerTXTADV(true);
2977 }
2979 return new LexerTXTADV(false);
2980 }
2981};
2982
2983/*int SCI_METHOD LexerNSCR::PropertySet(const char *key, const char *val) {
2984 if (osNSCR.PropertySet(&options, key, val)) {
2985 return 0;
2986 }
2987 return -1;
2988}
2989
2990int SCI_METHOD LexerNSCR::WordListSet(int n, const char *wl) {
2991 WordList *wordListN = 0;
2992 switch (n) {
2993 case 0:
2994 wordListN = &keywords;
2995 break;
2996 case 1:
2997 wordListN = &keywords2;
2998 break;
2999 case 2:
3000 wordListN = &keywords3;
3001 break;
3002 case 3:
3003 wordListN = &keywords4;
3004 break;
3005 case 4:
3006 wordListN = &keywords5;
3007 break;
3008 case 5:
3009 wordListN = &keywords6;
3010 break;
3011 case 6:
3012 wordListN = &keywords7;
3013 break;
3014 case 7:
3015 wordListN = &keywords8;
3016 break;
3017 }
3018 int firstModification = -1;
3019 if (wordListN) {
3020 WordList wlNew;
3021 wlNew.Set(wl);
3022 if (*wordListN != wlNew) {
3023 wordListN->Set(wl);
3024 firstModification = 0;
3025 }
3026 }
3027 return firstModification;
3028}*/
3029
3030// helper defines
3031#define SCE_TXTADV_POSSIB_URL 20
3032void SCI_METHOD LexerTXTADV::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
3033{
3034 LexAccessor styler(pAccess);
3035
3036 int styleBeforeDCKeyword = SCE_TXTADV_DEFAULT;
3037
3038 StyleContext sc(startPos, length, initStyle, styler);
3039
3040 int curLine = styler.GetLine(startPos);
3041 int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
3042
3043 for (; sc.More(); sc.Forward()) {
3044
3045 if (sc.atLineStart) {
3046 curLine = styler.GetLine(sc.currentPos);
3047 styler.SetLineState(curLine, curNcLevel);
3048 }
3049
3050 // Determine if the current state should terminate.
3051 switch (sc.state)
3052 {
3054 sc.SetState(SCE_TXTADV_DEFAULT);
3055 break;
3056 case SCE_TXTADV_BOLD:
3057 case SCE_TXTADV_ITALIC:
3059 if (sc.ch == '*')
3060 {
3061 if (sc.state == SCE_TXTADV_BOLD_ITALIC)
3062 {
3063 if (sc.Match("***"))
3064 {
3065 sc.SetState(SCE_TXTADV_MODIFIER);
3066 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3067 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3068 sc.ForwardSetState(SCE_TXTADV_DEFAULT);
3069 }
3070 else if (sc.Match("**"))
3071 {
3072 sc.SetState(SCE_TXTADV_MODIFIER);
3073 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3074 sc.ForwardSetState(SCE_TXTADV_ITALIC);
3075 }
3076 else
3077 {
3078 sc.SetState(SCE_TXTADV_MODIFIER);
3079 sc.ForwardSetState(SCE_TXTADV_BOLD);
3080 }
3081 }
3082 else if (sc.state == SCE_TXTADV_BOLD)
3083 {
3084 if (sc.Match("***"))
3085 {
3086 sc.SetState(SCE_TXTADV_MODIFIER);
3087 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3088 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3089 sc.ForwardSetState(SCE_TXTADV_ITALIC);
3090 }
3091 else if (sc.Match("**"))
3092 {
3093 sc.SetState(SCE_TXTADV_MODIFIER);
3094 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3095 sc.ForwardSetState(SCE_TXTADV_DEFAULT);
3096 }
3097 else
3098 {
3099 sc.SetState(SCE_TXTADV_MODIFIER);
3100 sc.ForwardSetState(SCE_TXTADV_BOLD_ITALIC);
3101 }
3102 }
3103 else
3104 {
3105 if (sc.Match("***"))
3106 {
3107 sc.SetState(SCE_TXTADV_MODIFIER);
3108 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3109 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3110 sc.ForwardSetState(SCE_TXTADV_BOLD);
3111 }
3112 else if (sc.Match("**"))
3113 {
3114 sc.SetState(SCE_TXTADV_MODIFIER);
3115 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3116 sc.ForwardSetState(SCE_TXTADV_BOLD_ITALIC);
3117 }
3118 else
3119 {
3120 sc.SetState(SCE_TXTADV_MODIFIER);
3121 sc.ForwardSetState(SCE_TXTADV_DEFAULT);
3122 }
3123 }
3124 }
3125 break;
3126 case SCE_TXTADV_HEAD:
3127 case SCE_TXTADV_BIGHEAD:
3128 if (sc.atLineStart)
3129 sc.SetState(SCE_TXTADV_DEFAULT);
3130 break;
3132 if (sc.ch == ' ' || sc.ch == '\t' || sc.ch == '*' || sc.ch == '_' || sc.ch == '-' || sc.atLineStart)
3133 sc.ChangeState(SCE_TXTADV_DEFAULT);
3134 else if (sc.Match("://"))
3135 sc.ChangeState(SCE_TXTADV_URL);
3136 break;
3137 case SCE_TXTADV_URL:
3138 if (sc.ch == ' ' || sc.atLineStart)
3139 sc.SetState(SCE_TXTADV_DEFAULT);
3140 break;
3142 if (sc.ch == '-' && (sc.chPrev == ' ' || sc.chNext == ' '))
3143 {
3144 sc.SetState(SCE_TXTADV_MODIFIER);
3145 sc.ForwardSetState(SCE_TXTADV_DEFAULT);
3146 }
3147 break;
3149 if (sc.ch == '_' && (sc.chPrev == ' ' || sc.chNext == ' '))
3150 {
3151 sc.SetState(SCE_TXTADV_MODIFIER);
3152 sc.ForwardSetState(SCE_TXTADV_DEFAULT);
3153 }
3154 break;
3155 }
3156
3157 // Determine if a new state should be entered.
3158 if (sc.state == SCE_TXTADV_DEFAULT)
3159 {
3160 if (sc.ch == '*')
3161 {
3162 if (sc.Match("***"))
3163 {
3164 sc.SetState(SCE_TXTADV_MODIFIER);
3165 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3166 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3167 sc.ForwardSetState(SCE_TXTADV_BOLD_ITALIC);
3168 }
3169 else if (sc.Match("**"))
3170 {
3171 sc.SetState(SCE_TXTADV_MODIFIER);
3172 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3173 sc.ForwardSetState(SCE_TXTADV_BOLD);
3174 }
3175 else
3176 {
3177 sc.SetState(SCE_TXTADV_MODIFIER);
3178 sc.ForwardSetState(SCE_TXTADV_ITALIC);
3179 }
3180 }
3181 else if (sc.ch == '_' && sc.chPrev == ' ')
3182 {
3183 sc.SetState(SCE_TXTADV_MODIFIER);
3184 sc.ForwardSetState(SCE_TXTADV_UNDERLINE);
3185 }
3186 else if (sc.ch == '#')
3187 {
3188 if (sc.Match("##"))
3189 {
3190 sc.SetState(SCE_TXTADV_MODIFIER);
3191 sc.ForwardSetState(SCE_TXTADV_MODIFIER);
3192 sc.ForwardSetState(SCE_TXTADV_HEAD);
3193 }
3194 else
3195 {
3196 sc.SetState(SCE_TXTADV_MODIFIER);
3197 sc.ForwardSetState(SCE_TXTADV_BIGHEAD);
3198 }
3199 }
3200 else if (sc.ch == '-')
3201 {
3202 if (sc.Match("--"))
3203 {
3204 sc.Forward();
3205 }
3206 else if (sc.chPrev == ' ')
3207 {
3208 sc.SetState(SCE_TXTADV_MODIFIER);
3209 sc.ForwardSetState(SCE_TXTADV_STRIKETHROUGH);
3210 }
3211 }
3212 else if (isalpha(sc.ch))
3213 sc.SetState(SCE_TXTADV_POSSIB_URL);
3214 }
3215 }
3216 sc.Complete();
3217}
3218
3219// Store both the current line's fold level and the next lines in the
3220// level store to make it easy to pick up with each increment
3221// and to make it possible to fiddle the current level for "} else {".
3222/*
3223void SCI_METHOD LexerNSCR::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
3224{
3225
3226 if (!options.fold)
3227 return;
3228
3229 LexAccessor styler(pAccess);
3230
3231 unsigned int endPos = startPos + length;
3232 int visibleChars = 0;
3233 int lineCurrent = styler.GetLine(startPos);
3234 int levelCurrent = SC_FOLDLEVELBASE;
3235 if (lineCurrent > 0)
3236 levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
3237 int levelMinCurrent = levelCurrent;
3238 int levelNext = levelCurrent;
3239 char chNext = styler[startPos];
3240 int styleNext = styler.StyleAt(startPos);
3241 int style = initStyle;
3242 bool foldAtElse = options.foldAtElse;
3243 bool foundElse = false;
3244 const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
3245 for (unsigned int i = startPos; i < endPos; i++)
3246 {
3247 char ch = chNext;
3248 chNext = styler.SafeGetCharAt(i + 1);
3249 int stylePrev = style;
3250 style = styleNext;
3251 styleNext = styler.StyleAt(i + 1);
3252 bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
3253 if (options.foldComment && options.foldCommentMultiline)
3254 {
3255 if (!(stylePrev == SCE_NSCR_COMMENT_BLOCK))
3256 {
3257 levelNext++;
3258 }
3259 else if (!(styleNext == SCE_NSCR_COMMENT_BLOCK) && !atEOL)
3260 {
3261 // Comments don't end at end of line and the next character may be unstyled.
3262 levelNext--;
3263 }
3264 }
3265 if (options.foldComment && options.foldCommentExplicit && ((style == SCE_NSCR_COMMENT_LINE) || options.foldExplicitAnywhere))
3266 {
3267 if (userDefinedFoldMarkers)
3268 {
3269 if (styler.Match(i, options.foldExplicitStart.c_str()))
3270 {
3271 levelNext++;
3272 }
3273 else if (styler.Match(i, options.foldExplicitEnd.c_str()))
3274 {
3275 levelNext--;
3276 }
3277 }
3278 else
3279 {
3280 if ((ch == '#') && (chNext == '#')) //##{
3281 {
3282 char chNext2 = styler.SafeGetCharAt(i + 2);
3283 if (chNext2 == '{')
3284 {
3285 levelNext++;
3286 }
3287 else if (chNext2 == '}')
3288 {
3289 levelNext--;
3290 }
3291 }
3292 }
3293 }
3294 if (options.foldSyntaxBased && (style == SCE_NSCR_IDENTIFIER || style == SCE_NSCR_COMMAND || style == SCE_NSCR_INSTALL || style == SCE_NSCR_PROCEDURE_COMMANDS))
3295 {
3296 if (styler.Match(i, "endif")
3297 || styler.Match(i, "endfor")
3298 || styler.Match(i, "endwhile")
3299 || styler.Match(i, "endprocedure")
3300 || styler.Match(i, "endcompose")
3301 || styler.Match(i, "<endinstall>")
3302 || styler.Match(i, "<endinfo>")
3303 || styler.Match(i, "</helpindex>")
3304 || styler.Match(i, "</helpfile>")
3305 || styler.Match(i, "</article>")
3306 || styler.Match(i, "</keywords>")
3307 || styler.Match(i, "</keyword>")
3308 || styler.Match(i, "</codeblock>")
3309 || styler.Match(i, "</exprblock>")
3310 || styler.Match(i, "</example>")
3311 || styler.Match(i, "</item>")
3312 || styler.Match(i, "</list>"))
3313 {
3314 levelNext--;
3315 foundElse = false;
3316 }
3317 else if (styler.SafeGetCharAt(i-1) != 'd'
3318 && styler.SafeGetCharAt(i-1) != 'e'
3319 && (styler.Match(i, "if ") || styler.Match(i, "if(")
3320 || styler.Match(i, "for ") || styler.Match(i, "for(")
3321 || styler.Match(i, "while ") || styler.Match(i, "while(")
3322 || styler.Match(i, "procedure ") || styler.Match(i, "compose")
3323 || styler.Match(i, "<install>")
3324 || styler.Match(i, "<info>")
3325 || styler.Match(i, "<helpindex>")
3326 || styler.Match(i, "<helpfile>")
3327 || styler.Match(i, "<article")
3328 || styler.Match(i, "<keywords>")
3329 || styler.Match(i, "<keyword>")
3330 || styler.Match(i, "<codeblock>")
3331 || styler.Match(i, "<exprblock>")
3332 || styler.Match(i, "<example")
3333 || styler.Match(i, "<item")
3334 || styler.Match(i, "<list")
3335 ))
3336 {
3337 // Measure the minimum before a '{' to allow
3338 // folding on "} else {"
3339
3340 levelNext++;
3341 }
3342
3343 }
3344 if (atEOL || (i == endPos-1))
3345 {
3346 if (options.foldComment && options.foldCommentMultiline)
3347 { // Handle nested comments
3348 int nc;
3349 nc = styler.GetLineState(lineCurrent);
3350 nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0;
3351 levelNext += nc;
3352 }
3353 int levelUse = levelCurrent;
3354 if (options.foldSyntaxBased && foldAtElse)
3355 {
3356 levelUse = levelMinCurrent;
3357 }
3358 int lev = levelUse | levelNext << 16;
3359 if (visibleChars == 0 && options.foldCompact)
3360 lev |= SC_FOLDLEVELWHITEFLAG;
3361 if (levelUse < levelNext || foundElse)
3362 lev |= SC_FOLDLEVELHEADERFLAG;
3363 if (lev != styler.LevelAt(lineCurrent))
3364 {
3365 styler.SetLevel(lineCurrent, lev);
3366 }
3367 lineCurrent++;
3368 levelCurrent = levelNext;
3369 levelMinCurrent = levelCurrent;
3370 visibleChars = 0;
3371 foundElse = false;
3372 }
3373 if (!IsASpace(ch))
3374 visibleChars++;
3375 }
3376}
3377*/
3378
3379
3380
3381
3385
3393LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");
static bool IsStreamCommentStyle(int style)
Definition: LexOthers.cxx:1612
static const char *const emptyWordListDesc[]
Definition: LexOthers.cxx:1487
static bool IsAlphabetic(int ch)
Definition: LexOthers.cxx:47
static bool IsWord(int ch)
Definition: LexOthers.cxx:1580
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc)
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:1160
static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:566
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc)
#define SCE_TXTADV_POSSIB_URL
Definition: LexOthers.cxx:3031
static bool latexIsBlank(int ch)
Definition: LexOthers.cxx:1191
static bool latexIsBlankAndNL(int ch)
Definition: LexOthers.cxx:1195
LexerModule lmNSCR(SCLEX_NSCR, LexerNSCR::LexerFactoryNSCR, "NSCR", NSCRWordLists)
static bool IsBOperator(char ch)
Definition: LexOthers.cxx:57
static bool isassignchar(unsigned char ch)
Definition: LexOthers.cxx:693
static bool latexNextNotBlankIs(int i, int l, Accessor &styler, char needle)
Definition: LexOthers.cxx:1223
static bool IsOperator(int ch)
Definition: LexOthers.cxx:1584
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc)
static bool AtEOL(Accessor &styler, unsigned int i)
Definition: LexOthers.cxx:51
static void ColouriseErrorListLine(char *lineBuffer, unsigned int lengthLine, unsigned int endPos, Accessor &styler, bool valueSeparate)
Definition: LexOthers.cxx:1144
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *keywordlists[], Accessor &styler)
Definition: LexOthers.cxx:477
static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:1491
#define DIFF_BUFFER_START_SIZE
Definition: LexOthers.cxx:507
static const char *const NSCRWordLists[]
Definition: LexOthers.cxx:1647
static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:672
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc)
static bool latexLastWordIs(int start, Accessor &styler, const char *needle)
Definition: LexOthers.cxx:1238
static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:1253
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc)
static bool Is0To9(char ch)
Definition: LexOthers.cxx:39
static bool strstart(const char *haystack, const char *needle)
Definition: LexOthers.cxx:35
static bool IsStringSuffix(int ch)
Definition: LexOthers.cxx:1608
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:925
LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc)
static void ColouriseMakeLine(char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, Accessor &styler)
Definition: LexOthers.cxx:843
static void FoldPropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:771
static void FoldDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:592
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
Definition: LexOthers.cxx:741
static bool Is1To9(char ch)
Definition: LexOthers.cxx:43
static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine, int &startValue)
Definition: LexOthers.cxx:946
static void ColourisePropsLine(char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, Accessor &styler, bool allowInitialSpaces)
Definition: LexOthers.cxx:697
static const char *const batchWordListDesc[]
Definition: LexOthers.cxx:1481
LexerModule lmNPRC(SCLEX_NPRC, LexerNPRC::LexerFactoryNPRC, "NPRC", NPRCWordLists)
static void ColourisePoLine(char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, Accessor &styler)
Definition: LexOthers.cxx:621
static bool latexIsSpecial(int ch)
Definition: LexOthers.cxx:1186
static bool IsBSeparator(char ch)
Definition: LexOthers.cxx:63
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc)
static bool latexIsTagValid(int &i, int l, Accessor &styler)
Definition: LexOthers.cxx:1203
LexerModule lmTXTADV(SCLEX_TXTADV, LexerTXTADV::LexerFactoryTXTADV, "TXTADV", emptyWordListDesc)
static bool latexIsLetter(int ch)
Definition: LexOthers.cxx:1199
static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler)
Definition: LexOthers.cxx:511
static const char *const NPRCWordLists[]
Definition: LexOthers.cxx:2324
static bool IsWordStart(int ch)
Definition: LexOthers.cxx:1576
static void ColouriseBatchLine(char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, WordList *keywordlists[], Accessor &styler)
Definition: LexOthers.cxx:68
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null")
#define SCE_NSCR_PROCEDURE_COMMANDS
Definition: SciLexer.h:1639
#define SCE_DIFF_POSITION
Definition: SciLexer.h:513
#define SCE_TXTADV_BOLD_ITALIC
Definition: SciLexer.h:1670
#define SCE_ERR_DEFAULT
Definition: SciLexer.h:461
#define SCE_L_COMMAND
Definition: SciLexer.h:428
#define SCE_NPRC_FUNCTION
Definition: SciLexer.h:1647
#define SCE_NSCR_DEFAULT
Definition: SciLexer.h:1615
#define SCE_PO_FUZZY
Definition: SciLexer.h:1360
#define SCE_BAT_IDENTIFIER
Definition: SciLexer.h:489
#define SCE_NSCR_OPERATOR_KEYWORDS
Definition: SciLexer.h:1629
#define SCE_NSCR_COMMENT_LINE
Definition: SciLexer.h:1617
#define SCE_NSCR_OPTION
Definition: SciLexer.h:1620
#define SCE_NPRC_OPERATOR_KEYWORDS
Definition: SciLexer.h:1655
#define SCE_L_MATH
Definition: SciLexer.h:430
#define SCE_BAT_WORD
Definition: SciLexer.h:485
#define SCLEX_DIFF
Definition: SciLexer.h:33
#define SCE_L_ERROR
Definition: SciLexer.h:439
#define SCE_L_TAG
Definition: SciLexer.h:429
#define SCE_BAT_OPERATOR
Definition: SciLexer.h:490
#define SCE_NPRC_COMMENT_BLOCK
Definition: SciLexer.h:1644
#define SCE_TXTADV_URL
Definition: SciLexer.h:1673
#define SCE_NPRC_INCLUDES
Definition: SciLexer.h:1657
#define SCE_ERR_ELF
Definition: SciLexer.h:476
#define SCE_NSCR_CONSTANTS
Definition: SciLexer.h:1623
#define SCLEX_NSCR
Definition: SciLexer.h:123
#define SCE_TXTADV_BOLD
Definition: SciLexer.h:1669
#define SCLEX_NPRC
Definition: SciLexer.h:124
#define SCE_PROPS_DEFAULT
Definition: SciLexer.h:421
#define SCE_MAKE_COMMENT
Definition: SciLexer.h:503
#define SCE_TXTADV_DEFAULT
Definition: SciLexer.h:1666
#define SCE_ERR_BORLAND
Definition: SciLexer.h:466
#define SCE_NPRC_PROCEDURES
Definition: SciLexer.h:1656
#define SCE_TXTADV_MODIFIER
Definition: SciLexer.h:1667
#define SCE_NSCR_PROCEDURES
Definition: SciLexer.h:1630
#define SCE_DIFF_COMMENT
Definition: SciLexer.h:510
#define SCE_ERR_GCC
Definition: SciLexer.h:463
#define SCE_PROPS_ASSIGNMENT
Definition: SciLexer.h:424
#define SCE_DIFF_ADDED
Definition: SciLexer.h:515
#define SCE_PROPS_SECTION
Definition: SciLexer.h:423
#define SCLEX_ERRORLIST
Definition: SciLexer.h:27
#define SCE_NSCR_CLUSTER
Definition: SciLexer.h:1634
#define SCE_D_COMMENTDOCKEYWORDERROR
Definition: SciLexer.h:184
#define SCE_NPRC_COMMAND
Definition: SciLexer.h:1645
#define SCE_NSCR_METHOD
Definition: SciLexer.h:1622
#define SCE_L_DEFAULT
Definition: SciLexer.h:427
#define SCLEX_PROPERTIES
Definition: SciLexer.h:26
#define SCE_DIFF_HEADER
Definition: SciLexer.h:512
#define SCE_TXTADV_HEAD
Definition: SciLexer.h:1674
#define SCE_BAT_COMMENT
Definition: SciLexer.h:484
#define SCE_NSCR_CUSTOM_FUNCTION
Definition: SciLexer.h:1633
#define SCE_NSCR_COMMAND
Definition: SciLexer.h:1619
#define SCE_NPRC_IDENTIFIER
Definition: SciLexer.h:1642
#define SCE_ERR_DIFF_CHANGED
Definition: SciLexer.h:471
#define SCE_ERR_DIFF_MESSAGE
Definition: SciLexer.h:474
#define SCE_NPRC_COMMENT_LINE
Definition: SciLexer.h:1643
#define SCE_MAKE_DEFAULT
Definition: SciLexer.h:502
#define SCE_PO_DEFAULT
Definition: SciLexer.h:1352
#define SCE_ERR_IFORT
Definition: SciLexer.h:478
#define SCE_DIFF_CHANGED
Definition: SciLexer.h:516
#define SCE_NSCR_INCLUDES
Definition: SciLexer.h:1631
#define SCE_L_COMMENT2
Definition: SciLexer.h:434
#define SCE_NPRC_NUMBERS
Definition: SciLexer.h:1658
#define SCE_PO_MSGCTXT
Definition: SciLexer.h:1358
#define SCE_NSCR_OPERATORS
Definition: SciLexer.h:1628
#define SCE_MAKE_OPERATOR
Definition: SciLexer.h:506
#define SCE_NPRC_OPERATORS
Definition: SciLexer.h:1654
#define SCE_MAKE_IDEOL
Definition: SciLexer.h:508
#define SCE_ERR_PHP
Definition: SciLexer.h:475
#define SCE_NSCR_FUNCTION
Definition: SciLexer.h:1621
#define SCE_D_COMMENTDOC
Definition: SciLexer.h:170
#define SCE_NPRC_CUSTOM_FUNCTION
Definition: SciLexer.h:1659
#define SCLEX_NULL
Definition: SciLexer.h:18
#define SCE_TXTADV_UNDERLINE
Definition: SciLexer.h:1671
#define SCE_NPRC_FLAGS
Definition: SciLexer.h:1664
#define SCE_PROPS_COMMENT
Definition: SciLexer.h:422
#define SCE_NPRC_PREDEFS
Definition: SciLexer.h:1650
#define SCE_ERR_MS
Definition: SciLexer.h:464
#define SCE_ERR_DIFF_ADDITION
Definition: SciLexer.h:472
#define SCE_ERR_NET
Definition: SciLexer.h:468
#define SCE_NSCR_DOCCOMMENT_BLOCK
Definition: SciLexer.h:1636
#define SCE_NSCR_DEFAULT_VARS
Definition: SciLexer.h:1627
#define SCE_ERR_PYTHON
Definition: SciLexer.h:462
#define SCE_PO_MSGSTR
Definition: SciLexer.h:1356
#define SCLEX_TXTADV
Definition: SciLexer.h:125
#define SCE_L_TAG2
Definition: SciLexer.h:432
#define SCE_BAT_DEFAULT
Definition: SciLexer.h:483
#define SCE_NSCR_STRING_PARSER
Definition: SciLexer.h:1626
#define SCE_ERR_LUA
Definition: SciLexer.h:469
#define SCE_NPRC_STRING
Definition: SciLexer.h:1651
#define SCE_NSCR_INSTALL
Definition: SciLexer.h:1638
#define SCLEX_LATEX
Definition: SciLexer.h:31
#define SCE_ERR_CTAG
Definition: SciLexer.h:470
#define SCE_L_VERBATIM
Definition: SciLexer.h:435
#define SCE_NSCR_DOCCOMMENT_LINE
Definition: SciLexer.h:1635
#define SCE_D_COMMENT
Definition: SciLexer.h:168
#define SCE_PO_MSGID
Definition: SciLexer.h:1354
#define SCE_NSCR_PREDEFS
Definition: SciLexer.h:1624
#define SCE_TXTADV_BIGHEAD
Definition: SciLexer.h:1675
#define SCE_NPRC_METHOD
Definition: SciLexer.h:1648
#define SCE_NPRC_DOCCOMMENT_BLOCK
Definition: SciLexer.h:1662
#define SCE_NPRC_DEFAULT_VARS
Definition: SciLexer.h:1653
#define SCE_NSCR_IDENTIFIER
Definition: SciLexer.h:1616
#define SCLEX_PO
Definition: SciLexer.h:105
#define SCE_PO_COMMENT
Definition: SciLexer.h:1353
#define SCE_NPRC_CONSTANTS
Definition: SciLexer.h:1649
#define SCE_ERR_JAVA_STACK
Definition: SciLexer.h:481
#define SCE_ERR_IFC
Definition: SciLexer.h:477
#define SCE_MAKE_IDENTIFIER
Definition: SciLexer.h:505
#define SCE_TXTADV_STRIKETHROUGH
Definition: SciLexer.h:1672
#define SCE_NPRC_STRING_PARSER
Definition: SciLexer.h:1652
#define SCE_ERR_TIDY
Definition: SciLexer.h:480
#define SCE_MAKE_TARGET
Definition: SciLexer.h:507
#define SCE_PO_MSGID_TEXT
Definition: SciLexer.h:1355
#define SCE_NSCR_NUMBERS
Definition: SciLexer.h:1632
#define SCE_L_SHORTCMD
Definition: SciLexer.h:436
#define SCE_PROPS_KEY
Definition: SciLexer.h:426
#define SCLEX_BATCH
Definition: SciLexer.h:29
#define SCE_TXTADV_ITALIC
Definition: SciLexer.h:1668
#define SCE_NPRC_DEFAULT
Definition: SciLexer.h:1641
#define SCE_D_COMMENTDOCKEYWORD
Definition: SciLexer.h:183
#define SCE_L_MATH2
Definition: SciLexer.h:433
#define SCE_PROPS_DEFVAL
Definition: SciLexer.h:425
#define SCE_ERR_CMD
Definition: SciLexer.h:465
#define SCE_ERR_ABSF
Definition: SciLexer.h:479
#define SCE_BAT_COMMAND
Definition: SciLexer.h:488
#define SCE_NPRC_CLUSTER
Definition: SciLexer.h:1660
#define SCE_DIFF_COMMAND
Definition: SciLexer.h:511
#define SCE_DIFF_DELETED
Definition: SciLexer.h:514
#define SCE_NPRC_DOCKEYWORD
Definition: SciLexer.h:1663
#define SCE_NPRC_OPTION
Definition: SciLexer.h:1646
#define SCE_BAT_LABEL
Definition: SciLexer.h:486
#define SCE_ERR_VALUE
Definition: SciLexer.h:482
#define SCE_NSCR_DOCKEYWORD
Definition: SciLexer.h:1637
#define SCE_ERR_PERL
Definition: SciLexer.h:467
#define SCE_NPRC_DOCCOMMENT_LINE
Definition: SciLexer.h:1661
#define SCE_MAKE_PREPROCESSOR
Definition: SciLexer.h:504
#define SCE_L_CMDOPT
Definition: SciLexer.h:438
#define SCLEX_MAKEFILE
Definition: SciLexer.h:28
#define SCE_L_SPECIAL
Definition: SciLexer.h:437
#define SCE_NSCR_STRING
Definition: SciLexer.h:1625
#define SCE_ERR_DIFF_DELETION
Definition: SciLexer.h:473
#define SCE_DIFF_DEFAULT
Definition: SciLexer.h:509
#define SCE_NSCR_COMMENT_BLOCK
Definition: SciLexer.h:1618
#define SCE_BAT_HIDE
Definition: SciLexer.h:487
#define SCE_L_COMMENT
Definition: SciLexer.h:431
#define SCE_PO_MSGCTXT_TEXT
Definition: SciLexer.h:1359
#define SCE_PO_MSGSTR_TEXT
Definition: SciLexer.h:1357
virtual ~LexerNPRC()
Definition: LexOthers.cxx:2399
WordList functionWords
Definition: LexOthers.cxx:2373
OptionSetNPRC osNPRC
Definition: LexOthers.cxx:2393
WordList optionWords
Definition: LexOthers.cxx:2372
void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:2767
const char *SCI_METHOD PropertyNames()
Definition: LexOthers.cxx:2407
LexerNPRC(bool caseSensitive_)
Definition: LexOthers.cxx:2395
int SCI_METHOD Version() const
Definition: LexOthers.cxx:2404
static ILexer * LexerFactoryNPRC()
Definition: LexOthers.cxx:2428
WordList constantWords
Definition: LexOthers.cxx:2376
WordList methodWords
Definition: LexOthers.cxx:2374
WordList preDefWords
Definition: LexOthers.cxx:2377
bool caseSensitive
Definition: LexOthers.cxx:2370
WordList defVarWords
Definition: LexOthers.cxx:2375
int SCI_METHOD WordListSet(int n, const char *wl)
Definition: LexOthers.cxx:2443
void SCI_METHOD Release()
Definition: LexOthers.cxx:2401
void *SCI_METHOD PrivateCall(int, void *)
Definition: LexOthers.cxx:2424
static ILexer * LexerFactoryNPRCInsensitive()
Definition: LexOthers.cxx:2431
const char *SCI_METHOD DescribeProperty(const char *name)
Definition: LexOthers.cxx:2413
const char *SCI_METHOD DescribeWordListSets()
Definition: LexOthers.cxx:2417
int SCI_METHOD PropertySet(const char *key, const char *val)
Definition: LexOthers.cxx:2436
WordList operatorWords
Definition: LexOthers.cxx:2378
WordList commandWords
Definition: LexOthers.cxx:2371
WordList blockEndWords
Definition: LexOthers.cxx:2381
int SCI_METHOD PropertyType(const char *name)
Definition: LexOthers.cxx:2410
WordList blockStartWords
Definition: LexOthers.cxx:2380
OptionsNPRC options
Definition: LexOthers.cxx:2392
WordList docKeyWords
Definition: LexOthers.cxx:2379
void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:2495
static ILexer * LexerFactoryNSCR()
Definition: LexOthers.cxx:1754
void *SCI_METHOD PrivateCall(int, void *)
Definition: LexOthers.cxx:1750
static ILexer * LexerFactoryNSCRInsensitive()
Definition: LexOthers.cxx:1757
WordList operatorWords
Definition: LexOthers.cxx:1702
WordList blockStartWords
Definition: LexOthers.cxx:1705
int SCI_METHOD PropertyType(const char *name)
Definition: LexOthers.cxx:1736
OptionSetNSCR osNSCR
Definition: LexOthers.cxx:1719
void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:1824
const char *SCI_METHOD DescribeWordListSets()
Definition: LexOthers.cxx:1743
bool caseSensitive
Definition: LexOthers.cxx:1694
WordList preDefWords
Definition: LexOthers.cxx:1701
int SCI_METHOD PropertySet(const char *key, const char *val)
Definition: LexOthers.cxx:1762
WordList docKeyWords
Definition: LexOthers.cxx:1703
WordList optionWords
Definition: LexOthers.cxx:1696
virtual ~LexerNSCR()
Definition: LexOthers.cxx:1725
WordList constantWords
Definition: LexOthers.cxx:1700
WordList functionWords
Definition: LexOthers.cxx:1697
WordList methodWords
Definition: LexOthers.cxx:1698
WordList defVarWords
Definition: LexOthers.cxx:1699
void SCI_METHOD Release()
Definition: LexOthers.cxx:1727
OptionsNSCR options
Definition: LexOthers.cxx:1718
LexerNSCR(bool caseSensitive_)
Definition: LexOthers.cxx:1721
WordList commandWords
Definition: LexOthers.cxx:1695
int SCI_METHOD Version() const
Definition: LexOthers.cxx:1730
WordList blockEndWords
Definition: LexOthers.cxx:1706
const char *SCI_METHOD DescribeProperty(const char *name)
Definition: LexOthers.cxx:1739
WordList procedureCommandWords
Definition: LexOthers.cxx:1704
void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:2145
const char *SCI_METHOD PropertyNames()
Definition: LexOthers.cxx:1733
int SCI_METHOD WordListSet(int n, const char *wl)
Definition: LexOthers.cxx:1769
const char *SCI_METHOD DescribeWordListSets()
Definition: LexOthers.cxx:2964
void SCI_METHOD Release()
Definition: LexOthers.cxx:2948
void *SCI_METHOD PrivateCall(int, void *)
Definition: LexOthers.cxx:2971
void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:3032
void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
Definition: LexOthers.cxx:2969
int SCI_METHOD PropertySet(const char *key, const char *val)
Definition: LexOthers.cxx:2963
const char *SCI_METHOD PropertyNames()
Definition: LexOthers.cxx:2954
static ILexer * LexerFactoryTXTADV()
Definition: LexOthers.cxx:2975
int SCI_METHOD PropertyType(const char *name)
Definition: LexOthers.cxx:2957
int SCI_METHOD WordListSet(int n, const char *wl)
Definition: LexOthers.cxx:2967
bool caseSensitive
Definition: LexOthers.cxx:2921
const char *SCI_METHOD DescribeProperty(const char *name)
Definition: LexOthers.cxx:2960
int SCI_METHOD Version() const
Definition: LexOthers.cxx:2951
static ILexer * LexerFactoryTXTADVInsensitive()
Definition: LexOthers.cxx:2978
LexerTXTADV(bool caseSensitive_)
Definition: LexOthers.cxx:2943
virtual ~LexerTXTADV()
Definition: LexOthers.cxx:2946
char name[32]
Definition: resampler.cpp:371
bool foldCommentExplicit
Definition: LexOthers.cxx:2304
bool foldExplicitAnywhere
Definition: LexOthers.cxx:2307
bool foldCommentMultiline
Definition: LexOthers.cxx:2303
std::string foldExplicitEnd
Definition: LexOthers.cxx:2306
bool foldCompact
Definition: LexOthers.cxx:2308
bool foldSyntaxBased
Definition: LexOthers.cxx:2301
std::string foldExplicitStart
Definition: LexOthers.cxx:2305
bool foldComment
Definition: LexOthers.cxx:2302
bool foldComment
Definition: LexOthers.cxx:1625
bool foldSyntaxBased
Definition: LexOthers.cxx:1624
std::string foldExplicitEnd
Definition: LexOthers.cxx:1629
bool foldExplicitAnywhere
Definition: LexOthers.cxx:1630
bool foldCompact
Definition: LexOthers.cxx:1631
bool foldCommentMultiline
Definition: LexOthers.cxx:1626
bool foldCommentExplicit
Definition: LexOthers.cxx:1627
std::string foldExplicitStart
Definition: LexOthers.cxx:1628