mirror of
				https://github.com/notepad-plus-plus/notepad-plus-plus.git
				synced 2025-10-31 19:44:06 +01:00 
			
		
		
		
	[BUG_FIXED] Fix bug that external lexer doesn't work with Unicode version.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@381 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
		
							parent
							
								
									e12d8b8c99
								
							
						
					
					
						commit
						261d357e66
					
				| @ -119,8 +119,8 @@ bool PluginsManager::loadPlugins(const TCHAR *dir) | |||||||
| 						throw generic_string(TEXT("Loading GetLexerStatusText function failed.")); | 						throw generic_string(TEXT("Loading GetLexerStatusText function failed.")); | ||||||
| 
 | 
 | ||||||
| 					// Assign a buffer for the lexer name.
 | 					// Assign a buffer for the lexer name.
 | ||||||
| 					TCHAR lexName[MAX_EXTERNAL_LEXER_NAME_LEN]; | 					char lexName[MAX_EXTERNAL_LEXER_NAME_LEN]; | ||||||
| 					lstrcpy(lexName, TEXT("")); | 					lexName[0] = '\0'; | ||||||
| 					TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN]; | 					TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN]; | ||||||
| 					lstrcpy(lexDesc, TEXT("")); | 					lstrcpy(lexDesc, TEXT("")); | ||||||
| 
 | 
 | ||||||
| @ -129,13 +129,20 @@ bool PluginsManager::loadPlugins(const TCHAR *dir) | |||||||
| 					NppParameters * nppParams = NppParameters::getInstance(); | 					NppParameters * nppParams = NppParameters::getInstance(); | ||||||
| 					 | 					 | ||||||
| 					ExternalLangContainer *containers[30]; | 					ExternalLangContainer *containers[30]; | ||||||
|  | #ifdef UNICODE | ||||||
|  | 					WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); | ||||||
|  | #endif | ||||||
| 					for (int x = 0; x < numLexers; x++) | 					for (int x = 0; x < numLexers; x++) | ||||||
| 					{ | 					{ | ||||||
| 						GetLexerName(x, lexName, MAX_EXTERNAL_LEXER_NAME_LEN); | 						GetLexerName(x, lexName, MAX_EXTERNAL_LEXER_NAME_LEN); | ||||||
| 						GetLexerStatusText(x, lexDesc, MAX_EXTERNAL_LEXER_DESC_LEN); | 						GetLexerStatusText(x, lexDesc, MAX_EXTERNAL_LEXER_DESC_LEN); | ||||||
| 						 | #ifdef UNICODE | ||||||
| 						if (!nppParams->isExistingExternalLangName(lexName) && nppParams->ExternalLangHasRoom()) | 						const TCHAR *pLexerName = wmc->char2wchar(lexName, CP_ACP); | ||||||
| 							containers[x] = new ExternalLangContainer(lexName, lexDesc); | #else | ||||||
|  | 						const TCHAR *pLexerName = lexName; | ||||||
|  | #endif | ||||||
|  | 						if (!nppParams->isExistingExternalLangName(pLexerName) && nppParams->ExternalLangHasRoom()) | ||||||
|  | 							containers[x] = new ExternalLangContainer(pLexerName, lexDesc); | ||||||
| 						else | 						else | ||||||
| 							containers[x] = NULL; | 							containers[x] = NULL; | ||||||
| 					} | 					} | ||||||
| @ -167,8 +174,12 @@ bool PluginsManager::loadPlugins(const TCHAR *dir) | |||||||
| 
 | 
 | ||||||
| 					nppParams->getExternalLexerFromXmlTree(_pXmlDoc); | 					nppParams->getExternalLexerFromXmlTree(_pXmlDoc); | ||||||
| 					nppParams->getExternalLexerDoc()->push_back(_pXmlDoc); | 					nppParams->getExternalLexerDoc()->push_back(_pXmlDoc); | ||||||
| 
 | #ifdef UNICODE | ||||||
| 					::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)dllNames[i].c_str()); | 					const char *pDllName = wmc->wchar2char(dllNames[i].c_str(), CP_ACP); | ||||||
|  | #else | ||||||
|  | 					const char *pDllName = dllNames[i].c_str(); | ||||||
|  | #endif | ||||||
|  | 					::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName); | ||||||
| 				} | 				} | ||||||
| 				_pluginInfos.push_back(pi); | 				_pluginInfos.push_back(pi); | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -148,7 +148,7 @@ private: | |||||||
| 
 | 
 | ||||||
| // External Lexer function definitions...
 | // External Lexer function definitions...
 | ||||||
| typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); | typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); | ||||||
| typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, TCHAR *name, int buflength); | typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); | ||||||
| typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, TCHAR *desc, int buflength); | typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, TCHAR *desc, int buflength); | ||||||
| 
 | 
 | ||||||
| #endif //PLUGINSMANAGER_H
 | #endif //PLUGINSMANAGER_H
 | ||||||
|  | |||||||
| @ -594,7 +594,13 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea | |||||||
| 	} else { | 	} else { | ||||||
| 		int id = language - L_EXTERNAL; | 		int id = language - L_EXTERNAL; | ||||||
| 		TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; | 		TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; | ||||||
| 		_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); | #ifdef UNICODE | ||||||
|  | 		WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); | ||||||
|  | 		const char *pName = wmc->wchar2char(name, CP_ACP); | ||||||
|  | #else | ||||||
|  | 		const char *pName = name; | ||||||
|  | #endif | ||||||
|  | 		_pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	bool success = true; | 	bool success = true; | ||||||
|  | |||||||
| @ -583,7 +583,14 @@ void ScintillaEditView::setExternalLexer(LangType typeDoc) | |||||||
| { | { | ||||||
| 	int id = typeDoc - L_EXTERNAL; | 	int id = typeDoc - L_EXTERNAL; | ||||||
| 	TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; | 	TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; | ||||||
| 	execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); | 	 | ||||||
|  | #ifdef UNICODE | ||||||
|  | 	WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); | ||||||
|  | 	const char *pName = wmc->wchar2char(name, CP_ACP); | ||||||
|  | #else | ||||||
|  | 	const char *pName = name; | ||||||
|  | #endif | ||||||
|  | 	execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)pName); | ||||||
| 
 | 
 | ||||||
| 	LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(name);	 | 	LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(name);	 | ||||||
| 	if (pStyler) | 	if (pStyler) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user