From d888fb5f1263f5ea036c610b6980e5c4381ce7eb Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sat, 1 Feb 2025 07:26:25 +0100 Subject: [PATCH] Improve NPPM_ADDSCNMODIFIEDFLAGS API Improve NPPM_ADDSCNMODIFIEDFLAGS API so plugins can call it anytime for taking the effect immediately. Ref: https://community.notepad-plus-plus.org/topic/26595/new-api-to-fix-eventual-regression-regarding-scn_modified-for-some-plugins/9?_=1738384417702 --- PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h | 8 +++++--- PowerEditor/src/NppBigSwitch.cpp | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index e7a5c97ee..b1f772677 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -992,9 +992,11 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 }; #define NPPM_ADDSCNMODIFIEDFLAGS (NPPMSG + 117) // BOOL NPPM_ADDSCNMODIFIEDFLAGS(0, unsigned long scnMotifiedFlags2Add) - // Add needed SCN_MODIFIED flags so your plugin will recieve the notification SCN_MODIFIED of these events for your specific treatments. - // By default, Notepad++ only forwards SCN_MODIFIED with the following 5 flags/events SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO | SC_MOD_CHANGEINDICATOR to plugins. - // If your plugin need to process other events of SCN_MODIFIED, you should add the flags you need by sending this message to Notepad++, just after recieving NPPN_READY. + // Add the necessary SCN_MODIFIED flags so that your plugin will receive the SCN_MODIFIED notification for these events, enabling your specific treatments. + // By default, Notepad++ only forwards SCN_MODIFIED with the following 5 flags/events: + // SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO | SC_MOD_CHANGEINDICATOR to plugins. + // If your plugin needs to process other SCN_MODIFIED events, you should add the required flags by sending this message to Notepad++. You can send it immediately after receiving NPPN_READY, + // or only when your plugin needs to listen to specific events (to avoid penalizing Notepad++'s performance). Just ensure that the message is sent only once. // wParam: 0 (not used) // lParam[in]: scnMotifiedFlags2Add - Scintilla SCN_MODIFIED flags to add. // Return TRUE diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 336b42981..01c988afc 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -3795,6 +3795,10 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case NPPM_ADDSCNMODIFIEDFLAGS: { nppParam.addScintillaModEventMask(static_cast(lParam)); + + auto newModEventMask = nppParam.getScintillaModEventMask(); + _mainEditView.execute(SCI_SETMODEVENTMASK, newModEventMask); + _subEditView.execute(SCI_SETMODEVENTMASK, newModEventMask); return TRUE; }