Add NPPM_ADDSCNMODIFIEDFLAGS to fix regression for Plugins

Add **NPPM_ADDSCNMODIFIEDFLAGS** message for plugins which need the SCN_MODIFIED notification of other events.

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.
wParam: 0 (not used)
lParam[in]: scnMotifiedFlags2Add- Scintilla SCN_MODIFIED flags to add.
Return TRUE

Ref: https://community.notepad-plus-plus.org/topic/26588/notepad-v8-7-6-released/2?_=1738167940554

Fix #16121, close #16120
This commit is contained in:
Don Ho 2025-01-29 19:13:29 +01:00
parent 5f004411af
commit 6fd3830b42
9 changed files with 50 additions and 6 deletions

View File

@ -990,6 +990,33 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
// lParam[out]: language file name string receives all copied native language file name string
// Return the number of char copied/to copy
#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.
// wParam: 0 (not used)
// lParam[in]: scnMotifiedFlags2Add - Scintilla SCN_MODIFIED flags to add.
// Return TRUE
//
// Example:
//
// extern "C" __declspec(dllexport) void beNotified(SCNotification* notifyCode)
// {
// switch (notifyCode->nmhdr.code)
// {
// case NPPN_READY:
// {
// // Add SC_MOD_DELETETEXT and SC_MOD_INSERTTEXT notifications
// ::SendMessage(nppData._nppHandle, NPPM_ADDSCNMODIFIEDFLAGS, 0, SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT);
// }
// break;
// ...
// }
// ...
// }
// For RUNCOMMAND_USER
#define VAR_NOT_RECOGNIZED 0
#define FULL_CURRENT_PATH 1

View File

@ -3876,6 +3876,7 @@ void Notepad_plus::setLanguage(LangType langType)
//If so, release one document
bool reset = false;
Document prev = 0;
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
if (bothActive())
{
if (_mainEditView.getCurrentBufferID() == _subEditView.getCurrentBufferID())

View File

@ -3792,6 +3792,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return fileName.length();
}
case NPPM_ADDSCNMODIFIEDFLAGS:
{
nppParam.addScintillaModEventMask(static_cast<unsigned long>(lParam));
return TRUE;
}
case NPPM_INTERNAL_HILITECURRENTLINE:
{
const ScintillaViewParams& svp = nppParam.getSVP();

View File

@ -571,6 +571,7 @@ bool Notepad_plus::doReload(BufferID id, bool alert)
//an empty Document is inserted during reload if needed.
bool mainVisisble = (_mainEditView.getCurrentBufferID() == id);
bool subVisisble = (_subEditView.getCurrentBufferID() == id);
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
if (mainVisisble)
{
_mainEditView.saveCurrentPos();
@ -2482,6 +2483,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
//Force in the document so we can add the markers
//Don't use default methods because of performance
Document prevDoc = _mainEditView.execute(SCI_GETDOCPOINTER);
unsigned long MODEVENTMASK_ON = nppParam.getScintillaModEventMask();
_mainEditView.execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
_mainEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
_mainEditView.execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
@ -2617,6 +2619,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
//Force in the document so we can add the markers
//Don't use default methods because of performance
Document prevDoc = _subEditView.execute(SCI_GETDOCPOINTER);
unsigned long MODEVENTMASK_ON = nppParam.getScintillaModEventMask();
_subEditView.execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
_subEditView.execute(SCI_SETDOCPOINTER, 0, buf->getDocument());
_subEditView.execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);

View File

@ -1852,6 +1852,8 @@ public:
bool isStylerDocLoaded() const { return _pXmlUserStylerDoc != nullptr; };
ColumnEditorParam _columnEditParam;
unsigned long getScintillaModEventMask() const { return _sintillaModEventMask; };
void addScintillaModEventMask(unsigned long mask2Add) { _sintillaModEventMask |= mask2Add; };
private:
NppParameters();
@ -2100,5 +2102,5 @@ private:
int getCmdIdFromMenuEntryItemName(HMENU mainMenuHadle, const std::wstring& menuEntryName, const std::wstring& menuItemName); // return -1 if not found
int getPluginCmdIdFromMenuEntryItemName(HMENU pluginsMenu, const std::wstring& pluginName, const std::wstring& pluginCmdName); // return -1 if not found
winVer getWindowsVersion();
unsigned long _sintillaModEventMask = SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO | SC_MOD_CHANGEINDICATOR;
};

View File

@ -1391,6 +1391,7 @@ SavingStatus FileManager::saveBuffer(BufferID id, const wchar_t* filename, bool
if (isCopy) // "Save a Copy As..." command
{
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
_pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
_pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault);
_pscratchTilla->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);

View File

@ -112,6 +112,7 @@ intptr_t CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l
(*_ppEditView)->execute(SCI_GOTOPOS, posToGoto);
}
}
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
(*_ppEditView)->execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
SCNotification notification{};

View File

@ -253,7 +253,8 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
long hiddenLinesGreenWithAlpha = hiddenLinesGreen | 0xFF000000;
setElementColour(SC_ELEMENT_HIDDEN_LINE, hiddenLinesGreenWithAlpha);
if (NppParameters::getInstance()._dpiManager.scaleX(100) >= 150)
NppParameters& nppParams = NppParameters::getInstance();
if (nppParams._dpiManager.scaleX(100) >= 150)
{
execute(SCI_RGBAIMAGESETWIDTH, 18);
execute(SCI_RGBAIMAGESETHEIGHT, 18);
@ -311,7 +312,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_FOUND_STYLE_EXT4, true);
execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_FOUND_STYLE_EXT5, true);
NppGUI& nppGui = (NppParameters::getInstance()).getNppGUI();
NppGUI& nppGui = nppParams.getNppGUI();
HMODULE hNtdllModule = ::GetModuleHandle(L"ntdll.dll");
FARPROC isWINE = nullptr;
@ -347,6 +348,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere)
delete[] defaultCharList;
}
}
unsigned long MODEVENTMASK_ON = nppParams.getScintillaModEventMask();
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON);
//Get the startup document and make a buffer for it so it can be accessed like a file
attachDefaultDoc();
@ -382,6 +384,7 @@ LRESULT CALLBACK ScintillaEditView::scintillaStatic_Proc(HWND hwnd, UINT Message
return ::DefWindowProc(hwnd, Message, wParam, lParam);
}
LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch (Message)
@ -2301,6 +2304,7 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
const int currentLangInt = static_cast<int>(_currentBuffer->getLangType());
const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() != currentLangInt);
unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask();
if (isFirstActiveBuffer) // Entering the tab for the 1st time
{
// change the doc, this operation will decrease

View File

@ -93,8 +93,7 @@ const bool fold_uncollapse = true;
const bool fold_collapse = false;
#define MAX_FOLD_COLLAPSE_LEVEL 8
#define MODEVENTMASK_OFF 0
#define MODEVENTMASK_ON SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT | SC_PERFORMED_UNDO | SC_PERFORMED_REDO | SC_MOD_CHANGEINDICATOR
#define MODEVENTMASK_OFF 0
enum TextCase : UCHAR
{