From a183c0042dacce9c7cc0b339c1f71dea7524f180 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 30 Mar 2009 10:27:48 +0000 Subject: =?UTF-8?q?lexer.props.allow.initial.spaces=20patch=20from=20Enric?= =?UTF-8?q?o=20Tr=C3=B6ger=20allows=20styling=20of=20RFC2822=20text=20with?= =?UTF-8?q?=20the=20props=20lexer.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/LexOthers.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3