diff options
| author | nyamatongwe <unknown> | 2000-08-03 12:22:34 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2000-08-03 12:22:34 +0000 | 
| commit | 01ee5832076b4be7fcbbb0bf5bdcc4f1f534698b (patch) | |
| tree | 3ac72616c4d057f33da63afff3fdea4de1daafef /src | |
| parent | 6051be089460dfaff3f18c32cf9ee849c2f0c02b (diff) | |
| download | scintilla-mirror-01ee5832076b4be7fcbbb0bf5bdcc4f1f534698b.tar.gz | |
Fixes from Philippe for preprocessor and HTML comments and one from Steve
for HTML comments.
Diffstat (limited to 'src')
| -rw-r--r-- | src/LexCPP.cxx | 15 | ||||
| -rw-r--r-- | src/LexHTML.cxx | 21 | ||||
| -rw-r--r-- | src/LexVB.cxx | 27 | 
3 files changed, 39 insertions, 24 deletions
| diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index b77468a44..4f70e9bd3 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -56,7 +56,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  	char chPrev = ' ';  	char chNext = styler[startPos];  	unsigned int lengthDoc = startPos + length; -	int visChars = 0; +	int visibleChars = 0;  	styler.StartSegment(startPos);  	bool lastWordWasUUID = false;  	for (unsigned int i = startPos; i < lengthDoc; i++) { @@ -64,6 +64,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  		chNext = styler.SafeGetCharAt(i + 1);  		if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { +			// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) +			// Avoid triggering two times on Dos/Win  			// End of line  			if (state == SCE_C_STRINGEOL) {  				styler.ColourTo(i, state); @@ -71,18 +73,18 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  			}  			if (fold) {  				int lev = levelPrev; -				if (visChars == 0) +				if (visibleChars == 0)  					lev |= SC_FOLDLEVELWHITEFLAG; -				if ((levelCurrent > levelPrev) && (visChars > 0)) +				if ((levelCurrent > levelPrev) && (visibleChars > 0))  					lev |= SC_FOLDLEVELHEADERFLAG;  				styler.SetLevel(lineCurrent, lev);  				lineCurrent++; -				visChars = 0;  				levelPrev = levelCurrent;  			} +			visibleChars = 0;  		}  		if (!isspace(ch)) -			visChars++; +			visibleChars++;  		if (styler.IsLeadByte(ch)) {  			chNext = styler.SafeGetCharAt(i + 2); @@ -115,7 +117,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo  			} else if (ch == '\'') {  				styler.ColourTo(i-1, state);  				state = SCE_C_CHARACTER; -			} else if (ch == '#') { +			} else if (ch == '#' && visibleChars == 1) { +				// Preprocessor commands are alone on their line  				styler.ColourTo(i-1, state);  				state = SCE_C_PREPROCESSOR;  				// Skip whitespace between # and preprocessor word diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index 91a79bed1..15f7ed3cb 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -330,7 +330,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  	bool fold = styler.GetPropertyInt("fold");  	int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;  	int levelCurrent = levelPrev; -	int visChars = 0; +	int visibleChars = 0;  	char chPrev = ' ';  	char ch = ' '; @@ -351,7 +351,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		}  		if (fold && !isspace(ch)) -			visChars++; +			visibleChars++;  		// handle script folding  		if (fold) { @@ -392,15 +392,17 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		StateToPrint = statePrintForState(state, inScriptType);  		if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { +			// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) +			// Avoid triggering two times on Dos/Win  			// New line -> record any line state onto /next/ line  			if (fold) {  				int lev = levelPrev; -				if (visChars == 0) +				if (visibleChars == 0)  					lev |= SC_FOLDLEVELWHITEFLAG; -				if ((levelCurrent > levelPrev) && (visChars > 0)) +				if ((levelCurrent > levelPrev) && (visibleChars > 0))  					lev |= SC_FOLDLEVELHEADERFLAG;  				styler.SetLevel(lineCurrent, lev); -				visChars = 0; +				visibleChars = 0;  				levelPrev = levelCurrent;  			}  			lineCurrent++; @@ -527,7 +529,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		case SCE_H_DEFAULT:  			if (ch == '<') {  				styler.ColourTo(i - 1, StateToPrint); -				state = SCE_H_TAGUNKNOWN; +				if (chNext == '!' && chNext2 == '-' && styler.SafeGetCharAt(i + 3) == '-') +					state = SCE_H_COMMENT; +				else +					state = SCE_H_TAGUNKNOWN;  			} else if (ch == '&') {  				styler.ColourTo(i - 1, SCE_H_DEFAULT);  				state = SCE_H_ENTITY; @@ -573,6 +578,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  				} else {  					if (eClass == SCE_H_COMMENT) {  						state = SCE_H_COMMENT; +						if ((ch == '>') && (chPrev == '-') && (chPrev2 == '-')) { +							styler.ColourTo(i, state); +							state = SCE_H_DEFAULT; +						}  					} else if (eClass == SCE_H_CDATA) {  						state = SCE_H_CDATA;  					} else { diff --git a/src/LexVB.cxx b/src/LexVB.cxx index feb9fe24a..67dfa7842 100644 --- a/src/LexVB.cxx +++ b/src/LexVB.cxx @@ -50,6 +50,7 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,  	styler.StartAt(startPos); +	int visibleChars = 0;  	int state = initStyle;  	char chNext = styler[startPos];  	styler.StartSegment(startPos); @@ -64,6 +65,17 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,  			continue;  		} +		if (ch == '\r' || ch == '\n') { +			// End of line +			if (state == SCE_C_COMMENTLINE || state == SCE_C_PREPROCESSOR) { +				styler.ColourTo(i - 1, state); +				state = SCE_C_DEFAULT; +			} +			visibleChars = 0; +		} +		if (!isspace(ch)) +			visibleChars++; +  		if (state == SCE_C_DEFAULT) {  			if (iswordstart(ch)) {  				styler.ColourTo(i - 1, state); @@ -74,7 +86,8 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,  			} else if (ch == '\"') {  				styler.ColourTo(i - 1, state);  				state = SCE_C_STRING; -			} else if (ch == '#') { +			} else if (ch == '#' && visibleChars == 1) { +				// Preprocessor commands are alone on their line  				styler.ColourTo(i - 1, state);  				state = SCE_C_PREPROCESSOR;  			} else if (ch == '&' && tolower(chNext) == 'h') { @@ -99,12 +112,7 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,  				}  			}  		} else { -			if (state == SCE_C_COMMENTLINE) { -				if (ch == '\r' || ch == '\n') { -					styler.ColourTo(i - 1, state); -					state = SCE_C_DEFAULT; -				} -			} else if (state == SCE_C_STRING) { +			if (state == SCE_C_STRING) {  				// VB doubles quotes to preserve them  				if (ch == '\"') {  					styler.ColourTo(i, state); @@ -113,11 +121,6 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,  					ch = chNext;  					chNext = styler.SafeGetCharAt(i + 1);  				} -			} else if (state == SCE_C_PREPROCESSOR) { -				if (ch == '\r' || ch == '\n') { -					styler.ColourTo(i - 1, state); -					state = SCE_C_DEFAULT; -				}  			}  			if (state == SCE_C_DEFAULT) {    // One of the above succeeded  				if (ch == '\'') { | 
