diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index fb0c2b5b4..a41b50779 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -746,3 +746,8 @@ 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 + + #define NPPN_EXTERNALLEXERBUFFER (NPPN_FIRST + 29) // To notify lexer plugins that the buffer (in idFrom) is just applied to a external lexer + //scnNotification->nmhdr.code = NPPN_EXTERNALLEXERBUFFER; + //scnNotification->nmhdr.hwndFrom = hwndNpp; + //scnNotification->nmhdr.idFrom = BufferID; //where pluginMessage is pointer of type wchar_t diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 246920312..6380c4204 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -2132,6 +2132,18 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_EXTERNALLEXERBUFFER: + { + // A buffer is just applied to an external lexer, let's send a notification to lexer plugin + // so the concerning plugin can manage it (associate the buffer & lexer instance). + SCNotification scnN{}; + scnN.nmhdr.code = NPPN_EXTERNALLEXERBUFFER; + scnN.nmhdr.hwndFrom = hwnd; + scnN.nmhdr.idFrom = lParam; + _pluginsManager.notify(&scnN); + return TRUE; + } + case WM_QUERYENDSESSION: { // app should return TRUE or FALSE immediately upon receiving this message, diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index c7e66c7ec..32bc02776 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -902,6 +902,8 @@ void ScintillaEditView::setExternalLexer(LangType typeDoc) return; execute(SCI_SETILEXER, 0, reinterpret_cast(iLex5)); + ::SendMessage(_hParent, NPPM_INTERNAL_EXTERNALLEXERBUFFER, 0, (LPARAM)getCurrentBufferID()); + WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); const wchar_t* lexerNameW = wmc.char2wchar(externalLexer._name.c_str(), CP_ACP); LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerNameW); diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 7b1592d5a..b73238862 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -649,6 +649,7 @@ #define NPPM_INTERNAL_NPCFORMCHANGED (NOTEPADPLUS_USER_INTERNAL + 73) #define NPPM_INTERNAL_NPCLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 74) #define NPPM_INTERNAL_CLOSEDOC (NOTEPADPLUS_USER_INTERNAL + 75) + #define NPPM_INTERNAL_EXTERNALLEXERBUFFER (NOTEPADPLUS_USER_INTERNAL + 76) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000)