Add NPPM_CREATELEXER message for plugins to instantiate lexers

Fix #11789, close #11790
pull/11799/head
dail8859 2022-06-13 15:14:14 -04:00 committed by Don Ho
parent f69a9093f9
commit f1ed4de78d
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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<TCHAR*>(lParam), CP_ACP);
return (LRESULT) CreateLexer(lexer_name);
}
case WM_FRSAVE_INT:
{
_macro.push_back(recordedMacroStep(static_cast<int32_t>(wParam), 0, lParam, NULL, recordedMacroStep::mtSavedSnR));