aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authornyamatongwe <unknown>2009-03-30 10:27:48 +0000
committernyamatongwe <unknown>2009-03-30 10:27:48 +0000
commita183c0042dacce9c7cc0b339c1f71dea7524f180 (patch)
tree3bebd513c7e262929b0f559de2cf531269aa2492 /src
parenta1e8681acf85f3ed93cbc53ee74a290e3e4a5fc8 (diff)
downloadscintilla-mirror-a183c0042dacce9c7cc0b339c1f71dea7524f180.tar.gz
lexer.props.allow.initial.spaces patch from Enrico Tröger allows styling
of RFC2822 text with the props lexer.
Diffstat (limited to 'src')
-rw-r--r--src/LexOthers.cxx19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/LexOthers.cxx b/src/LexOthers.cxx
index 6f500a06e..f5382bfdc 100644
--- a/src/LexOthers.cxx
+++ b/src/LexOthers.cxx
@@ -649,11 +649,18 @@ static void ColourisePropsLine(
unsigned int lengthLine,
unsigned int startLine,
unsigned int endPos,
- Accessor &styler) {
+ Accessor &styler,
+ bool allowInitialSpaces) {
unsigned int i = 0;
- while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
- i++;
+ if (allowInitialSpaces) {
+ while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
+ i++;
+ } else {
+ if (isspacechar(lineBuffer[i])) // don't allow initial spaces
+ i = lengthLine;
+ }
+
if (i < lengthLine) {
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
styler.ColourTo(endPos, SCE_PROPS_COMMENT);
@@ -687,18 +694,20 @@ static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *
styler.StartSegment(startPos);
unsigned int linePos = 0;
unsigned int startLine = startPos;
+ bool allowInitialSpaces = styler.GetPropertyInt("lexer.props.allow.initial.spaces", 1) != 0;
+
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
- ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
+ ColourisePropsLine(lineBuffer, linePos, startLine, i, styler, allowInitialSpaces);
linePos = 0;
startLine = i + 1;
}
}
if (linePos > 0) { // Last line does not have ending characters
- ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
+ ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length - 1, styler, allowInitialSpaces);
}
}