SF.net SVN: geany:[3669] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Mon Mar 30 17:49:40 UTC 2009


Revision: 3669
          http://geany.svn.sourceforge.net/geany/?rev=3669&view=rev
Author:   eht16
Date:     2009-03-30 17:49:40 +0000 (Mon, 30 Mar 2009)

Log Message:
-----------
Backport recent changes from Scintilla CVS to add partial support for RFC2822 styled text using the Properties lexer.
Ignore leading whitespace for config files and RFC2822 text.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/scintilla/LexOthers.cxx
    trunk/src/highlighting.c
    trunk/tagmanager/conf.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-03-29 16:15:35 UTC (rev 3668)
+++ trunk/ChangeLog	2009-03-30 17:49:40 UTC (rev 3669)
@@ -1,3 +1,11 @@
+2009-03-30  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * scintilla/LexOthers.cxx, src/highlighting.c, tagmanager/conf.c:
+   Backport recent changes from Scintilla CVS to add partial support
+   for RFC2822 styled text using the Properties lexer.
+   Ignore leading whitespace for config files and RFC2822 text.
+
+
 2009-03-29  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * doc/geany.html, doc/geany.txt, geany.glade, src/callbacks.c,

Modified: trunk/scintilla/LexOthers.cxx
===================================================================
--- trunk/scintilla/LexOthers.cxx	2009-03-29 16:15:35 UTC (rev 3668)
+++ trunk/scintilla/LexOthers.cxx	2009-03-30 17:49:40 UTC (rev 3669)
@@ -640,33 +640,42 @@
 	}
 }
 
+static inline bool isassignchar(unsigned char ch) {
+	return (ch == '=') || (ch == ':');
+}
 
 static void ColourisePropsLine(
     char *lineBuffer,
     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] == ';' ||
-			(i < (lengthLine - 1) && lineBuffer[i] == '/' && lineBuffer[i+1] == '/')) {
+		if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
 			styler.ColourTo(endPos, SCE_PROPS_COMMENT);
 		} else if (lineBuffer[i] == '[') {
 			styler.ColourTo(endPos, SCE_PROPS_SECTION);
 		} else if (lineBuffer[i] == '@') {
 			styler.ColourTo(startLine + i, SCE_PROPS_DEFVAL);
-			if (lineBuffer[++i] == '=')
+			if (isassignchar(lineBuffer[i++]))
 				styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
 			styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
 		} else {
 			// Search for the '=' character
-			while ((i < lengthLine) && ! (lineBuffer[i] == '=' || isspacechar(lineBuffer[i])))
+			while ((i < lengthLine) && !isassignchar(lineBuffer[i]))
 				i++;
-			if ((i < lengthLine) && (lineBuffer[i] == '=' || isspacechar(lineBuffer[i]))) {
+			if ((i < lengthLine) && isassignchar(lineBuffer[i])) {
 				styler.ColourTo(startLine + i - 1, SCE_PROPS_KEY);
 				styler.ColourTo(startLine + i, SCE_PROPS_ASSIGNMENT);
 				styler.ColourTo(endPos, SCE_PROPS_DEFAULT);
@@ -685,18 +694,20 @@
 	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);
 	}
 }
 

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2009-03-29 16:15:35 UTC (rev 3668)
+++ trunk/src/highlighting.c	2009-03-30 17:49:40 UTC (rev 3669)
@@ -2272,6 +2272,8 @@
 	set_sci_style(sci, SCE_PROPS_KEY, GEANY_FILETYPES_CONF, 3);
 	set_sci_style(sci, SCE_PROPS_ASSIGNMENT, GEANY_FILETYPES_CONF, 4);
 	set_sci_style(sci, SCE_PROPS_DEFVAL, GEANY_FILETYPES_CONF, 5);
+
+	SSM(sci, SCI_SETPROPERTY, (uptr_t) "lexer.props.allow.initial.spaces", (sptr_t) "0");
 }
 
 

Modified: trunk/tagmanager/conf.c
===================================================================
--- trunk/tagmanager/conf.c	2009-03-29 16:15:35 UTC (rev 3668)
+++ trunk/tagmanager/conf.c	2009-03-30 17:49:40 UTC (rev 3669)
@@ -53,9 +53,7 @@
 		const unsigned char* cp = line;
 		boolean possible = TRUE;
 
-		while (isspace ((int) *cp))
-			++cp;
-		if (*cp == '#' || (*cp != '\0' && *cp == '/' && *(cp+1) == '/'))
+		if (isspace ((int) *cp) || *cp == '#' || (*cp != '\0' && *cp == '/' && *(cp+1) == '/'))
 			continue;
 
 		/* look for a section */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list