[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:
donho 2008-12-30 10:26:01 +00:00
parent e12d8b8c99
commit 261d357e66
4 changed files with 35 additions and 11 deletions

View File

@ -119,23 +119,30 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
throw generic_string(TEXT("Loading GetLexerStatusText function failed."));
// Assign a buffer for the lexer name.
TCHAR lexName[MAX_EXTERNAL_LEXER_NAME_LEN];
lstrcpy(lexName, TEXT(""));
char lexName[MAX_EXTERNAL_LEXER_NAME_LEN];
lexName[0] = '\0';
TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN];
lstrcpy(lexDesc, TEXT(""));
int numLexers = GetLexerCount();
NppParameters * nppParams = NppParameters::getInstance();
ExternalLangContainer *containers[30];
#ifdef UNICODE
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
#endif
for (int x = 0; x < numLexers; x++)
{
GetLexerName(x, lexName, MAX_EXTERNAL_LEXER_NAME_LEN);
GetLexerStatusText(x, lexDesc, MAX_EXTERNAL_LEXER_DESC_LEN);
if (!nppParams->isExistingExternalLangName(lexName) && nppParams->ExternalLangHasRoom())
containers[x] = new ExternalLangContainer(lexName, lexDesc);
#ifdef UNICODE
const TCHAR *pLexerName = wmc->char2wchar(lexName, CP_ACP);
#else
const TCHAR *pLexerName = lexName;
#endif
if (!nppParams->isExistingExternalLangName(pLexerName) && nppParams->ExternalLangHasRoom())
containers[x] = new ExternalLangContainer(pLexerName, lexDesc);
else
containers[x] = NULL;
}
@ -167,8 +174,12 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
nppParams->getExternalLexerFromXmlTree(_pXmlDoc);
nppParams->getExternalLexerDoc()->push_back(_pXmlDoc);
::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)dllNames[i].c_str());
#ifdef UNICODE
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);
}

View File

@ -148,7 +148,7 @@ private:
// External Lexer function definitions...
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);
#endif //PLUGINSMANAGER_H

View File

@ -594,7 +594,13 @@ bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Rea
} else {
int id = language - L_EXTERNAL;
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;

View File

@ -583,7 +583,14 @@ void ScintillaEditView::setExternalLexer(LangType typeDoc)
{
int id = typeDoc - L_EXTERNAL;
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);
if (pStyler)