558
562
static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
559
char lineBuffer[1024];
563
char lineBuffer[DIFF_BUFFER_START_SIZE] = "";
560
564
styler.StartAt(startPos);
561
565
styler.StartSegment(startPos);
562
566
unsigned int linePos = 0;
563
567
for (unsigned int i = startPos; i < startPos + length; i++) {
564
lineBuffer[linePos++] = styler[i];
565
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
566
// End of line (or of line buffer) met, colourise it
567
lineBuffer[linePos] = '\0';
568
if (AtEOL(styler, i)) {
569
if (linePos < DIFF_BUFFER_START_SIZE) {
570
lineBuffer[linePos] = 0;
568
572
ColouriseDiffLine(lineBuffer, i, styler);
574
} else if (linePos < DIFF_BUFFER_START_SIZE - 1) {
575
lineBuffer[linePos++] = styler[i];
576
} else if (linePos == DIFF_BUFFER_START_SIZE - 1) {
577
lineBuffer[linePos++] = 0;
572
580
if (linePos > 0) { // Last line does not have ending characters
581
if (linePos < DIFF_BUFFER_START_SIZE) {
582
lineBuffer[linePos] = 0;
573
584
ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
603
614
} while (static_cast<int>(startPos) + length > curLineStart);
606
static void ColourisePoLine(
608
unsigned int lengthLine,
609
unsigned int startLine,
614
static unsigned int state = SCE_PO_DEFAULT;
615
unsigned int state_start = SCE_PO_DEFAULT;
617
while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
619
if (i < lengthLine) {
620
if (lineBuffer[i] == '#') {
621
// check if the comment contains any flags ("#, ") and
622
// then whether the flags contain "fuzzy"
623
if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy"))
624
styler.ColourTo(endPos, SCE_PO_FUZZY);
626
styler.ColourTo(endPos, SCE_PO_COMMENT);
628
if (lineBuffer[0] == '"') {
629
// line continuation, use previous style
630
styler.ColourTo(endPos, state);
632
// this implicitly also matches "msgid_plural"
633
} else if (strstart(lineBuffer, "msgid")) {
634
state_start = SCE_PO_MSGID;
635
state = SCE_PO_MSGID_TEXT;
636
} else if (strstart(lineBuffer, "msgstr")) {
637
state_start = SCE_PO_MSGSTR;
638
state = SCE_PO_MSGSTR_TEXT;
639
} else if (strstart(lineBuffer, "msgctxt")) {
640
state_start = SCE_PO_MSGCTXT;
641
state = SCE_PO_MSGCTXT_TEXT;
643
if (state_start != SCE_PO_DEFAULT) {
644
// find the next space
645
while ((i < lengthLine) && ! isspacechar(lineBuffer[i]))
647
styler.ColourTo(startLine + i - 1, state_start);
648
styler.ColourTo(startLine + i, SCE_PO_DEFAULT);
649
styler.ColourTo(endPos, state);
653
styler.ColourTo(endPos, SCE_PO_DEFAULT);
657
static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
658
char lineBuffer[1024];
659
styler.StartAt(startPos);
660
styler.StartSegment(startPos);
661
unsigned int linePos = 0;
662
unsigned int startLine = startPos;
663
for (unsigned int i = startPos; i < startPos + length; i++) {
664
lineBuffer[linePos++] = styler[i];
665
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
666
// End of line (or of line buffer) met, colourise it
667
lineBuffer[linePos] = '\0';
668
ColourisePoLine(lineBuffer, linePos, startLine, i, styler);
673
if (linePos > 0) { // Last line does not have ending characters
674
ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
678
617
static inline bool isassignchar(unsigned char ch) {
679
618
return (ch == '=') || (ch == ':');
846
785
while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
849
if (lineBuffer[i] == '#') { // Comment
850
styler.ColourTo(endPos, SCE_MAKE_COMMENT);
853
if (lineBuffer[i] == '!') { // Special directive
854
styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
788
if (i < lengthLine) {
789
if (lineBuffer[i] == '#') { // Comment
790
styler.ColourTo(endPos, SCE_MAKE_COMMENT);
793
if (lineBuffer[i] == '!') { // Special directive
794
styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
857
798
int varCount = 0;
858
799
while (i < lengthLine) {
859
if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
800
if (((i + 1) < lengthLine) && (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(')) {
860
801
styler.ColourTo(startLine + i - 1, state);
861
802
state = SCE_MAKE_IDENTIFIER;
1015
956
bool initialTab = (lineBuffer[0] == '\t');
1016
957
bool initialColonPart = false;
1017
958
enum { stInitial,
1018
stGccStart, stGccDigit, stGcc,
959
stGccStart, stGccDigit, stGccColumn, stGcc,
1019
960
stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
1020
961
stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
1047
988
state = Is1To9(ch) ? stGccDigit : stUnrecognized;
1048
989
} else if (state == stGccDigit) { // <filename>:<line>
1049
990
if (ch == ':') {
1050
state = stGcc; // :9.*: is GCC
991
state = stGccColumn; // :9.*: is GCC
1051
992
startValue = i + 1;
1053
993
} else if (!Is0To9(ch)) {
1054
994
state = stUnrecognized;
996
} else if (state == stGccColumn) { // <filename>:<line>:<column>
1056
1003
} else if (state == stMsStart) { // <filename>(
1057
1004
state = Is0To9(ch) ? stMsDigit : stUnrecognized;
1058
1005
} else if (state == stMsDigit) { // <filename>(<line>
1480
1427
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
1481
1428
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc);
1482
LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc);
1483
1429
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
1484
1430
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
1485
1431
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);