diff options
| author | nyamatongwe <devnull@localhost> | 2007-05-07 00:30:27 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2007-05-07 00:30:27 +0000 | 
| commit | b3530f6e2a16c0f8e7c9ab8632f84208706209ea (patch) | |
| tree | a54087d9ac5b0c0f0cb0fe64c813b47ba9142515 /src | |
| parent | 1e693d4d9ecc2b703432fbd298f6a4d854f179f2 (diff) | |
| download | scintilla-mirror-b3530f6e2a16c0f8e7c9ab8632f84208706209ea.tar.gz | |
Fix for bug #1709848 by Ariden01 allows folding of all tags in
XML and only terminates script mode with script end tag rather
than any tag in XML.
Diffstat (limited to 'src')
| -rw-r--r-- | src/LexHTML.cxx | 31 | 
1 files changed, 22 insertions, 9 deletions
| diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index fe9516357..a816ea188 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -223,7 +223,7 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k  static int classifyTagHTML(unsigned int start, unsigned int end,                             WordList &keywords, Accessor &styler, bool &tagDontFold, -			   bool caseSensitive) { +			   bool caseSensitive, bool isXml) {  	char s[30 + 2];  	// Copy after the '<'  	unsigned int i = 0; @@ -239,9 +239,10 @@ static int classifyTagHTML(unsigned int start, unsigned int end,  	s[i] = ' ';  	s[i+1] = '\0'; +	// if the current language is XML, I can fold any tag +	// if the current language is HTML, I don't want to fold certain tags (input, meta, etc.)  	//...to find it in the list of no-container-tags -	// (There are many more. We will need a keywordlist in the property file for this) -	tagDontFold = (NULL != strstr("meta link img area br hr input ",s)); +	tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ",s));  	//now we can remove the trailing space  	s[i] = '\0'; @@ -458,7 +459,7 @@ static int FindPhpStringDelimiter(char *phpStringDelimiter, const int phpStringD  }  static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], -                                  Accessor &styler) { +                                  Accessor &styler, bool isXml) {  	WordList &keywords = *keywordlists[0];  	WordList &keywords2 = *keywordlists[1];  	WordList &keywords3 = *keywordlists[2]; @@ -655,7 +656,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  				break;  			default :  				// check if the closing tag is a script tag -				if (state == SCE_HJ_COMMENTLINE) { +				if (state == SCE_HJ_COMMENTLINE || isXml) {  					char tag[7]; // room for the <script> tag  					char chr;	// current char  					int j=0; @@ -1017,7 +1018,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  		case SCE_H_TAGUNKNOWN:  			if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {  				int eClass = classifyTagHTML(styler.GetStartSegment(), -					i - 1, keywords, styler, tagDontFold, caseSensitive); +					i - 1, keywords, styler, tagDontFold, caseSensitive, isXml);  				if (eClass == SCE_H_SCRIPT) {  					if (!tagClosing) {  						inScriptType = eNonHtmlScript; @@ -1719,6 +1720,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty  	}  } +static void ColouriseXMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +                                  Accessor &styler) { +	// Passing in true because we're lexing XML +	ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists,styler, true); +} + +static void ColouriseHTMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +                                  Accessor &styler) { +	// Passing in false because we're notlexing XML +	ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists,styler, false); +} +  static bool isASPScript(int state) {  	return  		(state >= SCE_HJA_START && state <= SCE_HJA_REGEX) || @@ -2015,7 +2028,7 @@ static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, Wo  static void ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],                                                 Accessor &styler) {  	if(startPos == 0) initStyle = SCE_HPHP_DEFAULT; -		ColouriseHyperTextDoc(startPos,length,initStyle,keywordlists,styler); +		ColouriseHTMLDoc(startPos,length,initStyle,keywordlists,styler);  }  static const char * const htmlWordListDesc[] = { @@ -2038,8 +2051,8 @@ static const char * const phpscriptWordListDesc[] = {  	0,  }; -LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext", 0, htmlWordListDesc, 7); -LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml", 0, htmlWordListDesc, 7); +LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 7); +LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 7);  // SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead.  LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 7);  LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 7); | 
