Use string lexer ID instead of numeric ID for Scintilla 5

Plus some factoring.

Close #11472
This commit is contained in:
Don Ho 2022-04-04 04:34:56 +02:00
parent 121a396bf0
commit 2113e782fb
12 changed files with 222 additions and 217 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

@ -101,7 +101,7 @@ static WORD getBinaryArchitectureType(const TCHAR *filePath)
#define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000 #define LOAD_LIBRARY_SEARCH_DEFAULT_DIRS 0x00001000
#endif #endif
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath) int PluginsManager::loadPluginFromPath(const TCHAR *pluginFilePath)
{ {
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath); const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
if (isInLoadedDlls(pluginFileName)) if (isInLoadedDlls(pluginFileName))
@ -281,15 +281,17 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
} }
catch (generic_string& s) catch (generic_string& s)
{ {
if (pi && pi->_hLib)
{
::FreeLibrary(pi->_hLib);
}
s += TEXT("\n\n"); s += TEXT("\n\n");
s += pluginFileName; s += pluginFileName;
s += USERMSG; s += USERMSG;
if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES) if (::MessageBox(_nppData._nppHandle, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
{ {
if (pi && pi->_hLib)
{
::FreeLibrary(pi->_hLib);
}
::DeleteFile(pluginFilePath); ::DeleteFile(pluginFilePath);
} }
delete pi; delete pi;
@ -297,16 +299,17 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
} }
catch (...) catch (...)
{ {
if (pi && pi->_hLib)
{
::FreeLibrary(pi->_hLib);
}
generic_string msg = TEXT("Failed to load"); generic_string msg = TEXT("Failed to load");
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)
{
::FreeLibrary(pi->_hLib);
}
::DeleteFile(pluginFilePath); ::DeleteFile(pluginFilePath);
} }
delete pi; delete pi;
@ -314,7 +317,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath)
} }
} }
bool PluginsManager::loadPluginsV2(const TCHAR* dir, const PluginViewList* pluginUpdateInfoList) bool PluginsManager::loadPlugins(const TCHAR* dir, const PluginViewList* pluginUpdateInfoList)
{ {
if (_isDisabled) if (_isDisabled)
return false; return false;
@ -465,7 +468,7 @@ bool PluginsManager::loadPluginsV2(const TCHAR* dir, const PluginViewList* plugi
for (size_t i = 0, len = dllNames.size(); i < len; ++i) for (size_t i = 0, len = dllNames.size(); i < len; ++i)
{ {
loadPlugin(dllNames[i].c_str()); loadPluginFromPath(dllNames[i].c_str());
} }
return true; return true;

View File

@ -86,8 +86,7 @@ public:
_nppData = nppData; _nppData = nppData;
} }
int loadPlugin(const TCHAR *pluginFilePath); bool loadPlugins(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 loadPluginFromPath(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;

View File

@ -409,7 +409,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_pluginsManager.init(nppData); _pluginsManager.init(nppData);
bool enablePluginAdmin = _pluginsAdminDlg.initFromJson(); bool enablePluginAdmin = _pluginsAdminDlg.initFromJson();
_pluginsManager.loadPluginsV2(nppParam.getPluginRootDir(), enablePluginAdmin ? &_pluginsAdminDlg.getAvailablePluginUpdateInfoList() : nullptr); _pluginsManager.loadPlugins(nppParam.getPluginRootDir(), enablePluginAdmin ? &_pluginsAdminDlg.getAvailablePluginUpdateInfoList() : nullptr);
_restoreButton.init(_pPublicInterface->getHinst(), hwnd); _restoreButton.init(_pPublicInterface->getHinst(), hwnd);
// ------------ // // ------------ //
@ -2375,9 +2375,9 @@ generic_string Notepad_plus::getLangDesc(LangType langType, bool getName)
generic_string str2Show; generic_string str2Show;
if (getName) if (getName)
str2Show = ScintillaEditView::langNames[langType].shortName; str2Show = ScintillaEditView::_langNameInfoArray[langType]._shortName;
else else
str2Show = ScintillaEditView::langNames[langType].longName; str2Show = ScintillaEditView::_langNameInfoArray[langType]._longName;
if (langType == L_USER) if (langType == L_USER)
{ {
@ -4287,7 +4287,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::_langNameInfoArray[lt]._langName;
} }
command += TEXT(" -n"); command += TEXT(" -n");
command += to_wstring(_pEditView->getCurrentLineNumber() + 1); command += to_wstring(_pEditView->getCurrentLineNumber() + 1);

View File

@ -2875,7 +2875,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];
} }
@ -3959,7 +3959,7 @@ 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_EXTERNAL; ++lang)
{ {
const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; const TCHAR * name = ScintillaEditView::_langNameInfoArray[lang]._langName;
if (!lstrcmp(name, langName)) //found lang? if (!lstrcmp(name, langName)) //found lang?
{ {
return (LangType)lang; return (LangType)lang;

View File

@ -1077,6 +1077,6 @@ const TCHAR * AutoCompletion::getApiFileName()
if (_curLang == L_JAVASCRIPT) if (_curLang == L_JAVASCRIPT)
_curLang = L_JS; _curLang = L_JS;
return ScintillaEditView::langNames[_curLang].lexerName; return ScintillaEditView::_langNameInfoArray[_curLang]._langName;
} }

View File

@ -1447,11 +1447,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
if (fileFormat._language < L_EXTERNAL) if (fileFormat._language < L_EXTERNAL)
{ {
#pragma warning( push ) const char* lexerNameID = ScintillaEditView::_langNameInfoArray[fileFormat._language]._lexerID;
#pragma warning( disable : 4996) _pscratchTilla->execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(lexerNameID)));
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 else
{ {

View File

@ -18,8 +18,6 @@
#include <shlwapi.h> #include <shlwapi.h>
#include "FindReplaceDlg.h" #include "FindReplaceDlg.h"
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
#include <ILexer.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"
@ -554,7 +552,7 @@ void Finder::deleteResult()
auto end = _scintView.execute(SCI_GETLINEENDPOSITION, lno); auto end = _scintView.execute(SCI_GETLINEENDPOSITION, lno);
if (start + 2 >= end) return; // avoid empty lines if (start + 2 >= end) return; // avoid empty lines
_scintView.setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, LIST_NONE); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine() _scintView.setLexer(L_SEARCHRESULT, LIST_NONE); // Restore searchResult lexer in case the lexer was changed to SCLEX_NULL in GotoFoundLine()
if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) // delete a folder if (_scintView.execute(SCI_GETFOLDLEVEL, lno) & SC_FOLDLEVELHEADERFLAG) // delete a folder
{ {
@ -2314,7 +2312,11 @@ 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 +4313,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::_langNameInfoArray[L_SEARCHRESULT]._langName;
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pStyler) if (pStyler)
{ {

View File

@ -61,94 +61,97 @@ 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] = { LanguageNameInfo ScintillaEditView::_langNameInfoArray[L_EXTERNAL + 1] = {
{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}, // _langName _shortName _longName _langID _lexerID
{TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, SCLEX_CPP}, //
{TEXT("cpp"), TEXT("C++"), TEXT("C++ source file"), L_CPP, SCLEX_CPP}, {TEXT("normal"), TEXT("Normal text"), TEXT("Normal text file"), L_TEXT, "null"},
{TEXT("cs"), TEXT("C#"), TEXT("C# source file"), L_CS, SCLEX_CPP}, {TEXT("php"), TEXT("PHP"), TEXT("PHP Hypertext Preprocessor file"), L_PHP, "html"},
{TEXT("objc"), TEXT("Objective-C"), TEXT("Objective-C source file"), L_OBJC, SCLEX_OBJC}, {TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, "cpp"},
{TEXT("java"), TEXT("Java"), TEXT("Java source file"), L_JAVA, SCLEX_CPP}, {TEXT("cpp"), TEXT("C++"), TEXT("C++ source file"), L_CPP, "cpp"},
{TEXT("rc"), TEXT("RC"), TEXT("Windows Resource file"), L_RC, SCLEX_CPP}, {TEXT("cs"), TEXT("C#"), TEXT("C# source file"), L_CS, "cpp"},
{TEXT("html"), TEXT("HTML"), TEXT("Hyper Text Markup Language file"), L_HTML, SCLEX_HTML}, {TEXT("objc"), TEXT("Objective-C"), TEXT("Objective-C source file"), L_OBJC, "objc"},
{TEXT("xml"), TEXT("XML"), TEXT("eXtensible Markup Language file"), L_XML, SCLEX_XML}, {TEXT("java"), TEXT("Java"), TEXT("Java source file"), L_JAVA, "cpp"},
{TEXT("makefile"), TEXT("Makefile"), TEXT("Makefile"), L_MAKEFILE, SCLEX_MAKEFILE}, {TEXT("rc"), TEXT("RC"), TEXT("Windows Resource file"), L_RC, "cpp"},
{TEXT("pascal"), TEXT("Pascal"), TEXT("Pascal source file"), L_PASCAL, SCLEX_PASCAL}, {TEXT("html"), TEXT("HTML"), TEXT("Hyper Text Markup Language file"), L_HTML, "html"},
{TEXT("batch"), TEXT("Batch"), TEXT("Batch file"), L_BATCH, SCLEX_BATCH}, {TEXT("xml"), TEXT("XML"), TEXT("eXtensible Markup Language file"), L_XML, "xml"},
{TEXT("ini"), TEXT("ini"), TEXT("MS ini file"), L_INI, SCLEX_PROPERTIES}, {TEXT("makefile"), TEXT("Makefile"), TEXT("Makefile"), L_MAKEFILE, "makefile"},
{TEXT("nfo"), TEXT("NFO"), TEXT("MSDOS Style/ASCII Art"), L_ASCII, SCLEX_NULL}, {TEXT("pascal"), TEXT("Pascal"), TEXT("Pascal source file"), L_PASCAL, "pascal"},
{TEXT("udf"), TEXT("udf"), TEXT("User Defined language file"), L_USER, SCLEX_USER}, {TEXT("batch"), TEXT("Batch"), TEXT("Batch file"), L_BATCH, "batch"},
{TEXT("asp"), TEXT("ASP"), TEXT("Active Server Pages script file"), L_ASP, SCLEX_HTML}, {TEXT("ini"), TEXT("ini"), TEXT("MS ini file"), L_INI, "props"},
{TEXT("sql"), TEXT("SQL"), TEXT("Structured Query Language file"), L_SQL, SCLEX_SQL}, {TEXT("nfo"), TEXT("NFO"), TEXT("MSDOS Style/ASCII Art"), L_ASCII, "null"},
{TEXT("vb"), TEXT("Visual Basic"), TEXT("Visual Basic file"), L_VB, SCLEX_VB}, {TEXT("udf"), TEXT("udf"), TEXT("User Defined language file"), L_USER, "user"},
{TEXT("javascript"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JS, SCLEX_CPP}, {TEXT("asp"), TEXT("ASP"), TEXT("Active Server Pages script file"), L_ASP, "html"},
{TEXT("css"), TEXT("CSS"), TEXT("Cascade Style Sheets File"), L_CSS, SCLEX_CSS}, {TEXT("sql"), TEXT("SQL"), TEXT("Structured Query Language file"), L_SQL, "sql"},
{TEXT("perl"), TEXT("Perl"), TEXT("Perl source file"), L_PERL, SCLEX_PERL}, {TEXT("vb"), TEXT("Visual Basic"), TEXT("Visual Basic file"), L_VB, "vb"},
{TEXT("python"), TEXT("Python"), TEXT("Python file"), L_PYTHON, SCLEX_PYTHON}, {TEXT("javascript"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JS, "cpp"},
{TEXT("lua"), TEXT("Lua"), TEXT("Lua source File"), L_LUA, SCLEX_LUA}, {TEXT("css"), TEXT("CSS"), TEXT("Cascade Style Sheets File"), L_CSS, "css"},
{TEXT("tex"), TEXT("TeX"), TEXT("TeX file"), L_TEX, SCLEX_TEX}, {TEXT("perl"), TEXT("Perl"), TEXT("Perl source file"), L_PERL, "perl"},
{TEXT("fortran"), TEXT("Fortran free form"), TEXT("Fortran free form source file"), L_FORTRAN, SCLEX_FORTRAN}, {TEXT("python"), TEXT("Python"), TEXT("Python file"), L_PYTHON, "python"},
{TEXT("bash"), TEXT("Shell"), TEXT("Unix script file"), L_BASH, SCLEX_BASH}, {TEXT("lua"), TEXT("Lua"), TEXT("Lua source File"), L_LUA, "lua"},
{TEXT("actionscript"), TEXT("ActionScript"), TEXT("Flash ActionScript file"), L_FLASH, SCLEX_CPP}, {TEXT("tex"), TEXT("TeX"), TEXT("TeX file"), L_TEX, "tex"},
{TEXT("nsis"), TEXT("NSIS"), TEXT("Nullsoft Scriptable Install System script file"), L_NSIS, SCLEX_NSIS}, {TEXT("fortran"), TEXT("Fortran free form"), TEXT("Fortran free form source file"), L_FORTRAN, "fortran"},
{TEXT("tcl"), TEXT("TCL"), TEXT("Tool Command Language file"), L_TCL, SCLEX_TCL}, {TEXT("bash"), TEXT("Shell"), TEXT("Unix script file"), L_BASH, "bash"},
{TEXT("lisp"), TEXT("Lisp"), TEXT("List Processing language file"), L_LISP, SCLEX_LISP}, {TEXT("actionscript"), TEXT("ActionScript"), TEXT("Flash ActionScript file"), L_FLASH, "cpp"},
{TEXT("scheme"), TEXT("Scheme"), TEXT("Scheme file"), L_SCHEME, SCLEX_LISP}, {TEXT("nsis"), TEXT("NSIS"), TEXT("Nullsoft Scriptable Install System script file"), L_NSIS, "nsis"},
{TEXT("asm"), TEXT("Assembly"), TEXT("Assembly language source file"), L_ASM, SCLEX_ASM}, {TEXT("tcl"), TEXT("TCL"), TEXT("Tool Command Language file"), L_TCL, "tcl"},
{TEXT("diff"), TEXT("Diff"), TEXT("Diff file"), L_DIFF, SCLEX_DIFF}, {TEXT("lisp"), TEXT("Lisp"), TEXT("List Processing language file"), L_LISP, "lisp"},
{TEXT("props"), TEXT("Properties file"), TEXT("Properties file"), L_PROPS, SCLEX_PROPERTIES}, {TEXT("scheme"), TEXT("Scheme"), TEXT("Scheme file"), L_SCHEME, "lisp"},
{TEXT("postscript"), TEXT("PostScript"), TEXT("PostScript file"), L_PS, SCLEX_PS}, {TEXT("asm"), TEXT("Assembly"), TEXT("Assembly language source file"), L_ASM, "asm"},
{TEXT("ruby"), TEXT("Ruby"), TEXT("Ruby file"), L_RUBY, SCLEX_RUBY}, {TEXT("diff"), TEXT("Diff"), TEXT("Diff file"), L_DIFF, "diff"},
{TEXT("smalltalk"), TEXT("Smalltalk"), TEXT("Smalltalk file"), L_SMALLTALK, SCLEX_SMALLTALK}, {TEXT("props"), TEXT("Properties file"), TEXT("Properties file"), L_PROPS, "props"},
{TEXT("vhdl"), TEXT("VHDL"), TEXT("VHSIC Hardware Description Language file"), L_VHDL, SCLEX_VHDL}, {TEXT("postscript"), TEXT("PostScript"), TEXT("PostScript file"), L_PS, "ps"},
{TEXT("kix"), TEXT("KiXtart"), TEXT("KiXtart file"), L_KIX, SCLEX_KIX}, {TEXT("ruby"), TEXT("Ruby"), TEXT("Ruby file"), L_RUBY, "ruby"},
{TEXT("autoit"), TEXT("AutoIt"), TEXT("AutoIt"), L_AU3, SCLEX_AU3}, {TEXT("smalltalk"), TEXT("Smalltalk"), TEXT("Smalltalk file"), L_SMALLTALK, "smalltalk"},
{TEXT("caml"), TEXT("CAML"), TEXT("Categorical Abstract Machine Language"), L_CAML, SCLEX_CAML}, {TEXT("vhdl"), TEXT("VHDL"), TEXT("VHSIC Hardware Description Language file"), L_VHDL, "vhdl"},
{TEXT("ada"), TEXT("Ada"), TEXT("Ada file"), L_ADA, SCLEX_ADA}, {TEXT("kix"), TEXT("KiXtart"), TEXT("KiXtart file"), L_KIX, "kix"},
{TEXT("verilog"), TEXT("Verilog"), TEXT("Verilog file"), L_VERILOG, SCLEX_VERILOG}, {TEXT("autoit"), TEXT("AutoIt"), TEXT("AutoIt"), L_AU3, "au3"},
{TEXT("matlab"), TEXT("MATLAB"), TEXT("MATrix LABoratory"), L_MATLAB, SCLEX_MATLAB}, {TEXT("caml"), TEXT("CAML"), TEXT("Categorical Abstract Machine Language"), L_CAML, "caml"},
{TEXT("haskell"), TEXT("Haskell"), TEXT("Haskell"), L_HASKELL, SCLEX_HASKELL}, {TEXT("ada"), TEXT("Ada"), TEXT("Ada file"), L_ADA, "ada"},
{TEXT("inno"), TEXT("Inno Setup"), TEXT("Inno Setup script"), L_INNO, SCLEX_INNOSETUP}, {TEXT("verilog"), TEXT("Verilog"), TEXT("Verilog file"), L_VERILOG, "verilog"},
{TEXT("searchResult"), TEXT("Internal Search"), TEXT("Internal Search"), L_SEARCHRESULT, SCLEX_SEARCHRESULT}, {TEXT("matlab"), TEXT("MATLAB"), TEXT("MATrix LABoratory"), L_MATLAB, "matlab"},
{TEXT("cmake"), TEXT("CMake"), TEXT("CMake file"), L_CMAKE, SCLEX_CMAKE}, {TEXT("haskell"), TEXT("Haskell"), TEXT("Haskell"), L_HASKELL, "haskell"},
{TEXT("yaml"), TEXT("YAML"), TEXT("YAML Ain't Markup Language"), L_YAML, SCLEX_YAML}, {TEXT("inno"), TEXT("Inno Setup"), TEXT("Inno Setup script"), L_INNO, "inno"},
{TEXT("cobol"), TEXT("COBOL"), TEXT("COmmon Business Oriented Language"), L_COBOL, SCLEX_COBOL}, {TEXT("searchResult"), TEXT("Internal Search"), TEXT("Internal Search"), L_SEARCHRESULT, "searchResult"},
{TEXT("gui4cli"), TEXT("Gui4Cli"), TEXT("Gui4Cli file"), L_GUI4CLI, SCLEX_GUI4CLI}, {TEXT("cmake"), TEXT("CMake"), TEXT("CMake file"), L_CMAKE, "cmake"},
{TEXT("d"), TEXT("D"), TEXT("D programming language"), L_D, SCLEX_D}, {TEXT("yaml"), TEXT("YAML"), TEXT("YAML Ain't Markup Language"), L_YAML, "yaml"},
{TEXT("powershell"), TEXT("PowerShell"), TEXT("Windows PowerShell"), L_POWERSHELL, SCLEX_POWERSHELL}, {TEXT("cobol"), TEXT("COBOL"), TEXT("COmmon Business Oriented Language"), L_COBOL, "COBOL"},
{TEXT("r"), TEXT("R"), TEXT("R programming language"), L_R, SCLEX_R}, {TEXT("gui4cli"), TEXT("Gui4Cli"), TEXT("Gui4Cli file"), L_GUI4CLI, "gui4cli"},
{TEXT("jsp"), TEXT("JSP"), TEXT("JavaServer Pages script file"), L_JSP, SCLEX_HTML}, {TEXT("d"), TEXT("D"), TEXT("D programming language"), L_D, "d"},
{TEXT("coffeescript"), TEXT("CoffeeScript"), TEXT("CoffeeScript file"), L_COFFEESCRIPT, SCLEX_COFFEESCRIPT}, {TEXT("powershell"), TEXT("PowerShell"), TEXT("Windows PowerShell"), L_POWERSHELL, "powershell"},
{TEXT("json"), TEXT("json"), TEXT("JSON file"), L_JSON, SCLEX_JSON }, {TEXT("r"), TEXT("R"), TEXT("R programming language"), L_R, "r"},
{TEXT("javascript.js"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JAVASCRIPT, SCLEX_CPP }, {TEXT("jsp"), TEXT("JSP"), TEXT("JavaServer Pages script file"), L_JSP, "html"},
{TEXT("fortran77"), TEXT("Fortran fixed form"), TEXT("Fortran fixed form source file"), L_FORTRAN_77, SCLEX_F77}, {TEXT("coffeescript"), TEXT("CoffeeScript"), TEXT("CoffeeScript file"), L_COFFEESCRIPT, "coffeescript"},
{TEXT("baanc"), TEXT("BaanC"), TEXT("BaanC File"), L_BAANC, SCLEX_BAAN }, {TEXT("json"), TEXT("json"), TEXT("JSON file"), L_JSON, "json "},
{TEXT("srec"), TEXT("S-Record"), TEXT("Motorola S-Record binary data"), L_SREC, SCLEX_SREC}, {TEXT("javascript.js"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JAVASCRIPT, "cpp "},
{TEXT("ihex"), TEXT("Intel HEX"), TEXT("Intel HEX binary data"), L_IHEX, SCLEX_IHEX}, {TEXT("fortran77"), TEXT("Fortran fixed form"), TEXT("Fortran fixed form source file"), L_FORTRAN_77, "f77"},
{TEXT("tehex"), TEXT("Tektronix extended HEX"), TEXT("Tektronix extended HEX binary data"), L_TEHEX, SCLEX_TEHEX}, {TEXT("baanc"), TEXT("BaanC"), TEXT("BaanC File"), L_BAANC, "baan "},
{TEXT("swift"), TEXT("Swift"), TEXT("Swift file"), L_SWIFT, SCLEX_CPP}, {TEXT("srec"), TEXT("S-Record"), TEXT("Motorola S-Record binary data"), L_SREC, "srec"},
{TEXT("asn1"), TEXT("ASN.1"), TEXT("Abstract Syntax Notation One file"), L_ASN1, SCLEX_ASN1}, {TEXT("ihex"), TEXT("Intel HEX"), TEXT("Intel HEX binary data"), L_IHEX, "ihex"},
{TEXT("avs"), TEXT("AviSynth"), TEXT("AviSynth scripts files"), L_AVS, SCLEX_AVS}, {TEXT("tehex"), TEXT("Tektronix extended HEX"), TEXT("Tektronix extended HEX binary data"), L_TEHEX, "tehex"},
{TEXT("blitzbasic"), TEXT("BlitzBasic"), TEXT("BlitzBasic file"), L_BLITZBASIC, SCLEX_BLITZBASIC}, {TEXT("swift"), TEXT("Swift"), TEXT("Swift file"), L_SWIFT, "cpp"},
{TEXT("purebasic"), TEXT("PureBasic"), TEXT("PureBasic file"), L_PUREBASIC, SCLEX_PUREBASIC}, {TEXT("asn1"), TEXT("ASN.1"), TEXT("Abstract Syntax Notation One file"), L_ASN1, "asn1"},
{TEXT("freebasic"), TEXT("FreeBasic"), TEXT("FreeBasic file"), L_FREEBASIC, SCLEX_FREEBASIC}, {TEXT("avs"), TEXT("AviSynth"), TEXT("AviSynth scripts files"), L_AVS, "avs"},
{TEXT("csound"), TEXT("Csound"), TEXT("Csound file"), L_CSOUND, SCLEX_CSOUND}, {TEXT("blitzbasic"), TEXT("BlitzBasic"), TEXT("BlitzBasic file"), L_BLITZBASIC, "blitzbasic"},
{TEXT("erlang"), TEXT("Erlang"), TEXT("Erlang file"), L_ERLANG, SCLEX_ERLANG}, {TEXT("purebasic"), TEXT("PureBasic"), TEXT("PureBasic file"), L_PUREBASIC, "purebasic"},
{TEXT("escript"), TEXT("ESCRIPT"), TEXT("ESCRIPT file"), L_ESCRIPT, SCLEX_ESCRIPT}, {TEXT("freebasic"), TEXT("FreeBasic"), TEXT("FreeBasic file"), L_FREEBASIC, "freebasic"},
{TEXT("forth"), TEXT("Forth"), TEXT("Forth file"), L_FORTH, SCLEX_FORTH}, {TEXT("csound"), TEXT("Csound"), TEXT("Csound file"), L_CSOUND, "csound"},
{TEXT("latex"), TEXT("LaTeX"), TEXT("LaTeX file"), L_LATEX, SCLEX_LATEX}, {TEXT("erlang"), TEXT("Erlang"), TEXT("Erlang file"), L_ERLANG, "erlang"},
{TEXT("mmixal"), TEXT("MMIXAL"), TEXT("MMIXAL file"), L_MMIXAL, SCLEX_MMIXAL}, {TEXT("escript"), TEXT("ESCRIPT"), TEXT("ESCRIPT file"), L_ESCRIPT, "escript"},
{TEXT("nim"), TEXT("Nim"), TEXT("Nim file"), L_NIM, SCLEX_NIMROD}, {TEXT("forth"), TEXT("Forth"), TEXT("Forth file"), L_FORTH, "forth"},
{TEXT("nncrontab"), TEXT("Nncrontab"), TEXT("extended crontab file"), L_NNCRONTAB, SCLEX_NNCRONTAB}, {TEXT("latex"), TEXT("LaTeX"), TEXT("LaTeX file"), L_LATEX, "latex"},
{TEXT("oscript"), TEXT("OScript"), TEXT("OScript source file"), L_OSCRIPT, SCLEX_OSCRIPT}, {TEXT("mmixal"), TEXT("MMIXAL"), TEXT("MMIXAL file"), L_MMIXAL, "mmixal"},
{TEXT("rebol"), TEXT("REBOL"), TEXT("REBOL file"), L_REBOL, SCLEX_REBOL}, {TEXT("nim"), TEXT("Nim"), TEXT("Nim file"), L_NIM, "nimrod"},
{TEXT("registry"), TEXT("registry"), TEXT("registry file"), L_REGISTRY, SCLEX_REGISTRY}, {TEXT("nncrontab"), TEXT("Nncrontab"), TEXT("extended crontab file"), L_NNCRONTAB, "nncrontab"},
{TEXT("rust"), TEXT("Rust"), TEXT("Rust file"), L_RUST, SCLEX_RUST}, {TEXT("oscript"), TEXT("OScript"), TEXT("OScript source file"), L_OSCRIPT, "oscript"},
{TEXT("spice"), TEXT("Spice"), TEXT("spice file"), L_SPICE, SCLEX_SPICE}, {TEXT("rebol"), TEXT("REBOL"), TEXT("REBOL file"), L_REBOL, "rebol"},
{TEXT("txt2tags"), TEXT("txt2tags"), TEXT("txt2tags file"), L_TXT2TAGS, SCLEX_TXT2TAGS}, {TEXT("registry"), TEXT("registry"), TEXT("registry file"), L_REGISTRY, "registry"},
{TEXT("visualprolog"), TEXT("Visual Prolog"), TEXT("Visual Prolog file"), L_VISUALPROLOG, SCLEX_VISUALPROLOG}, {TEXT("rust"), TEXT("Rust"), TEXT("Rust file"), L_RUST, "rust"},
{TEXT("typescript"), TEXT("TypeScript"), TEXT("TypeScript file"), L_TYPESCRIPT, SCLEX_CPP}, {TEXT("spice"), TEXT("Spice"), TEXT("spice file"), L_SPICE, "spice"},
{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, SCLEX_NULL} {TEXT("txt2tags"), TEXT("txt2tags"), TEXT("txt2tags file"), L_TXT2TAGS, "txt2tags"},
{TEXT("visualprolog"), TEXT("Visual Prolog"), TEXT("Visual Prolog file"), L_VISUALPROLOG, "visualprolog"},
{TEXT("typescript"), TEXT("TypeScript"), TEXT("TypeScript file"), L_TYPESCRIPT, "cpp"},
{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, "null"}
}; };
//const int MASK_RED = 0xFF0000; //const int MASK_RED = 0xFF0000;
@ -630,9 +633,10 @@ void ScintillaEditView::setStyle(Style styleToSet)
void ScintillaEditView::setXmlLexer(LangType type) void ScintillaEditView::setXmlLexer(LangType type)
{ {
setLexerFromLangID(type);
if (type == L_XML) if (type == L_XML)
{ {
setLexerFromID(SCLEX_XML);
for (int i = 0 ; i < 4 ; ++i) for (int i = 0 ; i < 4 ; ++i)
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT(""))); execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT("")));
@ -642,7 +646,6 @@ void ScintillaEditView::setXmlLexer(LangType type)
} }
else if ((type == L_HTML) || (type == L_PHP) || (type == L_ASP) || (type == L_JSP)) else if ((type == L_HTML) || (type == L_PHP) || (type == L_ASP) || (type == L_JSP))
{ {
setLexerFromID(SCLEX_HTML);
const TCHAR *htmlKeyWords_generic = NppParameters::getInstance().getWordList(L_HTML, LANG_INDEX_INSTR); const TCHAR *htmlKeyWords_generic = NppParameters::getInstance().getWordList(L_HTML, LANG_INDEX_INSTR);
WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance();
@ -681,7 +684,7 @@ void ScintillaEditView::setEmbeddedJSLexer()
void ScintillaEditView::setJsonLexer() void ScintillaEditView::setJsonLexer()
{ {
setLexerFromID(SCLEX_JSON); setLexerFromLangID(L_JSON);
const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
@ -751,7 +754,7 @@ void ScintillaEditView::setEmbeddedAspLexer()
void ScintillaEditView::setUserLexer(const TCHAR *userLangName) void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
{ {
int setKeywordsCounter = 0; int setKeywordsCounter = 0;
setLexerFromID(SCLEX_USER); setLexerFromLangID(L_USER);
UserLangContainer * userLangContainer = userLangName? NppParameters::getInstance().getULCFromName(userLangName):_userDefineDlg._pCurrentUserLang; UserLangContainer * userLangContainer = userLangName? NppParameters::getInstance().getULCFromName(userLangName):_userDefineDlg._pCurrentUserLang;
@ -917,7 +920,7 @@ void ScintillaEditView::setCppLexer(LangType langType)
const char *cppTypes; const char *cppTypes;
const TCHAR *doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2); const TCHAR *doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2);
setLexerFromID(SCLEX_CPP); setLexerFromLangID(L_CPP);
if (langType != L_RC) if (langType != L_RC)
{ {
@ -967,7 +970,7 @@ void ScintillaEditView::setJsLexer()
{ {
const TCHAR *doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2); const TCHAR *doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2);
setLexerFromID(SCLEX_CPP); setLexerFromLangID(L_JAVASCRIPT);
const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; const TCHAR *pKwArray[10] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
makeStyle(L_JAVASCRIPT, pKwArray); makeStyle(L_JAVASCRIPT, pKwArray);
@ -978,7 +981,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::_langNameInfoArray[L_JAVASCRIPT]._langName;
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
{ {
@ -1018,7 +1021,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::_langNameInfoArray[L_JS]._langName;
LexerStyler *pOldStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pOldStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pOldStyler) if (pOldStyler)
@ -1081,7 +1084,7 @@ void ScintillaEditView::setTclLexer()
const char *tclTypes; const char *tclTypes;
setLexerFromID(SCLEX_TCL); setLexerFromLangID(L_TCL);
const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
makeStyle(L_TCL, pKwArray); makeStyle(L_TCL, pKwArray);
@ -1108,7 +1111,7 @@ void ScintillaEditView::setTclLexer()
void ScintillaEditView::setObjCLexer(LangType langType) void ScintillaEditView::setObjCLexer(LangType langType)
{ {
setLexerFromID(SCLEX_OBJC); setLexerFromLangID(L_OBJC);
const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
@ -1170,7 +1173,7 @@ void ScintillaEditView::setObjCLexer(LangType langType)
void ScintillaEditView::setTypeScriptLexer() void ScintillaEditView::setTypeScriptLexer()
{ {
const TCHAR* doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2); const TCHAR* doxygenKeyWords = NppParameters::getInstance().getWordList(L_CPP, LANG_INDEX_TYPE2);
setLexerFromID(SCLEX_CPP); setLexerFromLangID(L_TYPESCRIPT);
if (doxygenKeyWords) if (doxygenKeyWords)
{ {
@ -1219,9 +1222,9 @@ void ScintillaEditView::setKeywords(LangType langType, const char *keywords, int
execute(SCI_SETKEYWORDS, index, reinterpret_cast<LPARAM>(getCompleteKeywordList(wordList, langType, index))); execute(SCI_SETKEYWORDS, index, reinterpret_cast<LPARAM>(getCompleteKeywordList(wordList, langType, index)));
} }
void ScintillaEditView::setLexer(int lexerID, LangType langType, int whichList) void ScintillaEditView::setLexer(LangType langType, int whichList)
{ {
setLexerFromID(lexerID); setLexerFromLangID(langType);
const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
@ -1290,7 +1293,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::_langNameInfoArray[language]._langName;
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName); LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
if (pStyler) if (pStyler)
{ {
@ -1712,7 +1715,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
if (typeDoc >= L_EXTERNAL && typeDoc < NppParameters::getInstance().L_END) if (typeDoc >= L_EXTERNAL && typeDoc < NppParameters::getInstance().L_END)
setExternalLexer(typeDoc); setExternalLexer(typeDoc);
else else
setLexerFromID((_codepage == CP_CHINESE_TRADITIONAL) ? SCLEX_MAKEFILE : SCLEX_NULL); setLexerFromLangID(L_TEXT);
break; break;
} }
@ -1888,15 +1891,13 @@ void ScintillaEditView::styleChange()
restyleBuffer(); restyleBuffer();
} }
bool ScintillaEditView::setLexerFromID(int lexerID) bool ScintillaEditView::setLexerFromLangID(int langID) // Internal lexer only
{ {
#pragma warning( push ) if (langID >= L_EXTERNAL)
#pragma warning( disable : 4996)
const char* pName = LexerNameFromID(lexerID); //deprecated, therefore disabled warning
#pragma warning( pop )
if (!pName)
return false; return false;
execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(pName)));
const char* lexerNameID = _langNameInfoArray[langID]._lexerID;
execute(SCI_SETILEXER, 0, reinterpret_cast<LPARAM>(CreateLexer(lexerNameID)));
return true; return true;
} }

View File

@ -169,12 +169,12 @@ struct SortInPositionOrder {
typedef std::vector<ColumnModeInfo> ColumnModeInfos; typedef std::vector<ColumnModeInfo> ColumnModeInfos;
struct LanguageName { struct LanguageNameInfo {
const TCHAR * lexerName = nullptr; const TCHAR* _langName = nullptr;
const TCHAR * shortName = nullptr; const TCHAR* _shortName = nullptr;
const TCHAR * longName = nullptr; const TCHAR* _longName = nullptr;
LangType LangID = L_TEXT; LangType _langID = L_TEXT;
int lexerID = 0; const char* _lexerID = nullptr;
}; };
#define URL_INDIC 8 #define URL_INDIC 8
@ -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 LanguageNameInfo _langNameInfoArray[L_EXTERNAL+1];
void bufferUpdated(Buffer * buffer, int mask); void bufferUpdated(Buffer * buffer, int mask);
BufferID getCurrentBufferID() { return _currentBufferID; }; BufferID getCurrentBufferID() { return _currentBufferID; };
@ -649,8 +649,8 @@ protected:
void restyleBuffer(); void restyleBuffer();
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(LangType langID, int whichList);
bool setLexerFromID(int lexerID); bool setLexerFromLangID(int langID);
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
@ -674,176 +674,176 @@ protected:
//Simple lexers //Simple lexers
void setCssLexer() { void setCssLexer() {
setLexer(SCLEX_CSS, L_CSS, LIST_0 | LIST_1 | LIST_4 | LIST_6); setLexer(L_CSS, LIST_0 | LIST_1 | LIST_4 | LIST_6);
}; };
void setLuaLexer() { void setLuaLexer() {
setLexer(SCLEX_LUA, L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setMakefileLexer() { void setMakefileLexer() {
setLexer(SCLEX_MAKEFILE, L_MAKEFILE, LIST_NONE); setLexer(L_MAKEFILE, LIST_NONE);
}; };
void setIniLexer() { void setIniLexer() {
setLexer(SCLEX_PROPERTIES, L_INI, LIST_NONE); setLexer(L_INI, LIST_NONE);
execute(SCI_STYLESETEOLFILLED, SCE_PROPS_SECTION, true); execute(SCI_STYLESETEOLFILLED, SCE_PROPS_SECTION, true);
}; };
void setSqlLexer() { void setSqlLexer() {
const bool kbBackSlash = NppParameters::getInstance().getNppGUI()._backSlashIsEscapeCharacterForSql; const bool kbBackSlash = NppParameters::getInstance().getNppGUI()._backSlashIsEscapeCharacterForSql;
setLexer(SCLEX_SQL, L_SQL, LIST_0 | LIST_1 | LIST_4); setLexer(L_SQL, LIST_0 | LIST_1 | LIST_4);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("sql.backslash.escapes"), reinterpret_cast<LPARAM>(kbBackSlash ? "1" : "0")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("sql.backslash.escapes"), reinterpret_cast<LPARAM>(kbBackSlash ? "1" : "0"));
}; };
void setBashLexer() { void setBashLexer() {
setLexer(SCLEX_BASH, L_BASH, LIST_0); setLexer(L_BASH, LIST_0);
}; };
void setVBLexer() { void setVBLexer() {
setLexer(SCLEX_VB, L_VB, LIST_0); setLexer(L_VB, LIST_0);
}; };
void setPascalLexer() { void setPascalLexer() {
setLexer(SCLEX_PASCAL, L_PASCAL, LIST_0); setLexer(L_PASCAL, LIST_0);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
}; };
void setPerlLexer() { void setPerlLexer() {
setLexer(SCLEX_PERL, L_PERL, LIST_0); setLexer(L_PERL, LIST_0);
}; };
void setPythonLexer() { void setPythonLexer() {
setLexer(SCLEX_PYTHON, L_PYTHON, LIST_0 | LIST_1); setLexer(L_PYTHON, LIST_0 | LIST_1);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.quotes.python"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.quotes.python"), reinterpret_cast<LPARAM>("1"));
}; };
void setBatchLexer() { void setBatchLexer() {
setLexer(SCLEX_BATCH, L_BATCH, LIST_0); setLexer(L_BATCH, LIST_0);
}; };
void setTeXLexer() { void setTeXLexer() {
for (int i = 0 ; i < 4 ; ++i) for (int i = 0 ; i < 4 ; ++i)
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT(""))); execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT("")));
setLexer(SCLEX_TEX, L_TEX, LIST_NONE); setLexer(L_TEX, LIST_NONE);
}; };
void setNsisLexer() { void setNsisLexer() {
setLexer(SCLEX_NSIS, L_NSIS, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_NSIS, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setFortranLexer() { void setFortranLexer() {
setLexer(SCLEX_FORTRAN, L_FORTRAN, LIST_0 | LIST_1 | LIST_2); setLexer(L_FORTRAN, LIST_0 | LIST_1 | LIST_2);
}; };
void setFortran77Lexer() { void setFortran77Lexer() {
setLexer(SCLEX_F77, L_FORTRAN_77, LIST_0 | LIST_1 | LIST_2); setLexer(L_FORTRAN_77, LIST_0 | LIST_1 | LIST_2);
}; };
void setLispLexer(){ void setLispLexer(){
setLexer(SCLEX_LISP, L_LISP, LIST_0 | LIST_1); setLexer(L_LISP, LIST_0 | LIST_1);
}; };
void setSchemeLexer(){ void setSchemeLexer(){
setLexer(SCLEX_LISP, L_SCHEME, LIST_0 | LIST_1); setLexer(L_SCHEME, LIST_0 | LIST_1);
}; };
void setAsmLexer(){ void setAsmLexer(){
setLexer(SCLEX_ASM, L_ASM, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_ASM, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
}; };
void setDiffLexer(){ void setDiffLexer(){
setLexer(SCLEX_DIFF, L_DIFF, LIST_NONE); setLexer(L_DIFF, LIST_NONE);
}; };
void setPropsLexer(){ void setPropsLexer(){
setLexer(SCLEX_PROPERTIES, L_PROPS, LIST_NONE); setLexer(L_PROPS, LIST_NONE);
}; };
void setPostscriptLexer(){ void setPostscriptLexer(){
setLexer(SCLEX_PS, L_PS, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_PS, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setRubyLexer(){ void setRubyLexer(){
setLexer(SCLEX_RUBY, L_RUBY, LIST_0); setLexer(L_RUBY, LIST_0);
execute(SCI_STYLESETEOLFILLED, SCE_RB_POD, true); execute(SCI_STYLESETEOLFILLED, SCE_RB_POD, true);
}; };
void setSmalltalkLexer(){ void setSmalltalkLexer(){
setLexer(SCLEX_SMALLTALK, L_SMALLTALK, LIST_0); setLexer(L_SMALLTALK, LIST_0);
}; };
void setVhdlLexer(){ void setVhdlLexer(){
setLexer(SCLEX_VHDL, L_VHDL, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6); setLexer(L_VHDL, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
}; };
void setKixLexer(){ void setKixLexer(){
setLexer(SCLEX_KIX, L_KIX, LIST_0 | LIST_1 | LIST_2); setLexer(L_KIX, LIST_0 | LIST_1 | LIST_2);
}; };
void setAutoItLexer(){ void setAutoItLexer(){
setLexer(SCLEX_AU3, L_AU3, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6); setLexer(L_AU3, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
}; };
void setCamlLexer(){ void setCamlLexer(){
setLexer(SCLEX_CAML, L_CAML, LIST_0 | LIST_1 | LIST_2); setLexer(L_CAML, LIST_0 | LIST_1 | LIST_2);
}; };
void setAdaLexer(){ void setAdaLexer(){
setLexer(SCLEX_ADA, L_ADA, LIST_0); setLexer(L_ADA, LIST_0);
}; };
void setVerilogLexer(){ void setVerilogLexer(){
setLexer(SCLEX_VERILOG, L_VERILOG, LIST_0 | LIST_1); setLexer(L_VERILOG, LIST_0 | LIST_1);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
}; };
void setMatlabLexer(){ void setMatlabLexer(){
setLexer(SCLEX_MATLAB, L_MATLAB, LIST_0); setLexer(L_MATLAB, LIST_0);
}; };
void setHaskellLexer(){ void setHaskellLexer(){
setLexer(SCLEX_HASKELL, L_HASKELL, LIST_0); setLexer(L_HASKELL, LIST_0);
}; };
void setInnoLexer() { void setInnoLexer() {
setLexer(SCLEX_INNOSETUP, L_INNO, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_INNO, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
}; };
void setCmakeLexer() { void setCmakeLexer() {
setLexer(SCLEX_CMAKE, L_CMAKE, LIST_0 | LIST_1 | LIST_2); setLexer(L_CMAKE, LIST_0 | LIST_1 | LIST_2);
}; };
void setYamlLexer() { void setYamlLexer() {
setLexer(SCLEX_YAML, L_YAML, LIST_0); setLexer(L_YAML, LIST_0);
}; };
//-------------------- //--------------------
void setCobolLexer() { void setCobolLexer() {
setLexer(SCLEX_COBOL, L_COBOL, LIST_0 | LIST_1 | LIST_2); setLexer(L_COBOL, LIST_0 | LIST_1 | LIST_2);
}; };
void setGui4CliLexer() { void setGui4CliLexer() {
setLexer(SCLEX_GUI4CLI, L_GUI4CLI, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4); setLexer(L_GUI4CLI, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4);
}; };
void setDLexer() { void setDLexer() {
setLexer(SCLEX_D, L_D, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6); setLexer(L_D, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
}; };
void setPowerShellLexer() { void setPowerShellLexer() {
setLexer(SCLEX_POWERSHELL, L_POWERSHELL, LIST_0 | LIST_1 | LIST_2 | LIST_5); setLexer(L_POWERSHELL, LIST_0 | LIST_1 | LIST_2 | LIST_5);
}; };
void setRLexer() { void setRLexer() {
setLexer(SCLEX_R, L_R, LIST_0 | LIST_1 | LIST_2); setLexer(L_R, LIST_0 | LIST_1 | LIST_2);
}; };
void setCoffeeScriptLexer() { void setCoffeeScriptLexer() {
setLexer(SCLEX_COFFEESCRIPT, L_COFFEESCRIPT, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_COFFEESCRIPT, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setBaanCLexer() { void setBaanCLexer() {
setLexer(SCLEX_BAAN, L_BAANC, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6 | LIST_7 | LIST_8); setLexer(L_BAANC, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6 | LIST_7 | LIST_8);
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("lexer.baan.styling.within.preprocessor"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("lexer.baan.styling.within.preprocessor"), reinterpret_cast<LPARAM>("1"));
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$:")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$:"));
execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1")); execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("fold.preprocessor"), reinterpret_cast<LPARAM>("1"));
@ -855,102 +855,102 @@ protected:
}; };
void setSrecLexer() { void setSrecLexer() {
setLexer(SCLEX_SREC, L_SREC, LIST_NONE); setLexer(L_SREC, LIST_NONE);
}; };
void setIHexLexer() { void setIHexLexer() {
setLexer(SCLEX_IHEX, L_IHEX, LIST_NONE); setLexer(L_IHEX, LIST_NONE);
}; };
void setTEHexLexer() { void setTEHexLexer() {
setLexer(SCLEX_TEHEX, L_TEHEX, LIST_NONE); setLexer(L_TEHEX, LIST_NONE);
}; };
void setAsn1Lexer() { void setAsn1Lexer() {
setLexer(SCLEX_ASN1, L_ASN1, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_ASN1, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setAVSLexer() { void setAVSLexer() {
setLexer(SCLEX_AVS, L_AVS, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_AVS, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#"));
}; };
void setBlitzBasicLexer() { void setBlitzBasicLexer() {
setLexer(SCLEX_BLITZBASIC, L_BLITZBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_BLITZBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setPureBasicLexer() { void setPureBasicLexer() {
setLexer(SCLEX_PUREBASIC, L_PUREBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_PUREBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setFreeBasicLexer() { void setFreeBasicLexer() {
setLexer(SCLEX_FREEBASIC, L_FREEBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_FREEBASIC, LIST_0 | LIST_1 | LIST_2 | LIST_3);
}; };
void setCsoundLexer() { void setCsoundLexer() {
setLexer(SCLEX_CSOUND, L_CSOUND, LIST_0 | LIST_1 | LIST_2); setLexer(L_CSOUND, LIST_0 | LIST_1 | LIST_2);
execute(SCI_STYLESETEOLFILLED, SCE_CSOUND_STRINGEOL, true); execute(SCI_STYLESETEOLFILLED, SCE_CSOUND_STRINGEOL, true);
}; };
void setErlangLexer() { void setErlangLexer() {
setLexer(SCLEX_ERLANG, L_ERLANG, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_ERLANG, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
}; };
void setESCRIPTLexer() { void setESCRIPTLexer() {
setLexer(SCLEX_ESCRIPT, L_ESCRIPT, LIST_0 | LIST_1 | LIST_2); setLexer(L_ESCRIPT, LIST_0 | LIST_1 | LIST_2);
}; };
void setForthLexer() { void setForthLexer() {
setLexer(SCLEX_FORTH, L_FORTH, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_FORTH, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%-")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%-"));
}; };
void setLatexLexer() { void setLatexLexer() {
setLexer(SCLEX_LATEX, L_LATEX, LIST_NONE); setLexer(L_LATEX, LIST_NONE);
}; };
void setMMIXALLexer() { void setMMIXALLexer() {
setLexer(SCLEX_MMIXAL, L_MMIXAL, LIST_0 | LIST_1 | LIST_2); setLexer(L_MMIXAL, LIST_0 | LIST_1 | LIST_2);
}; };
void setNimrodLexer() { void setNimrodLexer() {
setLexer(SCLEX_NIMROD, L_NIM, LIST_0); setLexer(L_NIM, LIST_0);
}; };
void setNncrontabLexer() { void setNncrontabLexer() {
setLexer(SCLEX_NNCRONTAB, L_NNCRONTAB, LIST_0 | LIST_1 | LIST_2); setLexer(L_NNCRONTAB, LIST_0 | LIST_1 | LIST_2);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%-")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%-"));
}; };
void setOScriptLexer() { void setOScriptLexer() {
setLexer(SCLEX_OSCRIPT, L_OSCRIPT, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5); setLexer(L_OSCRIPT, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$"));
}; };
void setREBOLLexer() { void setREBOLLexer() {
setLexer(SCLEX_REBOL, L_REBOL, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6); setLexer(L_REBOL, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!.+-*&|=_~")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789?!.+-*&|=_~"));
}; };
void setRegistryLexer() { void setRegistryLexer() {
setLexer(SCLEX_REGISTRY, L_REGISTRY, LIST_NONE); setLexer(L_REGISTRY, LIST_NONE);
}; };
void setRustLexer() { void setRustLexer() {
setLexer(SCLEX_RUST, L_RUST, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6); setLexer(L_RUST, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6);
execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#")); execute(SCI_SETWORDCHARS, 0, reinterpret_cast<LPARAM>("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#"));
}; };
void setSpiceLexer() { void setSpiceLexer() {
setLexer(SCLEX_SPICE, L_SPICE, LIST_0 | LIST_1 | LIST_2); setLexer(L_SPICE, LIST_0 | LIST_1 | LIST_2);
}; };
void setTxt2tagsLexer() { void setTxt2tagsLexer() {
setLexer(SCLEX_TXT2TAGS, L_TXT2TAGS, LIST_NONE); setLexer(L_TXT2TAGS, LIST_NONE);
}; };
void setVisualPrologLexer() { void setVisualPrologLexer() {
setLexer(SCLEX_VISUALPROLOG, L_VISUALPROLOG, LIST_0 | LIST_1 | LIST_2 | LIST_3); setLexer(L_VISUALPROLOG, LIST_0 | LIST_1 | LIST_2 | LIST_3);
} }
//-------------------- //--------------------
@ -958,7 +958,7 @@ protected:
void setSearchResultLexer() { void setSearchResultLexer() {
execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_FILE_HEADER, true); execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_FILE_HEADER, true);
execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_SEARCH_HEADER, true); execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_SEARCH_HEADER, true);
setLexer(SCLEX_SEARCHRESULT, L_SEARCHRESULT, LIST_NONE); setLexer(L_SEARCHRESULT, LIST_NONE);
}; };
bool isNeededFolderMarge(LangType typeDoc) const { bool isNeededFolderMarge(LangType typeDoc) const {

View File

@ -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::_langNameInfoArray[lType]._langName;
funcListRulePath += lexerName; funcListRulePath += lexerName;
funcListRulePath += TEXT(".xml"); funcListRulePath += TEXT(".xml");
} }