Skip to content

Commit f660bb4

Browse files
committed
v8.7.7 NPPM_ADDSCNMODIFIEDFLAGS
1 parent 3cd4f8e commit f660bb4

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

content/docs/plugin-communication.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,50 @@ where:
8484

8585
---
8686

87+
#### [2117] **NPPM_ADDSCNMODIFIEDFLAGS**
88+
*Add needed `SCN_MODIFIED` flags so your plugin will recieve the notification `SCN_MODIFIED` of these events for your specific treatments. (New to v8.7.7.)*
89+
90+
*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.*
91+
*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.*
92+
*Even if your plugin only uses flags/events that are in those 5, it is recommended to notify Notepad++ of that need.*
93+
94+
**Parameters**:
95+
96+
*wParam [in]*
97+
: int, must be zero.
98+
99+
*lParam [in]*
100+
: unsigned long scnMotifiedFlags2Add, a bitwise-OR of the `SCN_MODIFIED` constants indicating which flags/events your plugin needs Notepad++ to forward.
101+
102+
**Return value**:
103+
: Returns True
104+
105+
**Example:**
106+
The following tells Notepad++ that your plugin needs the `SC_MOD_DELETETEXT` and `SC_MOD_INSERTTEXT` flags/events:
107+
```
108+
extern "C" __declspec(dllexport) void beNotified(SCNotification* notifyCode)
109+
{
110+
switch (notifyCode->nmhdr.code)
111+
{
112+
case NPPN_READY:
113+
{
114+
// Add SC_MOD_DELETETEXT and SC_MOD_INSERTTEXT notifications
115+
::SendMessage(nppData._nppHandle, NPPM_ADDSCNMODIFIEDFLAGS, 0, SC_MOD_DELETETEXT | SC_MOD_INSERTTEXT);
116+
}
117+
break;
118+
...
119+
}
120+
...
121+
}
122+
```
123+
124+
**Recommendation**:
125+
It is best practice to include _all_ flags/events that are needed by your plugin, even if they are in the list of default flags (like the `SC_MOD_DELETETEXT` and `SC_MOD_INSERTTEXT` are in the example), as this clearly communicates to Notepad++ the needs of your plugin. (It is possible, in the future, that the list of default flags/events will be changed, or that Notepad++ may be able to provide more performance optimizations if plugins indicate all the flags/events that they need.)
126+
127+
---
128+
87129
#### [2065] **NPPM_ADDTOOLBARICON** [DEPRECATED]
88-
*Deprecated in v8.0. Use NPPM_ADDTOOLBARICON_FORDARKMODE instead. Does not support
89-
the Darkmode icons.*
130+
*Deprecated in v8.0. Use NPPM_ADDTOOLBARICON_FORDARKMODE instead. Does not support the Darkmode icons.*
90131

91132
*`NPPM_ADDTOOLBARICON_DEPRECATED`: Adds an icon to the toolbar.
92133
This function only makes sense if called on response to NPPN_TBMODIFICATION notification.
@@ -1211,7 +1252,8 @@ MAX_PATH is suggested to use.*
12111252

12121253
#### [2140] **NPPM_GETNATIVELANGFILENAME**
12131254
*Get the Current native language file name string. Use it after getting NPPN_READY notification to find out which native language is used.*
1214-
Users should call it with nativeLangFileName as NULL to get the required number of char (not including the terminating nul character), allocate language file name string buffer with the return value + 1, then call it again to get the current native language file name string.*
1255+
1256+
*Users should call it with nativeLangFileName as NULL to get the required number of char (not including the terminating nul character), allocate language file name string buffer with the return value + 1, then call it again to get the current native language file name string.*
12151257

12161258
**Parameters**:
12171259

0 commit comments

Comments
 (0)