aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/LexOthers.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2000-08-18 10:45:24 +0000
committernyamatongwe <unknown>2000-08-18 10:45:24 +0000
commit74537dd24ba7943e79652b06f4b752be2035bcea (patch)
treec5d0492dca4b04bf79e1ef367a7190df8472bc3f /src/LexOthers.cxx
parentd15b65e7fba53354b9a044ba5d8232d256b58d5e (diff)
downloadscintilla-mirror-74537dd24ba7943e79652b06f4b752be2035bcea.tar.gz
Added in most of Ferdinand Prantl's changes except for regular expression
search. Some bits not quite done as well.
Diffstat (limited to 'src/LexOthers.cxx')
-rw-r--r--src/LexOthers.cxx45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/LexOthers.cxx b/src/LexOthers.cxx
index 90f41e3bf..edbf5d06f 100644
--- a/src/LexOthers.cxx
+++ b/src/LexOthers.cxx
@@ -49,6 +49,46 @@ static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *
ColouriseBatchLine(lineBuffer, startPos + length, styler);
}
+static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
+ // It is needed to remember the current state to recognize starting
+ // comment lines before the first "diff " or "--- ". If a real
+ // difference starts then each line starting with ' ' is a whitespace
+ // otherwise it is considered a comment (Only in..., Binary file...)
+ if (0 == strncmp(lineBuffer, "diff ", 3)) {
+ styler.ColourTo(endLine, 2);
+ } else if (0 == strncmp(lineBuffer, "--- ", 3)) {
+ styler.ColourTo(endLine, 3);
+ } else if (0 == strncmp(lineBuffer, "+++ ", 3)) {
+ styler.ColourTo(endLine, 3);
+ } else if (lineBuffer[0] == '@') {
+ styler.ColourTo(endLine, 4);
+ } else if (lineBuffer[0] == '-') {
+ styler.ColourTo(endLine, 5);
+ } else if (lineBuffer[0] == '+') {
+ styler.ColourTo(endLine, 6);
+ } else if (lineBuffer[0] != ' ') {
+ styler.ColourTo(endLine, 1);
+ } else {
+ styler.ColourTo(endLine, 0);
+ }
+}
+
+static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
+ char lineBuffer[1024];
+ styler.StartAt(startPos);
+ styler.StartSegment(startPos);
+ unsigned int linePos = 0;
+ for (unsigned int i = startPos; i < startPos + length; i++) {
+ lineBuffer[linePos++] = styler[i];
+ if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
+ ColouriseDiffLine(lineBuffer, i, styler);
+ linePos = 0;
+ }
+ }
+ if (linePos > 0)
+ ColouriseDiffLine(lineBuffer, startPos + length, styler);
+}
+
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, Accessor &styler) {
int i = 0;
while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
@@ -297,8 +337,9 @@ static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
styler.ColourTo(lengthDoc, state);
}
+LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);
+LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc);
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
-LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
-LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);
+LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc);