PageRenderTime 67ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 1ms

/notepad++/scintilla/src/LexOthers.cxx

http://creativity86.googlecode.com/
C++ | 573 lines | 334 code | 24 blank | 215 comment | 173 complexity | 88fa3fbdb2293fdb1735b753940a10bf MD5 | raw file
Possible License(s): AGPL-1.0
  1. // Scintilla source code edit control
  2. /** @file LexOthers.cxx
  3. ** Lexers for batch files, diff results, properties files, make files and error lists.
  4. ** Also lexer for LaTeX documents.
  5. **/
  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. #include <stdlib.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include <stdio.h>
  12. #include <stdarg.h>
  13. #include "Platform.h"
  14. #include "PropSet.h"
  15. #include "Accessor.h"
  16. #include "KeyWords.h"
  17. #include "Scintilla.h"
  18. #include "SciLexer.h"
  19. static inline bool AtEOL(Accessor &styler, unsigned int i) {
  20. return (styler[i] == '\n') ||
  21. ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
  22. }
  23. static void ColouriseBatchLine(
  24. char *lineBuffer,
  25. unsigned int lengthLine,
  26. unsigned int startLine,
  27. unsigned int endPos,
  28. WordList &keywords,
  29. Accessor &styler) {
  30. unsigned int i = 0;
  31. unsigned int state = SCE_BAT_DEFAULT;
  32. while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip initial spaces
  33. i++;
  34. }
  35. if (lineBuffer[i] == '@') { // Hide command (ECHO OFF)
  36. styler.ColourTo(startLine + i, SCE_BAT_HIDE);
  37. i++;
  38. while ((i < lengthLine) && isspacechar(lineBuffer[i])) { // Skip next spaces
  39. i++;
  40. }
  41. }
  42. if (lineBuffer[i] == ':') {
  43. // Label
  44. if (lineBuffer[i + 1] == ':') {
  45. // :: is a fake label, similar to REM, see http://content.techweb.com/winmag/columns/explorer/2000/21.htm
  46. styler.ColourTo(endPos, SCE_BAT_COMMENT);
  47. } else { // Real label
  48. styler.ColourTo(endPos, SCE_BAT_LABEL);
  49. }
  50. } else {
  51. // Check if initial word is a keyword
  52. char wordBuffer[21];
  53. unsigned int wbl = 0, offset = i;
  54. // Copy word in buffer
  55. for (; offset < lengthLine && wbl < 20 &&
  56. !isspacechar(lineBuffer[offset]); wbl++, offset++) {
  57. wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
  58. }
  59. wordBuffer[wbl] = '\0';
  60. // Check if it is a comment
  61. if (CompareCaseInsensitive(wordBuffer, "rem") == 0) {
  62. styler.ColourTo(endPos, SCE_BAT_COMMENT);
  63. return ;
  64. }
  65. // Check if it is in the list
  66. if (keywords.InList(wordBuffer)) {
  67. styler.ColourTo(startLine + offset - 1, SCE_BAT_WORD); // Regular keyword
  68. } else {
  69. // Search end of word (can be a long path)
  70. while (offset < lengthLine &&
  71. !isspacechar(lineBuffer[offset])) {
  72. offset++;
  73. }
  74. styler.ColourTo(startLine + offset - 1, SCE_BAT_COMMAND); // External command / program
  75. }
  76. // Remainder of the line: colourise the variables.
  77. while (offset < lengthLine) {
  78. if (state == SCE_BAT_DEFAULT && lineBuffer[offset] == '%') {
  79. styler.ColourTo(startLine + offset - 1, state);
  80. if (isdigit(lineBuffer[offset + 1])) {
  81. styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
  82. offset += 2;
  83. } else if (lineBuffer[offset + 1] == '%' &&
  84. !isspacechar(lineBuffer[offset + 2])) {
  85. // Should be safe, as there is CRLF at the end of the line...
  86. styler.ColourTo(startLine + offset + 2, SCE_BAT_IDENTIFIER);
  87. offset += 3;
  88. } else {
  89. state = SCE_BAT_IDENTIFIER;
  90. }
  91. } else if (state == SCE_BAT_IDENTIFIER && lineBuffer[offset] == '%') {
  92. styler.ColourTo(startLine + offset, state);
  93. state = SCE_BAT_DEFAULT;
  94. } else if (state == SCE_BAT_DEFAULT &&
  95. (lineBuffer[offset] == '*' ||
  96. lineBuffer[offset] == '?' ||
  97. lineBuffer[offset] == '=' ||
  98. lineBuffer[offset] == '<' ||
  99. lineBuffer[offset] == '>' ||
  100. lineBuffer[offset] == '|')) {
  101. styler.ColourTo(startLine + offset - 1, state);
  102. styler.ColourTo(startLine + offset, SCE_BAT_OPERATOR);
  103. }
  104. offset++;
  105. }
  106. // if (endPos > startLine + offset - 1) {
  107. styler.ColourTo(endPos, SCE_BAT_DEFAULT); // Remainder of line, currently not lexed
  108. // }
  109. }
  110. }
  111. // ToDo: (not necessarily at beginning of line) GOTO, [IF] NOT, ERRORLEVEL
  112. // IF [NO] (test) (command) -- test is EXIST (filename) | (string1)==(string2) | ERRORLEVEL (number)
  113. // FOR %%(variable) IN (set) DO (command) -- variable is [a-zA-Z] -- eg for %%X in (*.txt) do type %%X
  114. // ToDo: %n (parameters), %EnvironmentVariable% colourising
  115. // ToDo: Colourise = > >> < | "
  116. static void ColouriseBatchDoc(
  117. unsigned int startPos,
  118. int length,
  119. int /*initStyle*/,
  120. WordList *keywordlists[],
  121. Accessor &styler) {
  122. char lineBuffer[1024];
  123. WordList &keywords = *keywordlists[0];
  124. styler.StartAt(startPos);
  125. styler.StartSegment(startPos);
  126. unsigned int linePos = 0;
  127. unsigned int startLine = startPos;
  128. for (unsigned int i = startPos; i < startPos + length; i++) {
  129. lineBuffer[linePos++] = styler[i];
  130. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  131. // End of line (or of line buffer) met, colourise it
  132. lineBuffer[linePos] = '\0';
  133. ColouriseBatchLine(lineBuffer, linePos, startLine, i, keywords, styler);
  134. linePos = 0;
  135. startLine = i + 1;
  136. }
  137. }
  138. if (linePos > 0) { // Last line does not have ending characters
  139. ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
  140. keywords, styler);
  141. }
  142. }
  143. static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
  144. // It is needed to remember the current state to recognize starting
  145. // comment lines before the first "diff " or "--- ". If a real
  146. // difference starts then each line starting with ' ' is a whitespace
  147. // otherwise it is considered a comment (Only in..., Binary file...)
  148. if (0 == strncmp(lineBuffer, "diff ", 3)) {
  149. styler.ColourTo(endLine, SCE_DIFF_COMMAND);
  150. } else if (0 == strncmp(lineBuffer, "--- ", 3)) {
  151. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  152. } else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
  153. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  154. } else if (0 == strncmp(lineBuffer, "====", 4)) { // For p4's diff
  155. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  156. } else if (0 == strncmp(lineBuffer, "***", 3)) {
  157. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  158. } else if (0 == strncmp(lineBuffer, "? ", 2)) { // For difflib
  159. styler.ColourTo(endLine, SCE_DIFF_HEADER);
  160. } else if (lineBuffer[0] == '@') {
  161. styler.ColourTo(endLine, SCE_DIFF_POSITION);
  162. } else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
  163. styler.ColourTo(endLine, SCE_DIFF_DELETED);
  164. } else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
  165. styler.ColourTo(endLine, SCE_DIFF_ADDED);
  166. } else if (lineBuffer[0] != ' ') {
  167. styler.ColourTo(endLine, SCE_DIFF_COMMENT);
  168. } else {
  169. styler.ColourTo(endLine, SCE_DIFF_DEFAULT);
  170. }
  171. }
  172. static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  173. char lineBuffer[1024];
  174. styler.StartAt(startPos);
  175. styler.StartSegment(startPos);
  176. unsigned int linePos = 0;
  177. for (unsigned int i = startPos; i < startPos + length; i++) {
  178. lineBuffer[linePos++] = styler[i];
  179. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  180. // End of line (or of line buffer) met, colourise it
  181. lineBuffer[linePos] = '\0';
  182. ColouriseDiffLine(lineBuffer, i, styler);
  183. linePos = 0;
  184. }
  185. }
  186. if (linePos > 0) { // Last line does not have ending characters
  187. ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
  188. }
  189. }
  190. /*
  191. static void ColourisePropsLine(
  192. char *lineBuffer,
  193. unsigned int lengthLine,
  194. unsigned int startLine,
  195. unsigned int endPos,
  196. Accessor &styler) {
  197. unsigned int i = 0;
  198. while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
  199. i++;
  200. if (i < lengthLine) {
  201. if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
  202. styler.ColourTo(endPos, SCE_PROPS_COMMENT);
  203. } else if (lineBuffer[i] == '[') {
  204. styler.ColourTo(endPos, SCE_PROPS_SECTION);
  205. } else if (lineBuffer[i] == '@') {
  206. styler.ColourTo(startLine + i, SCE_PROPS_DEFVAL);
  207. if (lineBuffer[++i] == '=')
  208. styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
  209. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  210. } else {
  211. // Search for the '=' character
  212. while ((i < lengthLine) && (lineBuffer[i] != '='))
  213. i++;
  214. if ((i < lengthLine) && (lineBuffer[i] == '=')) {
  215. styler.ColourTo(startLine + i - 1, SCE_PROPS_DEFAULT);
  216. styler.ColourTo(startLine + i, 3);
  217. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  218. } else {
  219. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  220. }
  221. }
  222. } else {
  223. styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
  224. }
  225. }
  226. static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  227. char lineBuffer[1024];
  228. styler.StartAt(startPos);
  229. styler.StartSegment(startPos);
  230. unsigned int linePos = 0;
  231. unsigned int startLine = startPos;
  232. for (unsigned int i = startPos; i < startPos + length; i++) {
  233. lineBuffer[linePos++] = styler[i];
  234. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  235. // End of line (or of line buffer) met, colourise it
  236. lineBuffer[linePos] = '\0';
  237. ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
  238. linePos = 0;
  239. startLine = i + 1;
  240. }
  241. }
  242. if (linePos > 0) { // Last line does not have ending characters
  243. ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
  244. }
  245. }
  246. */
  247. static void ColouriseMakeLine(
  248. char *lineBuffer,
  249. unsigned int lengthLine,
  250. unsigned int startLine,
  251. unsigned int endPos,
  252. Accessor &styler) {
  253. unsigned int i = 0;
  254. int lastNonSpace = -1;
  255. unsigned int state = SCE_MAKE_DEFAULT;
  256. bool bSpecial = false;
  257. // Skip initial spaces
  258. while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
  259. i++;
  260. }
  261. if (lineBuffer[i] == '#') { // Comment
  262. styler.ColourTo(endPos, SCE_MAKE_COMMENT);
  263. return;
  264. }
  265. if (lineBuffer[i] == '!') { // Special directive
  266. styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
  267. return;
  268. }
  269. while (i < lengthLine) {
  270. if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
  271. styler.ColourTo(startLine + i - 1, state);
  272. state = SCE_MAKE_IDENTIFIER;
  273. } else if (state == SCE_MAKE_IDENTIFIER && lineBuffer[i] == ')') {
  274. styler.ColourTo(startLine + i, state);
  275. state = SCE_MAKE_DEFAULT;
  276. }
  277. if (!bSpecial) {
  278. if (lineBuffer[i] == ':') {
  279. // We should check that no colouring was made since the beginning of the line,
  280. // to avoid colouring stuff like /OUT:file
  281. if (lastNonSpace >= 0)
  282. styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
  283. styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
  284. styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
  285. bSpecial = true; // Only react to the first ':' of the line
  286. state = SCE_MAKE_DEFAULT;
  287. } else if (lineBuffer[i] == '=') {
  288. if (lastNonSpace >= 0)
  289. styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
  290. styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
  291. styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
  292. bSpecial = true; // Only react to the first '=' of the line
  293. state = SCE_MAKE_DEFAULT;
  294. }
  295. }
  296. if (!isspacechar(lineBuffer[i])) {
  297. lastNonSpace = i;
  298. }
  299. i++;
  300. }
  301. if (state == SCE_MAKE_IDENTIFIER) {
  302. styler.ColourTo(endPos, SCE_MAKE_IDEOL); // Error, variable reference not ended
  303. } else {
  304. styler.ColourTo(endPos, SCE_MAKE_DEFAULT);
  305. }
  306. }
  307. static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  308. char lineBuffer[1024];
  309. styler.StartAt(startPos);
  310. styler.StartSegment(startPos);
  311. unsigned int linePos = 0;
  312. unsigned int startLine = startPos;
  313. for (unsigned int i = startPos; i < startPos + length; i++) {
  314. lineBuffer[linePos++] = styler[i];
  315. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  316. // End of line (or of line buffer) met, colourise it
  317. lineBuffer[linePos] = '\0';
  318. ColouriseMakeLine(lineBuffer, linePos, startLine, i, styler);
  319. linePos = 0;
  320. startLine = i + 1;
  321. }
  322. }
  323. if (linePos > 0) { // Last line does not have ending characters
  324. ColouriseMakeLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
  325. }
  326. }
  327. /*
  328. static void ColouriseErrorListLine(
  329. char *lineBuffer,
  330. unsigned int lengthLine,
  331. // unsigned int startLine,
  332. unsigned int endPos,
  333. Accessor &styler) {
  334. if (lineBuffer[0] == '>') {
  335. // Command or return status
  336. styler.ColourTo(endPos, SCE_ERR_CMD);
  337. } else if (lineBuffer[0] == '<') {
  338. // Diff removal, but not interested. Trapped to avoid hitting CTAG cases.
  339. styler.ColourTo(endPos, SCE_ERR_DEFAULT);
  340. } else if (lineBuffer[0] == '!') {
  341. styler.ColourTo(endPos, SCE_ERR_DIFF_CHANGED);
  342. } else if (lineBuffer[0] == '+') {
  343. styler.ColourTo(endPos, SCE_ERR_DIFF_ADDITION);
  344. } else if (lineBuffer[0] == '-' && lineBuffer[1] == '-' && lineBuffer[2] == '-') {
  345. styler.ColourTo(endPos, SCE_ERR_DIFF_MESSAGE);
  346. } else if (lineBuffer[0] == '-') {
  347. styler.ColourTo(endPos, SCE_ERR_DIFF_DELETION);
  348. } else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
  349. styler.ColourTo(endPos, SCE_ERR_PYTHON);
  350. } else if (strstr(lineBuffer, " in ") && strstr(lineBuffer, " on line ")) {
  351. styler.ColourTo(endPos, SCE_ERR_PHP);
  352. } else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
  353. // Borland error message
  354. styler.ColourTo(endPos, SCE_ERR_BORLAND);
  355. } else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
  356. // Borland warning message
  357. styler.ColourTo(endPos, SCE_ERR_BORLAND);
  358. } else if (strstr(lineBuffer, "at line " ) &&
  359. (strstr(lineBuffer, "at line " ) < (lineBuffer + lengthLine)) &&
  360. strstr(lineBuffer, "file ") &&
  361. (strstr(lineBuffer, "file ") < (lineBuffer + lengthLine))) {
  362. // Lua error message
  363. styler.ColourTo(endPos, SCE_ERR_LUA);
  364. } else if (strstr(lineBuffer, " at " ) &&
  365. (strstr(lineBuffer, " at " ) < (lineBuffer + lengthLine)) &&
  366. strstr(lineBuffer, " line ") &&
  367. (strstr(lineBuffer, " line ") < (lineBuffer + lengthLine))) {
  368. // perl error message
  369. styler.ColourTo(endPos, SCE_ERR_PERL);
  370. } else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
  371. strstr(lineBuffer, ":line ")) {
  372. // A .NET traceback
  373. styler.ColourTo(endPos, SCE_ERR_NET);
  374. } else {
  375. // Look for <filename>:<line>:message
  376. // Look for <filename>(line)message
  377. // Look for <filename>(line,pos)message
  378. int state = 0;
  379. for (unsigned int i = 0; i < lengthLine; i++) {
  380. if ((state == 0) && (lineBuffer[i] == ':') && isdigit(lineBuffer[i + 1])) {
  381. state = 1;
  382. } else if ((state == 0) && (lineBuffer[i] == '(')) {
  383. state = 10;
  384. } else if ((state == 0) && (lineBuffer[i] == '\t')) {
  385. state = 20;
  386. } else if ((state == 1) && isdigit(lineBuffer[i])) {
  387. state = 2;
  388. } else if ((state == 2) && (lineBuffer[i] == ':')) {
  389. state = 3;
  390. break;
  391. } else if ((state == 2) && !isdigit(lineBuffer[i])) {
  392. state = 99;
  393. } else if ((state == 10) && isdigit(lineBuffer[i])) {
  394. state = 11;
  395. } else if ((state == 11) && (lineBuffer[i] == ',')) {
  396. state = 14;
  397. } else if ((state == 11) && (lineBuffer[i] == ')')) {
  398. state = 12;
  399. } else if ((state == 12) && (lineBuffer[i] == ':')) {
  400. state = 13;
  401. } else if ((state == 14) && (lineBuffer[i] == ')')) {
  402. state = 15;
  403. break;
  404. } else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
  405. state = 99;
  406. } else if ((state == 20) && (lineBuffer[i-1] == '\t') &&
  407. ((lineBuffer[i] == '/' && lineBuffer[i+1] == '^') || isdigit(lineBuffer[i]))) {
  408. state = 24;
  409. break;
  410. } else if ((state == 20) && ((lineBuffer[i] == '/') && (lineBuffer[i+1] == '^'))) {
  411. state = 21;
  412. } else if ((state == 21) && ((lineBuffer[i] == '$') && (lineBuffer[i+1] == '/'))) {
  413. state = 22;
  414. break;
  415. }
  416. }
  417. if (state == 3) {
  418. styler.ColourTo(endPos, SCE_ERR_GCC);
  419. } else if ((state == 13) || (state == 14) || (state == 15)) {
  420. styler.ColourTo(endPos, SCE_ERR_MS);
  421. } else if (((state == 22) || (state == 24)) && (lineBuffer[0] != '\t')) {
  422. styler.ColourTo(endPos, SCE_ERR_CTAG);
  423. } else {
  424. styler.ColourTo(endPos, SCE_ERR_DEFAULT);
  425. }
  426. }
  427. }
  428. static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
  429. char lineBuffer[1024];
  430. styler.StartAt(startPos);
  431. styler.StartSegment(startPos);
  432. unsigned int linePos = 0;
  433. for (unsigned int i = startPos; i < startPos + length; i++) {
  434. lineBuffer[linePos++] = styler[i];
  435. if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
  436. // End of line (or of line buffer) met, colourise it
  437. lineBuffer[linePos] = '\0';
  438. ColouriseErrorListLine(lineBuffer, linePos, i, styler);
  439. linePos = 0;
  440. }
  441. }
  442. if (linePos > 0) { // Last line does not have ending characters
  443. ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
  444. }
  445. }
  446. */
  447. static int isSpecial(char s) {
  448. return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
  449. (s == '\"') || (s == '`') || (s == '^') || (s == '~');
  450. }
  451. static int isTag(int start, Accessor &styler) {
  452. char s[6];
  453. unsigned int i = 0, e = 1;
  454. while (i < 5 && e) {
  455. s[i] = styler[start + i];
  456. i++;
  457. e = styler[start + i] != '{';
  458. }
  459. s[i] = '\0';
  460. return (strcmp(s, "begin") == 0) || (strcmp(s, "end") == 0);
  461. }
  462. static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
  463. WordList *[], Accessor &styler) {
  464. styler.StartAt(startPos);
  465. int state = initStyle;
  466. char chNext = styler[startPos];
  467. styler.StartSegment(startPos);
  468. int lengthDoc = startPos + length;
  469. for (int i = startPos; i < lengthDoc; i++) {
  470. char ch = chNext;
  471. chNext = styler.SafeGetCharAt(i + 1);
  472. if (styler.IsLeadByte(ch)) {
  473. chNext = styler.SafeGetCharAt(i + 2);
  474. i++;
  475. continue;
  476. }
  477. switch (state) {
  478. case SCE_L_DEFAULT :
  479. switch (ch) {
  480. case '\\' :
  481. styler.ColourTo(i - 1, state);
  482. if (isSpecial(styler[i + 1])) {
  483. styler.ColourTo(i + 1, SCE_L_COMMAND);
  484. i++;
  485. chNext = styler.SafeGetCharAt(i + 1);
  486. } else {
  487. if (isTag(i + 1, styler))
  488. state = SCE_L_TAG;
  489. else
  490. state = SCE_L_COMMAND;
  491. }
  492. break;
  493. case '$' :
  494. styler.ColourTo(i - 1, state);
  495. state = SCE_L_MATH;
  496. if (chNext == '$') {
  497. i++;
  498. chNext = styler.SafeGetCharAt(i + 1);
  499. }
  500. break;
  501. case '%' :
  502. styler.ColourTo(i - 1, state);
  503. state = SCE_L_COMMENT;
  504. break;
  505. }
  506. break;
  507. case SCE_L_COMMAND :
  508. if (chNext == '[' || chNext == '{' || chNext == '}' ||
  509. chNext == ' ' || chNext == '\r' || chNext == '\n') {
  510. styler.ColourTo(i, state);
  511. state = SCE_L_DEFAULT;
  512. i++;
  513. chNext = styler.SafeGetCharAt(i + 1);
  514. }
  515. break;
  516. case SCE_L_TAG :
  517. if (ch == '}') {
  518. styler.ColourTo(i, state);
  519. state = SCE_L_DEFAULT;
  520. }
  521. break;
  522. case SCE_L_MATH :
  523. if (ch == '$') {
  524. if (chNext == '$') {
  525. i++;
  526. chNext = styler.SafeGetCharAt(i + 1);
  527. }
  528. styler.ColourTo(i, state);
  529. state = SCE_L_DEFAULT;
  530. }
  531. break;
  532. case SCE_L_COMMENT :
  533. if (ch == '\r' || ch == '\n') {
  534. styler.ColourTo(i - 1, state);
  535. state = SCE_L_DEFAULT;
  536. }
  537. }
  538. }
  539. styler.ColourTo(lengthDoc, state);
  540. }
  541. LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch");
  542. LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff");
  543. //LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props");
  544. LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile");
  545. //LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist");
  546. LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex");