Remove the external lexer support

SCI_LOADLEXERLIBRARY has been removed since Scintilla 5,
and I belive that Scintilla won't support it anymore:
https://sourceforge.net/p/scintilla/bugs/2236/

Close #11451
This commit is contained in:
Don Ho 2022-03-29 23:43:29 +02:00
parent a61b03ea88
commit 41a5bf0245
21 changed files with 80 additions and 420 deletions

2
.gitignore vendored
View File

@ -55,6 +55,8 @@ UpgradeLog*.htm
*.bak *.bak
PowerEditor/bin/notepad++.exe PowerEditor/bin/notepad++.exe
PowerEditor/bin/Notepad++.exp
PowerEditor/bin/Notepad++.lib
PowerEditor/bin/SciLexer.dll PowerEditor/bin/SciLexer.dll
PowerEditor/bin/config.xml PowerEditor/bin/config.xml
PowerEditor/bin/stylers.xml PowerEditor/bin/stylers.xml

View File

@ -23,7 +23,6 @@ class FileNameStringSplitter
public: public:
FileNameStringSplitter(const TCHAR *fileNameStr) FileNameStringSplitter(const TCHAR *fileNameStr)
{ {
//if (!fileNameStr) return;
TCHAR *pStr = NULL; TCHAR *pStr = NULL;
bool isInsideQuotes = false; bool isInsideQuotes = false;
const int filePathLength = MAX_PATH; const int filePathLength = MAX_PATH;

View File

@ -35,7 +35,7 @@ enum LangType {L_TEXT, L_PHP , L_C, L_CPP, L_CS, L_OBJC, L_JAVA, L_RC,\
L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT,\ L_REGISTRY, L_RUST, L_SPICE, L_TXT2TAGS, L_VISUALPROLOG, L_TYPESCRIPT,\
// Don't use L_JS, use L_JAVASCRIPT instead // Don't use L_JS, use L_JAVASCRIPT instead
// The end of enumated language type, so it should be always at the end // The end of enumated language type, so it should be always at the end
L_EXTERNAL}; L_END};
enum class ExternalLexerAutoIndentMode { Standard, C_Like, Custom }; enum class ExternalLexerAutoIndentMode { Standard, C_Like, Custom };
enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack }; enum class MacroStatus { Idle, RecordInProgress, RecordingStopped, PlayingBack };
@ -456,6 +456,10 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
HICON hToolbarIconDarkMode; HICON hToolbarIconDarkMode;
}; };
// Due to Scintilla 5 doesn't support external lexer, the following 2 messages are deprecated - they do nothing and return always FALSE
#define NPPM_GETEXTERNALLEXERAUTOINDENTMODE_DEPRECATED (NPPMSG + 103)
#define NPPM_SETEXTERNALLEXERAUTOINDENTMODE_DEPRECATED (NPPMSG + 104)
/*
#define NPPM_GETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 103) #define NPPM_GETEXTERNALLEXERAUTOINDENTMODE (NPPMSG + 103)
// BOOL NPPM_GETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode &autoIndentMode) // BOOL NPPM_GETEXTERNALLEXERAUTOINDENTMODE(const TCHAR *languageName, ExternalLexerAutoIndentMode &autoIndentMode)
// Get ExternalLexerAutoIndentMode for an installed external programming language. // Get ExternalLexerAutoIndentMode for an installed external programming language.
@ -471,7 +475,7 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language; // - C_Like means Notepad++ will perform a C-Language style indentation for the selected external language;
// - Custom means a Plugin will be controlling auto-indentation for the current language. // - Custom means a Plugin will be controlling auto-indentation for the current language.
// returned value: TRUE if function call was successful, otherwise FALSE. // returned value: TRUE if function call was successful, otherwise FALSE.
*/
#define NPPM_ISAUTOINDENTON (NPPMSG + 105) #define NPPM_ISAUTOINDENTON (NPPMSG + 105)
// BOOL NPPM_ISAUTOINDENTON(0, 0) // BOOL NPPM_ISAUTOINDENTON(0, 0)
// Returns the current Use Auto-Indentation setting in Notepad++ Preferences. // Returns the current Use Auto-Indentation setting in Notepad++ Preferences.

View File

@ -173,82 +173,17 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
// it's a lexer plugin // it's a lexer plugin
if (GetLexerCount) if (GetLexerCount)
{ {
GetLexerNameFn GetLexerName = (GetLexerNameFn)::GetProcAddress(pi->_hLib, "GetLexerName"); // Lexer library (.dll) is not supported in Scintilla 5
if (!GetLexerName)
throw generic_string(TEXT("Loading GetLexerName function failed."));
GetLexerStatusTextFn GetLexerStatusText = (GetLexerStatusTextFn)::GetProcAddress(pi->_hLib, "GetLexerStatusText"); generic_string s = pluginFileName;
s += TEXT(" is a Lexer library.\n");
if (!GetLexerStatusText) s += TEXT("Lexer library is not supported in Scintilla 5.\nIt'll be loaded as only a normal plugin, the external language part won't work with this version of Notepad++.");
throw generic_string(TEXT("Loading GetLexerStatusText function failed.")); ::MessageBox(_nppData._nppHandle, s.c_str(), pluginFilePath, MB_OK);
// Assign a buffer for the lexer name.
char lexName[MAX_EXTERNAL_LEXER_NAME_LEN];
lexName[0] = '\0';
TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN];
lexDesc[0] = '\0';
int numLexers = GetLexerCount();
ExternalLangContainer *containers[30];
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
for (int x = 0; x < numLexers; ++x)
{
GetLexerName(x, lexName, MAX_EXTERNAL_LEXER_NAME_LEN);
GetLexerStatusText(x, lexDesc, MAX_EXTERNAL_LEXER_DESC_LEN);
const TCHAR *pLexerName = wmc.char2wchar(lexName, CP_ACP);
if (!nppParams.isExistingExternalLangName(pLexerName) && nppParams.ExternalLangHasRoom())
containers[x] = new ExternalLangContainer(pLexerName, lexDesc);
else
containers[x] = NULL;
} }
TCHAR xmlPath[MAX_PATH];
wcscpy_s(xmlPath, nppParams.getNppPath().c_str());
PathAppend(xmlPath, TEXT("plugins\\Config"));
PathAppend(xmlPath, pi->_moduleName.c_str());
PathRemoveExtension(xmlPath);
PathAddExtension(xmlPath, TEXT(".xml"));
if (!PathFileExists(xmlPath))
{
lstrcpyn(xmlPath, TEXT("\0"), MAX_PATH );
wcscpy_s(xmlPath, nppParams.getAppDataNppDir() );
PathAppend(xmlPath, TEXT("plugins\\Config"));
PathAppend(xmlPath, pi->_moduleName.c_str());
PathRemoveExtension( xmlPath );
PathAddExtension( xmlPath, TEXT(".xml") );
if (! PathFileExists( xmlPath ) )
{
throw generic_string(generic_string(xmlPath) + TEXT(" is missing."));
}
}
TiXmlDocument *pXmlDoc = new TiXmlDocument(xmlPath);
if (!pXmlDoc->LoadFile())
{
delete pXmlDoc;
pXmlDoc = NULL;
throw generic_string(generic_string(xmlPath) + TEXT(" failed to load."));
}
for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt
{
if (containers[x] != NULL)
nppParams.addExternalLangToEnd(containers[x]);
}
nppParams.getExternalLexerFromXmlTree(pXmlDoc);
nppParams.getExternalLexerDoc()->push_back(pXmlDoc);
//const char *pDllName = wmc.wchar2char(pluginFilePath, CP_ACP);
//::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, reinterpret_cast<LPARAM>(pDllName));
}
addInLoadedDlls(pluginFilePath, pluginFileName); addInLoadedDlls(pluginFilePath, pluginFileName);
_pluginInfos.push_back(pi); _pluginInfos.push_back(pi);
return static_cast<int32_t>(_pluginInfos.size() - 1); return static_cast<int32_t>(_pluginInfos.size() - 1);
} }
catch (std::exception& e) catch (std::exception& e)
@ -257,18 +192,20 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
return -1; return -1;
} }
catch (generic_string& s) catch (generic_string& s)
{
s += TEXT("\n\n");
s += pluginFileName;
s += USERMSG;
if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
{ {
if (pi && pi->_hLib) if (pi && pi->_hLib)
{ {
::FreeLibrary(pi->_hLib); ::FreeLibrary(pi->_hLib);
} }
s += TEXT("\n\n");
s += pluginFileName;
s += USERMSG;
if (::MessageBox(_nppData._nppHandle, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
{
::DeleteFile(pluginFilePath); ::DeleteFile(pluginFilePath);
} }
delete pi; delete pi;
return -1; return -1;
} }
@ -278,7 +215,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
msg += TEXT("\n\n"); msg += TEXT("\n\n");
msg += pluginFileName; msg += pluginFileName;
msg += USERMSG; msg += USERMSG;
if (::MessageBox(NULL, msg.c_str(), pluginFilePath, MB_YESNO) == IDYES) if (::MessageBox(_nppData._nppHandle, msg.c_str(), pluginFilePath, MB_YESNO) == IDYES)
{ {
if (pi && pi->_hLib) if (pi && pi->_hLib)
{ {
@ -291,7 +228,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
} }
} }
bool PluginsManager::loadPluginsV2(const TCHAR* dir, const PluginViewList* pluginUpdateInfoList) bool PluginsManager::loadPluginsFromItsOwnFolder(const TCHAR* dir, const PluginViewList* pluginUpdateInfoList)
{ {
if (_isDisabled) if (_isDisabled)
return false; return false;

View File

@ -86,8 +86,7 @@ public:
_nppData = nppData; _nppData = nppData;
} }
int loadPlugin(const TCHAR *pluginFilePath); bool loadPluginsFromItsOwnFolder(const TCHAR *dir = NULL, const PluginViewList* pluginUpdateInfoList = nullptr);
bool loadPluginsV2(const TCHAR *dir = NULL, const PluginViewList* pluginUpdateInfoList = nullptr);
bool unloadPlugin(int index, HWND nppHandle); bool unloadPlugin(int index, HWND nppHandle);
@ -127,6 +126,8 @@ private:
IDAllocator _markerAlloc; IDAllocator _markerAlloc;
bool _noMoreNotification = false; bool _noMoreNotification = false;
int loadPlugin(const TCHAR* pluginFilePath);
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature)
{ {
generic_string msg = pluginName; generic_string msg = pluginName;
@ -162,5 +163,3 @@ 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, char *name, int buflength);
typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, TCHAR *desc, int buflength);

View File

@ -407,9 +407,8 @@ LRESULT Notepad_plus::init(HWND hwnd)
_scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd); _scintillaCtrls4Plugins.init(_pPublicInterface->getHinst(), hwnd);
_pluginsManager.init(nppData); _pluginsManager.init(nppData);
bool enablePluginAdmin = _pluginsAdminDlg.initFromJson(); bool enablePluginAdmin = _pluginsAdminDlg.initFromJson();
_pluginsManager.loadPluginsV2(nppParam.getPluginRootDir(), enablePluginAdmin ? &_pluginsAdminDlg.getAvailablePluginUpdateInfoList() : nullptr); _pluginsManager.loadPluginsFromItsOwnFolder(nppParam.getPluginRootDir(), enablePluginAdmin ? &_pluginsAdminDlg.getAvailablePluginUpdateInfoList() : nullptr);
_restoreButton.init(_pPublicInterface->getHinst(), hwnd); _restoreButton.init(_pPublicInterface->getHinst(), hwnd);
// ------------ // // ------------ //
@ -467,24 +466,6 @@ LRESULT Notepad_plus::init(HWND hwnd)
//Languages Menu //Languages Menu
HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE); HMENU hLangMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_LANGUAGE);
// Add external languages to menu
for (int i = 0; i < nppParam.getNbExternalLang(); ++i)
{
ExternalLangContainer & externalLangContainer = nppParam.getELCFromIndex(i);
int numLangs = ::GetMenuItemCount(hLangMenu);
const int bufferSize = 100;
TCHAR buffer[bufferSize];
int x;
for (x = 0; (x == 0 || lstrcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; ++x)
{
::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION);
}
::InsertMenu(hLangMenu, x - 1, MF_BYPOSITION, IDM_LANG_EXTERNAL + i, externalLangContainer._name);
}
if (nppGUI._excludedLangList.size() > 0) if (nppGUI._excludedLangList.size() > 0)
{ {
for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len; ++i) for (size_t i = 0, len = nppGUI._excludedLangList.size(); i < len; ++i)
@ -2358,25 +2339,14 @@ void Notepad_plus::checkLangsMenu(int id) const
generic_string Notepad_plus::getLangDesc(LangType langType, bool getName) generic_string Notepad_plus::getLangDesc(LangType langType, bool getName)
{ {
NppParameters& nppParams = NppParameters::getInstance(); if (langType >= L_END)
if ((langType >= L_EXTERNAL) && (langType < nppParams.L_END))
{
ExternalLangContainer & elc = nppParams.getELCFromIndex(langType - L_EXTERNAL);
if (getName)
return generic_string(elc._name);
else
return generic_string(elc._desc);
}
if (langType > L_EXTERNAL)
langType = L_TEXT; langType = L_TEXT;
generic_string str2Show; generic_string str2Show;
if (getName) if (getName)
str2Show = ScintillaEditView::langNames[langType].shortName; str2Show = ScintillaEditView::_langNames[langType].shortName;
else else
str2Show = ScintillaEditView::langNames[langType].longName; str2Show = ScintillaEditView::_langNames[langType].longName;
if (langType == L_USER) if (langType == L_USER)
{ {
@ -3105,15 +3075,6 @@ void Notepad_plus::maintainIndentation(TCHAR ch)
LangType type = _pEditView->getCurrentBuffer()->getLangType(); LangType type = _pEditView->getCurrentBuffer()->getLangType();
ExternalLexerAutoIndentMode autoIndentMode = ExternalLexerAutoIndentMode::Standard; ExternalLexerAutoIndentMode autoIndentMode = ExternalLexerAutoIndentMode::Standard;
// For external languages, query for custom auto-indentation funcionality
if (type >= L_EXTERNAL)
{
NppParameters& nppParam = NppParameters::getInstance();
autoIndentMode = nppParam.getELCFromIndex(type - L_EXTERNAL)._autoIndentMode;
if (autoIndentMode == ExternalLexerAutoIndentMode::Custom)
return;
}
// Do not alter indentation if we were at the beginning of the line and we pressed Enter // Do not alter indentation if we were at the beginning of the line and we pressed Enter
if ((((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') || if ((((eolMode == SC_EOL_CRLF || eolMode == SC_EOL_LF) && ch == '\n') ||
(eolMode == SC_EOL_CR && ch == '\r')) && prevLine >= 0 && _pEditView->getLineLength(prevLine) == 0) (eolMode == SC_EOL_CR && ch == '\r')) && prevLine >= 0 && _pEditView->getLineLength(prevLine) == 0)
@ -3504,7 +3465,7 @@ LangType Notepad_plus::menuID2LangType(int cmdID)
break; break;
} }
} }
return L_EXTERNAL; return L_TEXT;
} }
@ -4286,7 +4247,7 @@ void Notepad_plus::docOpenInNewInstance(FileTransferMode mode, int x, int y)
if (lt != L_USER) if (lt != L_USER)
{ {
command += TEXT(" -l"); command += TEXT(" -l");
command += ScintillaEditView::langNames[lt].lexerName; command += ScintillaEditView::_langNames[lt].lexerName;
} }
command += TEXT(" -n"); command += TEXT(" -n");
command += to_wstring(_pEditView->getCurrentLineNumber() + 1); command += to_wstring(_pEditView->getCurrentLineNumber() + 1);
@ -6160,7 +6121,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
{ {
pBuf->setLangType(L_USER, udl.c_str()); pBuf->setLangType(L_USER, udl.c_str());
} }
else if (lt != L_EXTERNAL && lt < nppParams.L_END) else
{ {
pBuf->setLangType(lt); pBuf->setLangType(lt);
} }

View File

@ -415,7 +415,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
{ {
if (!wParam) if (!wParam)
return FALSE; return FALSE;
if (lParam < L_TEXT || lParam >= L_EXTERNAL || lParam == L_USER) if (lParam < L_TEXT || lParam >= L_END || lParam == L_USER)
return FALSE; return FALSE;
BufferID id = (BufferID)wParam; BufferID id = (BufferID)wParam;
@ -2555,24 +2555,14 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return langDesc.length(); return langDesc.length();
} }
case NPPM_GETEXTERNALLEXERAUTOINDENTMODE: case NPPM_GETEXTERNALLEXERAUTOINDENTMODE_DEPRECATED:
{ {
int index = nppParam.getExternalLangIndexFromName(reinterpret_cast<TCHAR*>(wParam));
if (index < 0)
return FALSE; return FALSE;
*(reinterpret_cast<ExternalLexerAutoIndentMode*>(lParam)) = nppParam.getELCFromIndex(index)._autoIndentMode;
return TRUE;
} }
case NPPM_SETEXTERNALLEXERAUTOINDENTMODE: case NPPM_SETEXTERNALLEXERAUTOINDENTMODE_DEPRECATED:
{ {
int index = nppParam.getExternalLangIndexFromName(reinterpret_cast<TCHAR*>(wParam));
if (index < 0)
return FALSE; return FALSE;
nppParam.getELCFromIndex(index)._autoIndentMode = static_cast<ExternalLexerAutoIndentMode>(lParam);
return TRUE;
} }
case NPPM_ISAUTOINDENTON: case NPPM_ISAUTOINDENTON:

View File

@ -3777,14 +3777,6 @@ void Notepad_plus::command(int id)
_pDocMap->setSyntaxHiliting(); _pDocMap->setSyntaxHiliting();
} }
} }
else if ((id >= IDM_LANG_EXTERNAL) && (id <= IDM_LANG_EXTERNAL_LIMIT))
{
setLanguage((LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL));
if (_pDocMap)
{
_pDocMap->setSyntaxHiliting();
}
}
else if ((id >= ID_MACRO) && (id < ID_MACRO_LIMIT)) else if ((id >= ID_MACRO) && (id < ID_MACRO_LIMIT))
{ {
int i = id - ID_MACRO; int i = id - ID_MACRO;

View File

@ -2047,8 +2047,6 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou
LangType typeToSet = L_TEXT; LangType typeToSet = L_TEXT;
if (id != 0 && id != IDM_LANG_USER) if (id != 0 && id != IDM_LANG_USER)
typeToSet = menuID2LangType(id); typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL )
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
Buffer *buf = MainFileManager.getBufferByID(lastOpened); Buffer *buf = MainFileManager.getBufferByID(lastOpened);
@ -2158,8 +2156,6 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou
if (id != 0) if (id != 0)
typeToSet = menuID2LangType(id); typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL )
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
Buffer * buf = MainFileManager.getBufferByID(lastOpened); Buffer * buf = MainFileManager.getBufferByID(lastOpened);

View File

@ -934,11 +934,6 @@ NppParameters::~NppParameters()
delete _userLangArray[i]; delete _userLangArray[i];
if (_hUXTheme) if (_hUXTheme)
FreeLibrary(_hUXTheme); FreeLibrary(_hUXTheme);
for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it )
delete (*it);
_pXmlExternalLexerDoc.clear();
} }
@ -975,11 +970,6 @@ bool NppParameters::reloadStylers(const TCHAR* stylePath)
getUserStylersFromXmlTree(); getUserStylersFromXmlTree();
// Reload plugin styles.
for ( size_t i = 0; i < getExternalLexerDoc()->size(); ++i)
{
getExternalLexerFromXmlTree( getExternalLexerDoc()->at(i) );
}
return true; return true;
} }
@ -1042,7 +1032,6 @@ generic_string NppParameters::getSettingsFolder()
bool NppParameters::load() bool NppParameters::load()
{ {
L_END = L_EXTERNAL;
bool isAllLaoded = true; bool isAllLaoded = true;
_isx64 = sizeof(void *) == 8; _isx64 = sizeof(void *) == 8;
@ -1481,10 +1470,6 @@ bool NppParameters::load()
getSessionFromXmlTree(pXmlSessionDoc, _session); getSessionFromXmlTree(pXmlSessionDoc, _session);
delete pXmlSessionDoc; delete pXmlSessionDoc;
for (size_t i = 0, len = _pXmlExternalLexerDoc.size() ; i < len ; ++i)
if (_pXmlExternalLexerDoc[i])
delete _pXmlExternalLexerDoc[i];
} }
//-------------------------------------------------------------// //-------------------------------------------------------------//
@ -1590,21 +1575,6 @@ void NppParameters::SetTransparent(HWND hwnd, int percent)
} }
} }
bool NppParameters::isExistingExternalLangName(const TCHAR *newName) const
{
if ((!newName) || (!newName[0]))
return true;
for (int i = 0 ; i < _nbExternalLang ; ++i)
{
if (!lstrcmp(_externalLangArray[i]->_name, newName))
return true;
}
return false;
}
const TCHAR* NppParameters::getUserDefinedLangNameFromExt(TCHAR *ext, TCHAR *fullName) const const TCHAR* NppParameters::getUserDefinedLangNameFromExt(TCHAR *ext, TCHAR *fullName) const
{ {
if ((!ext) || (!ext[0])) if ((!ext) || (!ext[0]))
@ -1642,18 +1612,6 @@ const TCHAR* NppParameters::getUserDefinedLangNameFromExt(TCHAR *ext, TCHAR *ful
return nullptr; return nullptr;
} }
int NppParameters::getExternalLangIndexFromName(const TCHAR* externalLangName) const
{
for (int i = 0 ; i < _nbExternalLang ; ++i)
{
if (!lstrcmp(externalLangName, _externalLangArray[i]->_name))
return i;
}
return -1;
}
UserLangContainer* NppParameters::getULCFromName(const TCHAR *userLangName) UserLangContainer* NppParameters::getULCFromName(const TCHAR *userLangName)
{ {
for (int i = 0 ; i < _nbUserLang ; ++i) for (int i = 0 ; i < _nbUserLang ; ++i)
@ -1756,25 +1714,6 @@ void NppParameters::getLangKeywordsFromXmlTree()
feedKeyWordsParameters(root); feedKeyWordsParameters(root);
} }
void NppParameters::getExternalLexerFromXmlTree(TiXmlDocument *doc)
{
TiXmlNode *root = doc->FirstChild(TEXT("NotepadPlus"));
if (!root) return;
feedKeyWordsParameters(root);
feedStylerArray(root);
}
int NppParameters::addExternalLangToEnd(ExternalLangContainer * externalLang)
{
_externalLangArray[_nbExternalLang] = externalLang;
++_nbExternalLang;
++L_END;
return _nbExternalLang-1;
}
bool NppParameters::getUserStylersFromXmlTree() bool NppParameters::getUserStylersFromXmlTree()
{ {
TiXmlNode *root = _pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")); TiXmlNode *root = _pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus"));
@ -2874,7 +2813,7 @@ std::pair<unsigned char, unsigned char> NppParameters::feedUserLang(TiXmlNode *n
} }
} }
catch (const std::exception& /*e*/) catch (const std::exception&)
{ {
delete _userLangArray[--_nbUserLang]; delete _userLangArray[--_nbUserLang];
} }
@ -3664,16 +3603,9 @@ bool NppParameters::feedStylerArray(TiXmlNode *node)
const TCHAR *lexerName = element->Attribute(TEXT("name")); const TCHAR *lexerName = element->Attribute(TEXT("name"));
const TCHAR *lexerDesc = element->Attribute(TEXT("desc")); const TCHAR *lexerDesc = element->Attribute(TEXT("desc"));
const TCHAR *lexerUserExt = element->Attribute(TEXT("ext")); const TCHAR *lexerUserExt = element->Attribute(TEXT("ext"));
const TCHAR *lexerExcluded = element->Attribute(TEXT("excluded"));
if (lexerName) if (lexerName)
{ {
_lexerStylerVect.addLexerStyler(lexerName, lexerDesc, lexerUserExt, childNode); _lexerStylerVect.addLexerStyler(lexerName, lexerDesc, lexerUserExt, childNode);
if (lexerExcluded != NULL && (lstrcmp(lexerExcluded, TEXT("yes")) == 0))
{
int index = getExternalLangIndexFromName(lexerName);
if (index != -1)
_nppGUI._excludedLangList.push_back(LangMenuItem((LangType)(index + L_EXTERNAL)));
}
} }
} }
@ -3956,24 +3888,15 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHA
LangType NppParameters::getLangIDFromStr(const TCHAR *langName) LangType NppParameters::getLangIDFromStr(const TCHAR *langName)
{ {
int lang = static_cast<int32_t>(L_TEXT); int lang = static_cast<int32_t>(L_TEXT);
for (; lang < L_EXTERNAL; ++lang) for (; lang < L_END; ++lang)
{ {
const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; const TCHAR * name = ScintillaEditView::_langNames[lang].lexerName;
if (!lstrcmp(name, langName)) //found lang? if (!lstrcmp(name, langName)) //found lang?
{ {
return (LangType)lang; return (LangType)lang;
} }
} }
//Cannot find language, check if its an external one
LangType l = (LangType)lang;
if (l == L_EXTERNAL) //try find external lexer
{
int id = NppParameters::getInstance().getExternalLangIndexFromName(langName);
if (id != -1) return (LangType)(id + L_EXTERNAL);
}
return L_TEXT; return L_TEXT;
} }
@ -6824,7 +6747,7 @@ void NppParameters::writeExcludedLangList(TiXmlElement *element)
for (size_t i = 0, len = _nppGUI._excludedLangList.size(); i < len ; ++i) for (size_t i = 0, len = _nppGUI._excludedLangList.size(); i < len ; ++i)
{ {
LangType langType = _nppGUI._excludedLangList[i]._langType; LangType langType = _nppGUI._excludedLangList[i]._langType;
if (langType >= L_EXTERNAL && langType < L_END) if (langType >= L_END)
continue; continue;
int nGrp = langType / groupNbMember; int nGrp = langType / groupNbMember;
@ -7124,9 +7047,6 @@ int NppParameters::langTypeToCommandID(LangType lt) const
default : default :
if (lt >= L_EXTERNAL && lt < L_END)
id = lt - L_EXTERNAL + IDM_LANG_EXTERNAL;
else
id = IDM_LANG_TEXT; id = IDM_LANG_TEXT;
} }
return id; return id;
@ -7204,42 +7124,6 @@ generic_string NppParameters::writeStyles(LexerStylerArray & lexersStylers, Styl
} }
} }
for (size_t x = 0; x < _pXmlExternalLexerDoc.size(); ++x)
{
TiXmlNode* lexersRoot2 = ( _pXmlExternalLexerDoc[x]->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode* childNode = lexersRoot2->FirstChildElement(TEXT("LexerType"));
childNode ;
childNode = childNode->NextSibling(TEXT("LexerType")))
{
TiXmlElement *element = childNode->ToElement();
const TCHAR *nm = element->Attribute(TEXT("name"));
LexerStyler *pLs = _lexerStylerVect.getLexerStylerByName(nm);
LexerStyler *pLs2 = lexersStylers.getLexerStylerByName(nm);
if (pLs)
{
const TCHAR *extStr = pLs->getLexerUserExt();
element->SetAttribute(TEXT("ext"), extStr);
for (TiXmlNode *grChildNode = childNode->FirstChildElement(TEXT("WordsStyle"));
grChildNode ;
grChildNode = grChildNode->NextSibling(TEXT("WordsStyle")))
{
TiXmlElement *grElement = grChildNode->ToElement();
const TCHAR *styleName = grElement->Attribute(TEXT("name"));
const Style * pStyle = pLs->findByName(styleName);
Style * pStyle2Sync = pLs2 ? pLs2->findByName(styleName) : nullptr;
if (pStyle && pStyle2Sync)
{
writeStyle2Element(*pStyle, *pStyle2Sync, grElement);
}
}
}
}
_pXmlExternalLexerDoc[x]->SaveFile();
}
TiXmlNode *globalStylesRoot = (_pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("GlobalStyles")); TiXmlNode *globalStylesRoot = (_pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("GlobalStyles"));
for (TiXmlNode *childNode = globalStylesRoot->FirstChildElement(TEXT("WidgetStyle")); for (TiXmlNode *childNode = globalStylesRoot->FirstChildElement(TEXT("WidgetStyle"));

View File

@ -241,7 +241,7 @@ struct CmdLineParams
bool _isRecursive = false; bool _isRecursive = false;
bool _openFoldersAsWorkspace = false; bool _openFoldersAsWorkspace = false;
LangType _langType = L_EXTERNAL; LangType _langType = L_END;
generic_string _localizationPath; generic_string _localizationPath;
generic_string _udlName; generic_string _udlName;
@ -274,7 +274,7 @@ struct CmdLineParamsDTO
intptr_t _column2go = 0; intptr_t _column2go = 0;
intptr_t _pos2go = 0; intptr_t _pos2go = 0;
LangType _langType = L_EXTERNAL; LangType _langType = L_END;
generic_string _udlName; generic_string _udlName;
static CmdLineParamsDTO FromCmdLineParams(const CmdLineParams& params) static CmdLineParamsDTO FromCmdLineParams(const CmdLineParams& params)
@ -1072,25 +1072,6 @@ private:
friend class StylerDlg; friend class StylerDlg;
}; };
#define MAX_EXTERNAL_LEXER_NAME_LEN 16
#define MAX_EXTERNAL_LEXER_DESC_LEN 32
class ExternalLangContainer final
{
public:
TCHAR _name[MAX_EXTERNAL_LEXER_NAME_LEN];
TCHAR _desc[MAX_EXTERNAL_LEXER_DESC_LEN];
ExternalLexerAutoIndentMode _autoIndentMode = ExternalLexerAutoIndentMode::Standard;
ExternalLangContainer(const TCHAR* name, const TCHAR* desc)
{
generic_strncpy(_name, name, MAX_EXTERNAL_LEXER_NAME_LEN);
generic_strncpy(_desc, desc, MAX_EXTERNAL_LEXER_DESC_LEN);
}
};
struct FindHistory final struct FindHistory final
{ {
@ -1287,7 +1268,6 @@ public:
generic_string getSettingsFolder(); generic_string getSettingsFolder();
bool _isTaskListRBUTTONUP_Active = false; bool _isTaskListRBUTTONUP_Active = false;
int L_END;
NppGUI & getNppGUI() { NppGUI & getNppGUI() {
return _nppGUI; return _nppGUI;
@ -1402,16 +1382,6 @@ public:
UserLangContainer & getULCFromIndex(size_t i) {return *_userLangArray[i];}; UserLangContainer & getULCFromIndex(size_t i) {return *_userLangArray[i];};
UserLangContainer * getULCFromName(const TCHAR *userLangName); UserLangContainer * getULCFromName(const TCHAR *userLangName);
int getNbExternalLang() const {return _nbExternalLang;};
int getExternalLangIndexFromName(const TCHAR *externalLangName) const;
ExternalLangContainer & getELCFromIndex(int i) {return *_externalLangArray[i];};
bool ExternalLangHasRoom() const {return _nbExternalLang < NB_MAX_EXTERNAL_LANG;};
void getExternalLexerFromXmlTree(TiXmlDocument *doc);
std::vector<TiXmlDocument *> * getExternalLexerDoc() { return &_pXmlExternalLexerDoc; };
void writeDefaultUDL(); void writeDefaultUDL();
void writeNonDefaultUDL(); void writeNonDefaultUDL();
void writeNeed2SaveUDL(); void writeNeed2SaveUDL();
@ -1437,10 +1407,6 @@ public:
int addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName); int addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName);
void removeUserLang(size_t index); void removeUserLang(size_t index);
bool isExistingExternalLangName(const TCHAR *newName) const;
int addExternalLangToEnd(ExternalLangContainer * externalLang);
TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;}; TiXmlDocumentA * getNativeLangA() const {return _pXmlNativeLangDocA;};
TiXmlDocument * getToolIcons() const {return _pXmlToolIconsDoc;}; TiXmlDocument * getToolIcons() const {return _pXmlToolIconsDoc;};
@ -1682,8 +1648,6 @@ private:
TiXmlDocumentA *_pXmlNativeLangDocA = nullptr; TiXmlDocumentA *_pXmlNativeLangDocA = nullptr;
TiXmlDocumentA *_pXmlContextMenuDocA = nullptr; TiXmlDocumentA *_pXmlContextMenuDocA = nullptr;
std::vector<TiXmlDocument *> _pXmlExternalLexerDoc;
NppGUI _nppGUI; NppGUI _nppGUI;
ScintillaViewParams _svp; ScintillaViewParams _svp;
Lang* _langList[NB_LANG] = { nullptr }; Lang* _langList[NB_LANG] = { nullptr };
@ -1704,7 +1668,6 @@ private:
unsigned char _nbUserLang = 0; // won't be exceeded to 255; unsigned char _nbUserLang = 0; // won't be exceeded to 255;
generic_string _userDefineLangsFolderPath; generic_string _userDefineLangsFolderPath;
generic_string _userDefineLangPath; generic_string _userDefineLangPath;
ExternalLangContainer* _externalLangArray[NB_MAX_EXTERNAL_LANG] = { nullptr };
int _nbExternalLang = 0; int _nbExternalLang = 0;
CmdLineParamsDTO _cmdLineParams; CmdLineParamsDTO _cmdLineParams;

View File

@ -1065,15 +1065,12 @@ const TCHAR * AutoCompletion::getApiFileName()
} }
} }
if (_curLang >= L_EXTERNAL && _curLang < NppParameters::getInstance().L_END) if (_curLang > L_END)
return NppParameters::getInstance().getELCFromIndex(_curLang - L_EXTERNAL)._name;
if (_curLang > L_EXTERNAL)
_curLang = L_TEXT; _curLang = L_TEXT;
if (_curLang == L_JAVASCRIPT) if (_curLang == L_JAVASCRIPT)
_curLang = L_JS; _curLang = L_JS;
return ScintillaEditView::langNames[_curLang].lexerName; return ScintillaEditView::_langNames[_curLang].lexerName;
} }

View File

@ -1444,23 +1444,13 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
} }
_pscratchTilla->execute(SCI_CLEARALL); _pscratchTilla->execute(SCI_CLEARALL);
int lexerID = SCLEX_NULL;
if (fileFormat._language < L_END)
{
lexerID = ScintillaEditView::_langNames[fileFormat._language].lexerID;
}
if (fileFormat._language < L_EXTERNAL) _pscratchTilla->setLexerFromID(lexerID);
{
#pragma warning( push )
#pragma warning( disable : 4996)
const char* pName = LexerNameFromID(ScintillaEditView::langNames[fileFormat._language].lexerID); //deprecated, therefore disabled warning
#pragma warning( pop )
_pscratchTilla->execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(pName)));
}
else
{
int id = fileFormat._language - L_EXTERNAL;
TCHAR * name = nppParam.getELCFromIndex(id)._name;
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc.wchar2char(name, CP_ACP);
_pscratchTilla->execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(pName)));
}
if (fileFormat._encoding != -1) if (fileFormat._encoding != -1)
_pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8); _pscratchTilla->execute(SCI_SETCODEPAGE, SC_CP_UTF8);

View File

@ -18,8 +18,8 @@
#include <shlwapi.h> #include <shlwapi.h>
#include "FindReplaceDlg.h" #include "FindReplaceDlg.h"
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
#include <ILexer.h> #include "ILexer.h"
#include <Lexilla.h> #include "Lexilla.h"
#include "Notepad_plus_msgs.h" #include "Notepad_plus_msgs.h"
#include "localization.h" #include "localization.h"
#include "Utf8.h" #include "Utf8.h"
@ -2314,6 +2314,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
if (!isCreated() && !findReplaceInfo._txt2find) if (!isCreated() && !findReplaceInfo._txt2find)
return nbProcessed; return nbProcessed;
if (!_ppEditView)
return nbProcessed;
ScintillaEditView *pEditView = *_ppEditView; ScintillaEditView *pEditView = *_ppEditView;
if (view2Process) if (view2Process)
pEditView = view2Process; pEditView = view2Process;
@ -4311,7 +4314,7 @@ void Finder::setFinderStyle()
NppDarkMode::setBorder(_scintView.getHSelf()); NppDarkMode::setBorder(_scintView.getHSelf());
// Set current line background color for the finder // Set current line background color for the finder
const TCHAR * lexerName = ScintillaEditView::langNames[L_SEARCHRESULT].lexerName; const TCHAR * lexerName = ScintillaEditView::_langNames[L_SEARCHRESULT].lexerName;
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pStyler) if (pStyler)
{ {

View File

@ -61,7 +61,7 @@ const int ScintillaEditView::_markersArray[][NB_FOLDER_STATE] = {
// Array with all the names of all languages // Array with all the names of all languages
// The order of lang type (enum LangType) must be respected // The order of lang type (enum LangType) must be respected
LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = { LanguageName ScintillaEditView::_langNames[L_END + 1] = {
{TEXT("normal"), TEXT("Normal text"), TEXT("Normal text file"), L_TEXT, SCLEX_NULL}, {TEXT("normal"), TEXT("Normal text"), TEXT("Normal text file"), L_TEXT, SCLEX_NULL},
{TEXT("php"), TEXT("PHP"), TEXT("PHP Hypertext Preprocessor file"), L_PHP, SCLEX_HTML}, {TEXT("php"), TEXT("PHP"), TEXT("PHP Hypertext Preprocessor file"), L_PHP, SCLEX_HTML},
{TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, SCLEX_CPP}, {TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, SCLEX_CPP},
@ -148,7 +148,7 @@ LanguageName ScintillaEditView::langNames[L_EXTERNAL + 1] = {
{TEXT("txt2tags"), TEXT("txt2tags"), TEXT("txt2tags file"), L_TXT2TAGS, SCLEX_TXT2TAGS}, {TEXT("txt2tags"), TEXT("txt2tags"), TEXT("txt2tags file"), L_TXT2TAGS, SCLEX_TXT2TAGS},
{TEXT("visualprolog"), TEXT("Visual Prolog"), TEXT("Visual Prolog file"), L_VISUALPROLOG, SCLEX_VISUALPROLOG}, {TEXT("visualprolog"), TEXT("Visual Prolog"), TEXT("Visual Prolog file"), L_VISUALPROLOG, SCLEX_VISUALPROLOG},
{TEXT("typescript"), TEXT("TypeScript"), TEXT("TypeScript file"), L_TYPESCRIPT, SCLEX_CPP}, {TEXT("typescript"), TEXT("TypeScript"), TEXT("TypeScript file"), L_TYPESCRIPT, SCLEX_CPP},
{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, SCLEX_NULL} {TEXT("endOfLang"), TEXT("EndOfLang"), TEXT("End of Language"), L_END, SCLEX_NULL}
}; };
//const int MASK_RED = 0xFF0000; //const int MASK_RED = 0xFF0000;
@ -877,36 +877,6 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
} }
} }
void ScintillaEditView::setExternalLexer(LangType typeDoc)
{
int id = typeDoc - L_EXTERNAL;
TCHAR * name = NppParameters::getInstance().getELCFromIndex(id)._name;
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
const char *pName = wmc.wchar2char(name, CP_ACP);
execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(pName)));
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(name);
if (pStyler)
{
for (const Style & style : *pStyler)
{
setStyle(style);
if (style._keywordClass >= 0 && style._keywordClass <= KEYWORDSET_MAX)
{
basic_string<char> keywordList("");
if (!style._keywords.empty())
{
keywordList = wstring2string(style._keywords, CP_ACP);
}
execute(SCI_SETKEYWORDS, style._keywordClass, reinterpret_cast<LPARAM>(getCompleteKeywordList(keywordList, typeDoc, style._keywordClass)));
}
}
}
}
void ScintillaEditView::setCppLexer(LangType langType) void ScintillaEditView::setCppLexer(LangType langType)
{ {
const char *cppInstrs; const char *cppInstrs;
@ -974,7 +944,7 @@ void ScintillaEditView::setJsLexer()
execute(SCI_SETKEYWORDS, 2, reinterpret_cast<LPARAM>(doxygenKeyWords_char)); execute(SCI_SETKEYWORDS, 2, reinterpret_cast<LPARAM>(doxygenKeyWords_char));
} }
const TCHAR *newLexerName = ScintillaEditView::langNames[L_JAVASCRIPT].lexerName; const TCHAR *newLexerName = ScintillaEditView::_langNames[L_JAVASCRIPT].lexerName;
LexerStyler *pNewStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(newLexerName); LexerStyler *pNewStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(newLexerName);
if (pNewStyler) // New js styler is available, so we can use it do more modern styling if (pNewStyler) // New js styler is available, so we can use it do more modern styling
{ {
@ -1014,7 +984,7 @@ void ScintillaEditView::setJsLexer()
} }
else // New js styler is not available, we use the old styling for the sake of retro-compatibility else // New js styler is not available, we use the old styling for the sake of retro-compatibility
{ {
const TCHAR *lexerName = ScintillaEditView::langNames[L_JS].lexerName; const TCHAR *lexerName = ScintillaEditView::_langNames[L_JS].lexerName;
LexerStyler *pOldStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pOldStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pOldStyler) if (pOldStyler)
@ -1286,7 +1256,7 @@ void ScintillaEditView::setLexer(int lexerID, LangType langType, int whichList)
void ScintillaEditView::makeStyle(LangType language, const TCHAR **keywordArray) void ScintillaEditView::makeStyle(LangType language, const TCHAR **keywordArray)
{ {
const TCHAR * lexerName = ScintillaEditView::langNames[language].lexerName; const TCHAR * lexerName = ScintillaEditView::_langNames[language].lexerName;
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pStyler) if (pStyler)
{ {
@ -1705,10 +1675,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
case L_TEXT : case L_TEXT :
default : default :
if (typeDoc >= L_EXTERNAL && typeDoc < NppParameters::getInstance().L_END) setLexerFromID(SCLEX_NULL);
setExternalLexer(typeDoc);
else
setLexerFromID((_codepage == CP_CHINESE_TRADITIONAL) ? SCLEX_MAKEFILE : SCLEX_NULL);
break; break;
} }

View File

@ -541,7 +541,7 @@ public:
bool getIndicatorRange(size_t indicatorNumber, size_t* from = NULL, size_t* to = NULL, size_t* cur = NULL); bool getIndicatorRange(size_t indicatorNumber, size_t* from = NULL, size_t* to = NULL, size_t* cur = NULL);
static LanguageName langNames[L_EXTERNAL+1]; static LanguageName _langNames[L_END + 1];
void bufferUpdated(Buffer * buffer, int mask); void bufferUpdated(Buffer * buffer, int mask);
BufferID getCurrentBufferID() { return _currentBufferID; }; BufferID getCurrentBufferID() { return _currentBufferID; };
@ -609,6 +609,7 @@ public:
void setPositionRestoreNeeded(bool val) { _positionRestoreNeeded = val; }; void setPositionRestoreNeeded(bool val) { _positionRestoreNeeded = val; };
void markedTextToClipboard(int indiStyle, bool doAll = false); void markedTextToClipboard(int indiStyle, bool doAll = false);
void removeAnyDuplicateLines(); void removeAnyDuplicateLines();
bool setLexerFromID(int lexerID);
protected: protected:
static bool _SciInit; static bool _SciInit;
@ -650,7 +651,6 @@ protected:
const char * getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex); const char * getCompleteKeywordList(std::basic_string<char> & kwl, LangType langType, int keywordIndex);
void setKeywords(LangType langType, const char *keywords, int index); void setKeywords(LangType langType, const char *keywords, int index);
void setLexer(int lexerID, LangType langType, int whichList); void setLexer(int lexerID, LangType langType, int whichList);
bool setLexerFromID(int lexerID);
void makeStyle(LangType langType, const TCHAR **keywordArray = NULL); void makeStyle(LangType langType, const TCHAR **keywordArray = NULL);
void setStyle(Style styleToSet); //NOT by reference (style edited) void setStyle(Style styleToSet); //NOT by reference (style edited)
void setSpecialStyle(const Style & styleToSet); //by reference void setSpecialStyle(const Style & styleToSet); //by reference
@ -665,7 +665,6 @@ protected:
void setTclLexer(); void setTclLexer();
void setObjCLexer(LangType type); void setObjCLexer(LangType type);
void setUserLexer(const TCHAR *userLangName = NULL); void setUserLexer(const TCHAR *userLangName = NULL);
void setExternalLexer(LangType typeDoc);
void setEmbeddedJSLexer(); void setEmbeddedJSLexer();
void setEmbeddedPhpLexer(); void setEmbeddedPhpLexer();
void setEmbeddedAspLexer(); void setEmbeddedAspLexer();

View File

@ -23,7 +23,7 @@ using namespace std;
FunctionParsersManager::~FunctionParsersManager() FunctionParsersManager::~FunctionParsersManager()
{ {
for (size_t i = 0, len = L_EXTERNAL + nbMaxUserDefined; i < len; ++i) for (size_t i = 0, len = L_END + nbMaxUserDefined; i < len; ++i)
{ {
if (_parsers[i] != nullptr) if (_parsers[i] != nullptr)
delete _parsers[i]; delete _parsers[i];
@ -160,7 +160,7 @@ bool FunctionParsersManager::loadFuncListFromXmlTree(generic_string & xmlDirPath
index = lType; index = lType;
if (overrideId.empty()) if (overrideId.empty())
{ {
generic_string lexerName = ScintillaEditView::langNames[lType].lexerName; generic_string lexerName = ScintillaEditView::_langNames[lType].lexerName;
funcListRulePath += lexerName; funcListRulePath += lexerName;
funcListRulePath += TEXT(".xml"); funcListRulePath += TEXT(".xml");
} }
@ -281,7 +281,7 @@ bool FunctionParsersManager::getOverrideMapFromXmlTree(generic_string & xmlDirPa
} }
else if (userDefinedLangName && userDefinedLangName[0]) else if (userDefinedLangName && userDefinedLangName[0])
{ {
if (_currentUDIndex < L_EXTERNAL + nbMaxUserDefined) if (_currentUDIndex < L_END + nbMaxUserDefined)
{ {
++_currentUDIndex; ++_currentUDIndex;
_parsers[_currentUDIndex] = new ParserInfo(id, userDefinedLangName); _parsers[_currentUDIndex] = new ParserInfo(id, userDefinedLangName);
@ -343,10 +343,10 @@ FunctionParser * FunctionParsersManager::getParser(const AssociationInfo & assoI
case checkUserDefined: case checkUserDefined:
{ {
if (_currentUDIndex == L_EXTERNAL) // no User Defined Language parser if (_currentUDIndex == L_END) // no User Defined Language parser
return nullptr; return nullptr;
for (int i = L_EXTERNAL + 1; i <= _currentUDIndex; ++i) for (int i = L_END + 1; i <= _currentUDIndex; ++i)
{ {
if (_parsers[i]->_userDefinedLangName == assoInfo._userDefinedLangName) if (_parsers[i]->_userDefinedLangName == assoInfo._userDefinedLangName)
{ {

View File

@ -156,8 +156,8 @@ private:
generic_string _xmlDirPath; // The 1st place to load function list files. Usually it's "%APPDATA%\Notepad++\functionList\" generic_string _xmlDirPath; // The 1st place to load function list files. Usually it's "%APPDATA%\Notepad++\functionList\"
generic_string _xmlDirInstalledPath; // Where Notepad++ is installed. The 2nd place to load function list files. Usually it's "%PROGRAMFILES%\Notepad++\functionList\" generic_string _xmlDirInstalledPath; // Where Notepad++ is installed. The 2nd place to load function list files. Usually it's "%PROGRAMFILES%\Notepad++\functionList\"
ParserInfo* _parsers[L_EXTERNAL + nbMaxUserDefined] = {nullptr}; ParserInfo* _parsers[L_END + nbMaxUserDefined] = {nullptr};
int _currentUDIndex = L_EXTERNAL; int _currentUDIndex = L_END;
bool getOverrideMapFromXmlTree(generic_string & xmlDirPath); bool getOverrideMapFromXmlTree(generic_string & xmlDirPath);
bool loadFuncListFromXmlTree(generic_string & xmlDirPath, LangType lType, const generic_string& overrideId, int udlIndex = -1); bool loadFuncListFromXmlTree(generic_string & xmlDirPath, LangType lType, const generic_string& overrideId, int udlIndex = -1);

View File

@ -1933,7 +1933,7 @@ intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_OPENANSIASUTF8, BM_SETCHECK, (ID2Check == IDC_RADIO_UTF8SANSBOM && ndds._openAnsiAsUtf8)?BST_CHECKED:BST_UNCHECKED, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_OPENANSIASUTF8), ID2Check == IDC_RADIO_UTF8SANSBOM);
for (int i = L_TEXT + 1 ; i < nppParam.L_END ; ++i) // Skip L_TEXT for (int i = L_TEXT + 1 ; i < L_END ; ++i) // Skip L_TEXT
{ {
LangType lt = static_cast<LangType>(i); LangType lt = static_cast<LangType>(i);
str.clear(); str.clear();
@ -2372,7 +2372,7 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
// //
// Lang Menu // Lang Menu
// //
for (int i = L_TEXT ; i < nppParam.L_END ; ++i) for (int i = L_TEXT ; i < L_END ; ++i)
{ {
generic_string str; generic_string str;
if (static_cast<LangType>(i) != L_USER) if (static_cast<LangType>(i) != L_USER)
@ -2626,29 +2626,6 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE); ::EnableWindow(::GetDlgItem(_hSelf, idButton2Enable), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, idButton2Disable), FALSE);
if ((lmi._langType >= L_EXTERNAL) && (lmi._langType < nppParam.L_END))
{
bool found(false);
for (size_t x = 0; x < nppParam.getExternalLexerDoc()->size() && !found; ++x)
{
TiXmlNode *lexersRoot = nppParam.getExternalLexerDoc()->at(x)->FirstChild(TEXT("NotepadPlus"))->FirstChildElement(TEXT("LexerStyles"));
for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType"));
childNode ;
childNode = childNode->NextSibling(TEXT("LexerType")))
{
TiXmlElement *element = childNode->ToElement();
if (generic_string(element->Attribute(TEXT("name"))) == lmi._langName)
{
element->SetAttribute(TEXT("excluded"), (LOWORD(wParam)==IDC_BUTTON_REMOVE)?TEXT("yes"):TEXT("no"));
nppParam.getExternalLexerDoc()->at(x)->SaveFile();
found = true;
break;
}
}
}
}
HWND grandParent = ::GetParent(_hParent); HWND grandParent = ::GetParent(_hParent);
if (LOWORD(wParam)==IDC_BUTTON_REMOVE) if (LOWORD(wParam)==IDC_BUTTON_REMOVE)

View File

@ -526,8 +526,8 @@
#define IDM_LANG_VISUALPROLOG (IDM_LANG + 83) #define IDM_LANG_VISUALPROLOG (IDM_LANG + 83)
#define IDM_LANG_TYPESCRIPT (IDM_LANG + 84) #define IDM_LANG_TYPESCRIPT (IDM_LANG + 84)
#define IDM_LANG_EXTERNAL (IDM_LANG + 165) //#define IDM_LANG_EXTERNAL (IDM_LANG + 165)
#define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 179) //#define IDM_LANG_EXTERNAL_LIMIT (IDM_LANG + 179)
#define IDM_LANG_USER (IDM_LANG + 180) //46180: Used for translation #define IDM_LANG_USER (IDM_LANG + 180) //46180: Used for translation
#define IDM_LANG_USER_LIMIT (IDM_LANG + 210) //46210: Ajust with IDM_LANG_USER #define IDM_LANG_USER_LIMIT (IDM_LANG + 210) //46210: Ajust with IDM_LANG_USER

View File

@ -226,7 +226,7 @@ LangType getLangTypeFromParam(ParamVector & params)
{ {
generic_string langStr; generic_string langStr;
if (!getParamVal('l', params, langStr)) if (!getParamVal('l', params, langStr))
return L_EXTERNAL; return L_TEXT;
return NppParameters::getLangIDFromStr(langStr.c_str()); return NppParameters::getLangIDFromStr(langStr.c_str());
} }