diff options
| -rw-r--r-- | include/SciLexer.h | 10 | ||||
| -rw-r--r-- | include/Scintilla.iface | 12 | ||||
| -rw-r--r-- | src/KeyWords.cxx | 1 | ||||
| -rw-r--r-- | src/LexOthers.cxx | 84 | ||||
| -rw-r--r-- | vcbuild/SciLexer.dsp | 4 | 
5 files changed, 106 insertions, 5 deletions
| diff --git a/include/SciLexer.h b/include/SciLexer.h index 05cea61d4..5b35d40cc 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -102,6 +102,7 @@  #define SCLEX_MAGIK 87  #define SCLEX_POWERSHELL 88  #define SCLEX_MYSQL 89 +#define SCLEX_PO 90  #define SCLEX_AUTOMATIC 1000  #define SCE_P_DEFAULT 0  #define SCE_P_COMMENTLINE 1 @@ -1256,6 +1257,15 @@  #define SCE_MYSQL_USER1 18  #define SCE_MYSQL_USER2 19  #define SCE_MYSQL_USER3 20 +#define SCE_PO_DEFAULT 0 +#define SCE_PO_COMMENT 1 +#define SCE_PO_MSGID 2 +#define SCE_PO_MSGID_TEXT 3 +#define SCE_PO_MSGSTR 4 +#define SCE_PO_MSGSTR_TEXT 5 +#define SCE_PO_MSGCTXT 6 +#define SCE_PO_MSGCTXT_TEXT 7 +#define SCE_PO_FUZZY 8  #define SCLEX_ASP 29  #define SCLEX_PHP 30  //--Autogenerated -- end of section automatically generated from Scintilla.iface diff --git a/include/Scintilla.iface b/include/Scintilla.iface index bc2e0a033..e8292d267 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2008,6 +2008,7 @@ val SCLEX_R=86  val SCLEX_MAGIK=87  val SCLEX_POWERSHELL=88  val SCLEX_MYSQL=89 +val SCLEX_PO=90  # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a  # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -3329,6 +3330,17 @@ val SCE_MYSQL_QUOTEDIDENTIFIER=17  val SCE_MYSQL_USER1=18  val SCE_MYSQL_USER2=19  val SCE_MYSQL_USER3=20 +# Lexical state for SCLEX_PO +lex Po=SCLEX_PO SCE_PO_ +val SCE_PO_DEFAULT=0 +val SCE_PO_COMMENT=1 +val SCE_PO_MSGID=2 +val SCE_PO_MSGID_TEXT=3 +val SCE_PO_MSGSTR=4 +val SCE_PO_MSGSTR_TEXT=5 +val SCE_PO_MSGCTXT=6 +val SCE_PO_MSGCTXT_TEXT=7 +val SCE_PO_FUZZY=8  # Events diff --git a/src/KeyWords.cxx b/src/KeyWords.cxx index d98c43ffa..b38e515a0 100644 --- a/src/KeyWords.cxx +++ b/src/KeyWords.cxx @@ -205,6 +205,7 @@ int Scintilla_LinkLexers() {  	LINK_LEXER(lmPHP);  	LINK_LEXER(lmPHPSCRIPT);  	LINK_LEXER(lmPLM); +	LINK_LEXER(lmPo);  	LINK_LEXER(lmPOV);  	LINK_LEXER(lmPowerShell);  	LINK_LEXER(lmProgress); diff --git a/src/LexOthers.cxx b/src/LexOthers.cxx index d3b58a635..24eee96a3 100644 --- a/src/LexOthers.cxx +++ b/src/LexOthers.cxx @@ -24,6 +24,10 @@  using namespace Scintilla;  #endif +static bool strstart(const char *haystack, const char *needle) { +	return strncmp(haystack, needle, strlen(needle)) == 0; +} +  static bool Is0To9(char ch) {  	return (ch >= '0') && (ch <= '9');  } @@ -564,6 +568,79 @@ static void FoldDiffDoc(unsigned int startPos, int length, int, WordList *[], Ac  	} while (static_cast<int>(startPos) + length > curLineStart);  } +static void ColourisePoLine( +    char *lineBuffer, +    unsigned int lengthLine, +    unsigned int startLine, +    unsigned int endPos, +    Accessor &styler) { + +	unsigned int i = 0; +	static unsigned int state = SCE_PO_DEFAULT; +	unsigned int state_start = SCE_PO_DEFAULT; + +	while ((i < lengthLine) && isspacechar(lineBuffer[i]))	// Skip initial spaces +		i++; +	if (i < lengthLine) { +		if (lineBuffer[i] == '#') { +			// check if the comment contains any flags ("#, ") and +			// then whether the flags contain "fuzzy" +			if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy")) +				styler.ColourTo(endPos, SCE_PO_FUZZY); +			else +				styler.ColourTo(endPos, SCE_PO_COMMENT); +		} else { +			if (lineBuffer[0] == '"') { +				// line continuation, use previous style +				styler.ColourTo(endPos, state); +				return; +			// this implicitly also matches "msgid_plural" +			} else if (strstart(lineBuffer, "msgid")) { +				state_start = SCE_PO_MSGID; +				state = SCE_PO_MSGID_TEXT; +			} else if (strstart(lineBuffer, "msgstr")) { +				state_start = SCE_PO_MSGSTR; +				state = SCE_PO_MSGSTR_TEXT; +			} else if (strstart(lineBuffer, "msgctxt")) { +				state_start = SCE_PO_MSGCTXT; +				state = SCE_PO_MSGCTXT_TEXT; +			} +			if (state_start != SCE_PO_DEFAULT) { +				// find the next space +				while ((i < lengthLine) && ! isspacechar(lineBuffer[i])) +					i++; +				styler.ColourTo(startLine + i - 1, state_start); +				styler.ColourTo(startLine + i, SCE_PO_DEFAULT); +				styler.ColourTo(endPos, state); +			} +		} +	} else { +		styler.ColourTo(endPos, SCE_PO_DEFAULT); +	} +} + +static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { +	char lineBuffer[1024]; +	styler.StartAt(startPos); +	styler.StartSegment(startPos); +	unsigned int linePos = 0; +	unsigned int startLine = startPos; +	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'; +			ColourisePoLine(lineBuffer, linePos, startLine, i, styler); +			linePos = 0; +			startLine = i + 1; +		} +	} +	if (linePos > 0) {	// Last line does not have ending characters +		ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler); +	} +} + +  static void ColourisePropsLine(      char *lineBuffer,      unsigned int lengthLine, @@ -795,10 +872,6 @@ static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[  	}  } -static bool strstart(const char *haystack, const char *needle) { -	return strncmp(haystack, needle, strlen(needle)) == 0; -} -  static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine, int &startValue) {  	if (lineBuffer[0] == '>') {  		// Command or return status @@ -902,7 +975,7 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin  					if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) {  						// This check is not completely accurate as may be on  						// GTK+ with a file name that includes ':'. -						state = stGccStart;						 +						state = stGccStart;  					} else if (chNext == ' ') { // indicates a Lua 5.1 error message  						initialColonPart = true;  					} @@ -1150,6 +1223,7 @@ static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[  LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);  LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc); +LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc);  LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);  LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);  LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc); diff --git a/vcbuild/SciLexer.dsp b/vcbuild/SciLexer.dsp index 7a21c18f2..13f88b5eb 100644 --- a/vcbuild/SciLexer.dsp +++ b/vcbuild/SciLexer.dsp @@ -314,6 +314,10 @@ SOURCE=..\src\LexMSSQL.cxx  # End Source File  # Begin Source File +SOURCE=..\src\LexMySQL.cxx +# End Source File +# Begin Source File +  SOURCE=..\src\LexNsis.cxx  # End Source File  # Begin Source File | 
