From f1ed4de78dbe8f5d85f4d199bae2970148cca8ed Mon Sep 17 00:00:00 2001 From: dail8859 Date: Mon, 13 Jun 2022 15:14:14 -0400 Subject: [PATCH] Add NPPM_CREATELEXER message for plugins to instantiate lexers Fix #11789, close #11790 --- PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h | 4 +++- PowerEditor/src/NppBigSwitch.cpp | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 2cc9357b2..16210c189 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -540,6 +540,9 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; // Users should call it with commandLineStr as NULL to get the required number of TCHAR (not including the terminating nul character), // allocate commandLineStr buffer with the return value + 1, then call it again to get the current command line string. + #define NPPM_CREATELEXER (NPPMSG + 110) + // void* NPPN_CREATELEXER(0, const TCHAR *lexer_name) + // Returns the ILexer pointer created by Lexilla #define VAR_NOT_RECOGNIZED 0 #define FULL_CURRENT_PATH 1 @@ -734,4 +737,3 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; //scnNotification->nmhdr.code = NPPN_CMDLINEPLUGINMSG; //scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.idFrom = pluginMessage; //where pluginMessage is pointer of type wchar_t - diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 9102f348b..6f8869b06 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1386,6 +1386,13 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return cmdLineString.length(); } + case NPPM_CREATELEXER: + { + WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); + const char* lexer_name = wmc.wchar2char(reinterpret_cast(lParam), CP_ACP); + return (LRESULT) CreateLexer(lexer_name); + } + case WM_FRSAVE_INT: { _macro.push_back(recordedMacroStep(static_cast(wParam), 0, lParam, NULL, recordedMacroStep::mtSavedSnR));