Plugin Communication: Messages and Notifications
- Plugin Communication: Messages and Notifications
- Notepad++ messages
- Message Key
- [2052] NPPM_ACTIVATEDOC
- [2141] NPPM_ADDSCNMODIFIEDFLAGS
- [2065] NPPM_ADDTOOLBARICON [DEPRECATED]
- [2125] NPPM_ADDTOOLBARICON_FORDARKMODE
- [2105] NPPM_ALLOCATECMDID
- [2137] NPPM_ALLOCATEINDICATOR
- [2106] NPPM_ALLOCATEMARKER
- [2104] NPPM_ALLOCATESUPPORTED [DEPRECATED]
- [2134] NPPM_CREATELEXER
- [2044] NPPM_CREATESCINTILLAHANDLE
- [2136] NPPM_DARKMODESUBCLASSANDTHEME
- [2051] NPPM_DECODESCI
- [2045] NPPM_DESTROYSCINTILLAHANDLE [DEPRECATED]
- [2119] NPPM_DISABLEAUTOUPDATE
- [2067] NPPM_DMMGETPLUGINHWNDBYNAME
- [2055] NPPM_DMMHIDE
- [2057] NPPM_DMMREGASDCKDLG
- [2054] NPPM_DMMSHOW
- [2056] NPPM_DMMUPDATEDISPINFO
- [2059] NPPM_DMMVIEWOTHERTAB
- [2113] NPPM_DOCLISTDISABLEEXTCOLUMN
- [2126] NPPM_DOCLISTDISABLEPATHCOLUMN
- [2101] NPPM_DOOPEN
- [2050] NPPM_ENCODESCI
- [2111] NPPM_GETAPPDATAPLUGINSALLOWED
- [2135] NPPM_GETBOOKMARKID
- [2090] NPPM_GETBUFFERENCODING
- [2092] NPPM_GETBUFFERFORMAT
- [2083] NPPM_GETBUFFERIDFROMPOS
- [2088] NPPM_GETBUFFERLANGTYPE
- [2084] NPPM_GETCURRENTBUFFERID
- [2133] NPPM_GETCURRENTCMDLINE
- [4033] NPPM_GETCURRENTCOLUMN
- [4026] NPPM_GETCURRENTDIRECTORY
- [2047] NPPM_GETCURRENTDOCINDEX
- [2029] NPPM_GETCURRENTLANGTYPE
- [4032] NPPM_GETCURRENTLINE
- [4036] NPPM_GETCURRENTLINESTR
- [2130] NPPM_GETCURRENTMACROSTATUS
- [2103] NPPM_GETCURRENTNATIVELANGENCODING
- [2028] NPPM_GETCURRENTSCINTILLA
- [2112] NPPM_GETCURRENTVIEW
- [4030] NPPM_GETCURRENTWORD
- [2132] NPPM_GETDARKMODECOLORS
- [2115] NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR
- [2114] NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
- [2069] NPPM_GETENABLETHEMETEXTUREFUNC [DEPRECATED]
- [2127] NPPM_GETEXTERNALLEXERAUTOINDENTMODE
- [4029] NPPM_GETEXTPART
- [2142] NPPM_GETTOOLBARICONSETCHOICE
- [4027] NPPM_GETFILENAME
- [4035] NPPM_GETFILENAMEATCURSOR
- [4025] NPPM_GETFULLCURRENTPATH
- [2082] NPPM_GETFULLPATHFROMBUFFERID
- [2108] NPPM_GETLANGUAGEDESC
- [2107] NPPM_GETLANGUAGENAME
- [2124] NPPM_GETLINENUMBERWIDTHMODE
- [2049] NPPM_GETMENUHANDLE
- [4028] NPPM_GETNAMEPART
- [2140] NPPM_GETNATIVELANGFILENAME
- [2031] NPPM_GETNBOPENFILES
- [2037] NPPM_GETNBSESSIONFILES
- [2046] NPPM_GETNBUSERLANG
- [4031] NPPM_GETNPPDIRECTORY
- [4034] NPPM_GETNPPFULLFILEPATH
- [2074] NPPM_GETNPPVERSION
- [2032] NPPM_GETOPENFILENAMES [DEPRECATED]
- [2041] NPPM_GETOPENFILENAMESPRIMARY [DEPRECATED]
- [2042] NPPM_GETOPENFILENAMESSECOND [DEPRECATED]
- [2121] NPPM_GETPLUGINHOMEPATH
- [2070] NPPM_GETPLUGINSCONFIGDIR
- [2081] NPPM_GETPOSFROMBUFFERID
- [2143] NPPM_GETNPPSETTINGSDIRPATH
- [2122] NPPM_GETSETTINGSONCLOUDPATH
- Notepad++ messages
Notepad++ messages
To send a message to Notepad++ you send its window handle together with the message ID, and two parameters, known as wParam and lParam. The values placed in those two parameters depend on the message, and are explained below. In cases when either wParam, lParam or both are not used, they must be set to 0.
The message IDs for each of these named messages, as well as the enums used with these messages, can be found in the source code in .
Aside: interpreting #defines
If you are writing your plugin in C++ or similar languages, you should just include the Notepad_plus_msgs.h to get all the constants; but if you are using a different language for your plugin or other message-interface, you will need to translate those #define statements to constants or values appropriate to your language.
When reading the #define for the various NPPM_ constants, you need to notice that NPPMSG is defined as (WM_USER + 1000) near the top of the file, and you need to know that WM_USER is the Windows standard constant with a value of 0x0400 (1024). You may need to look up other #define values from elsewhere in the header file in order to fully resolve some of the values. For example, #define NPPM_SAVEALLFILES (NPPMSG + 39) is really the integer 1024 + 1000 + 39 = 2063, so that is the value you need to use when defining your version of the NPPM_SAVEALLFILES constant.
Aside: Internal Messages
Note: Notepad++ header files other than Notepad_plus_msgs.h may define constants for internal messages, indicated by NPPM_INTERNAL_xxx. If you are able to find such messages and understand how to use them, there is no way for Notepad++ to prevent you from doing so; however, using internal messages is done at your own risk. Such internal messages are not part of the official plugin interface, are not publically documented, and can change behavior or even be completely removed, without any documentation or announcement; this could cause your plugin to crash Notepad++, and the Notepad++ developer is likely to add your plugin to the “Disabled” list if he gets complaints of crashes that are caused by your plugin. If you find there’s an NPPM_INTERNAL message that you would like to use in your plugin, it is highly recommended that you put in an issue to request that the message be added to the public interface, and wait until it is public before trying to use that message.
You can also communicate to the Scintilla editor instances inside Notepad++ by using the Scintilla messages, which are documented at the Scintilla website, and the values can be found in and/or . Note, you need to use one of the two Scintilla handles as the first parameter to SendMessage api function.
Message Key
The general layout of the following messages look like this
[ID Number] MESSAGE NAME
Description
Parameters:
wParam [in/out]
lParam [in/out]
Return value:
where:
- [ID Number] is the integer value of the Notepad++ message
- MESSAGE NAME is the name of the Notepad++ message constant (like
NPPM_ACTIVATEDOC). - Description informs about the usage of the message and provides additional information if needed.
- Parameters called wParam and lParam are to be provided as the arguments to the notification.
- [in/out] indicates whether this is an input or output Parameter. In the case of an output Parameter, Notepad++ will copy some information into the buffer provided as that Parameter
- Return value is the value returned by the SendMessage api call.
[2052] NPPM_ACTIVATEDOC
Switches to the document by the given viewIndex and docIndex.
Parameters:
wParam [in] : int viewIndex, which must be either 0 (main view) or 1 (secondary view).
lParam [in] : int docIndex, a 0-based index which indicates which document to activate from the selected view’s list of documents.
Return value: : Returns True
[2141] NPPM_ADDSCNMODIFIEDFLAGS
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.
Even if your plugin only uses flags/events that are in those 5, it is recommended to notify Notepad++ of that need.
Parameters:
wParam [in] : int, must be zero.
lParam [in]
: unsigned long scnMotifiedFlags2Add, a bitwise-OR of the SCN_MODIFIED constants indicating which flags/events your plugin needs Notepad++ to forward.
Return value: : Returns True
Example:
The following tells Notepad++ that your plugin needs the SC_MOD_DELETETEXT and SC_MOD_INSERTTEXT flags/events:
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;
...
}
...
}
Recommendation:
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.)
[2065] NPPM_ADDTOOLBARICON [DEPRECATED]
Deprecated in v8.0. Use NPPM_ADDTOOLBARICON_FORDARKMODE instead. Does not support the Darkmode icons.
NPPM_ADDTOOLBARICON_DEPRECATED: Adds an icon to the toolbar.
This function only makes sense if called on response to NPPN_TBMODIFICATION notification.
cmdID must be a command function id which the plugin registered via getFuncsArray previously.
icon is a pointer to the toolbarIcons structure.
Parameters:
wParam [in] : INT cmdID
lParam [in] : toolbarIcons* icon
struct toolbarIconsWithDarkMode {
HBITMAP hToolbarBmp;
HICON hToolbarIcon;
};
Return value: : Returns True
Notes: data structure source
[2125] NPPM_ADDTOOLBARICON_FORDARKMODE
Adds an icon to the toolbar. This function only makes sense if called on response to NPPN_TBMODIFICATION notification. cmdID must be a command function id which the plugin registered via getFuncsArray previously. icon is a pointer to the toolbarIconsWithDarkMode structure.
Parameters:
wParam [in] : INT cmdID
lParam [in] : toolbarIconsWithDarkMode* icon
struct toolbarIconsWithDarkMode {
HBITMAP hToolbarBmp;
HICON hToolbarIcon;
HICON hToolbarIconDarkMode;
};
Return value: : Returns True
Notes: data structure source
[2105] NPPM_ALLOCATECMDID
Obtains a number of consecutive menu item IDs for creating menus dynamically, with the guarantee of these IDs not clashing with any other plugins.
Parameters:
wParam [in] : int, requested number of IDs.
lParam [out] : int, pointer to allocated range.
Return value: : Returns 0 on failure, nonzero on success
Examples: If a plugin needs 4 menu item ID, the following code can be used:
int idBegin;
BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATECMDID, 4, &idBegin);
if isAllocatedSuccessful is TRUE, and value of idBegin is 46581 then menu iten ID 46581, 46582, 46583 and 46584 are preserved by Notepad++, and they are safe to be used by the plugin.
[2137] NPPM_ALLOCATEINDICATOR
Obtains a number of consecutive indicator IDs dynamically, with the guarantee of these IDs not clashing with Notepad++'s own internal indicator usage, nor usage by any other plugins that use this API to allocate their needed indicators.
Parameters:
wParam [in] : int, numberOfIndicators.
lParam [out] : int, pointer to firstIndicatorID.
Return value : Returns 0 on failure, nonzero on success
Other information
: If successful, (*firstIndicatorID)+0 thru (*firstIndicatorID)+numberOfIndicators-1 are the indicator numbers that have been set as reserved for use by the caller.
Examples: If a plugin needs 1 indicator ID, the following code can be used:
int idBegin;
BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATEINDICATOR, 1, &idBegin);
if isAllocatedSuccessful is TRUE, and value of idBegin is 7 then indicator ID 7 is preserved by Notepad++, and it is safe to be used by the plugin.
[2106] NPPM_ALLOCATEMARKER
Obtains a number of consecutive marker IDs dynamically, with the guarantee of these IDs not clashing with any other plugins.
Parameters:
wParam [in] : int numberOfMarkers
lParam [out] : int * firstMarkerID
Return value: : Returns 0 on failure, nonzero on success. firstMarkerID will also be set to 0 if unsuccessful
Examples: If a plugin needs 3 marker ID, the following code can be used:
int idBegin;
BOOL isAllocatedSuccessful = ::SendMessage(nppData._nppHandle, NPPM_ALLOCATEMARKER, 3, &idBegin);
if isAllocatedSuccessful is TRUE, and value of idBegin is 16 then marker ID 16, 17 and 18 are preserved by Notepad++, and they are safe to be used by the plugin.
[2104] NPPM_ALLOCATESUPPORTED [DEPRECATED]
Deprecated in v8.6.2: the message has been made (since 2010 AD) for checking if NPPM_ALLOCATECMDID is supported. This message is no more needed.
NPPM_ALLOCATESUPPORTED_DEPRECATED return True to indicate NPPM_ALLOCATECMDID is supported.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns True always
[2134] NPPM_CREATELEXER
Returns the ILexer pointer created by Lexilla.
Calls the lexilla CreateLexer() function; allows plugins
to set the lexer for a Scintilla instance created by
NPPM_CREATESCINTILLAHANDLE
Parameters:
wParam [in] : int, must be zero.
lParam [in] : const wchar_t * lexer_name, the name of the lexer
Return value: : Returns the ILexer pointer created by Lexilla.
[2044] NPPM_CREATESCINTILLAHANDLE
A plugin can create a Scintilla for its usage by sending this message to Notepad++.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : HWND pluginWindowHandle, If set (non NULL), it will be the parent window of this created Scintilla handle, otherwise the parent window is Notepad++.
Return value: : Returns the created Scintilla handle.
[2136] NPPM_DARKMODESUBCLASSANDTHEME
Add support for generic dark mode.
Parameters:
wParam [in]
: ULONG dmFlags : values in namespace NppDarkMode (below)
lParam [in] : HWND pluginWindowHandle,
Return value: : Returns succesful combinations of flags.
Other information:
dmFlagsvalues inNppDarkModenamespace:
``` namespace NppDarkMode
{
// Standard flags for main parent after its children are initialized.
constexpr ULONG dmfInit = 0x0000000BUL;
// Standard flags for main parent usually used in NPPN_DARKMODECHANGED.
constexpr ULONG dmfHandleChange = 0x0000000CUL;
};
``` - Docking panels don’t need to call NPPM_DARKMODESUBCLASSANDTHEME for main hwnd. - Subclassing is applied automatically unless DWS_USEOWNDARKMODE flag is used. - Might not work properly in C# plugins. - It is important for the message to be sent after controls are initialized, otherwise it may not affect all controls correctly.
Examples:
- after controls initializations in WM_INITDIALOG, in WM_CREATE or after CreateWindow:
```
auto success = static_cast
``` - handling dark mode change:
``` extern "C" __declspec(dllexport) void beNotified(SCNotification * notifyCode)
switch (notifyCode->nmhdr.code)
{
case NPPN_DARKMODECHANGED:
{
::SendMessage(nppData._nppHandle, NPPM_DARKMODESUBCLASSANDTHEME, static_cast<WPARAM>(dmfHandleChange), reinterpret_cast<LPARAM>(mainHwnd));
::SetWindowPos(mainHwnd, nullptr, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // to redraw titlebar and window
break;
}
}
```
[2051] NPPM_DECODESCI
Changes current buffer view to ansi. view must be either 0 = main view or 1 = second view.
Parameters:
wParam [in] : INT view
lParam [in] : int, must be zero.
Return value: : Returns The new encoding mode.
[2045] NPPM_DESTROYSCINTILLAHANDLE [DEPRECATED]
Deprecated in v8.6.2: this message returns TRUE but does nothing. It is kept for the compatibility. Notepad++ will deallocate every createed Scintilla control on exit
NPPM_DESTROYSCINTILLAHANDLE_DEPRECATED is called to destroy a Scintilla handle.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : HWND scintillaHandle2Destroy
Return value: : Returns True
[2119] NPPM_DISABLEAUTOUPDATE
Disables the auto update functionality of Notepad++.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns True
[2067] NPPM_DMMGETPLUGINHWNDBYNAME
Retrieves the dialog handle corresponds to the windowName and moduleName. You may need this message if you want to communicate with another plugin “dockable” dialog.
Parameters:
wParam [in] : const wchar_t * windowName
lParam [in] : const wchar_t * moduleName
Return value: : Returns NULL if moduleName is NULL. If windowName is NULL, then the first found window handle which matches with the moduleName will be returned
[2055] NPPM_DMMHIDE
Hides the dialog which was previously regeistered by NPPM_DMMREGASDCKDLG.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : HWND hDlg, is the handle of your dialog which should be hidden.
Return value: : Returns True
[2057] NPPM_DMMREGASDCKDLG
From v4.0, Notepad++ supports the dockable dialog feature for the plugins. Pass the necessary dockingData to Notepad++ in order to make your dialog dockable. Minimum informations which needs to be filled out are hClient, pszName, dlgID, uMask and pszModuleName. Notice that rcFloat and iPrevCont shouldn’t be filled. They are used internally
Parameters:
wParam [in] : int, must be zero.
lParam [in] : tTbData * dockingData
typedef struct {
HWND hClient; // client Window Handle
const wchar_t *pszName; // name of plugin (shown in window)
int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID
// user modifications
UINT uMask; // mask params: look to above defines
HICON hIconTab; // icon for tabs
const wchar_t *pszAddInfo; // for plugin to display additional informations
// internal data, do not use !!!
RECT rcFloat; // floating position
int iPrevCont; // stores the privious container (toggling between float and dock)
const wchar_t* pszModuleName; // it's the plugin file name. It's used to identify the plugin
} tTbData;
Return value: : Returns True
Notes: data structure source
[2054] NPPM_DMMSHOW
Shows the dialog which was previously regeistered by NPPM_DMMREGASDCKDLG.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : HWND hDlg, is the handle of your dialog which should be shown.
Return value: : Returns True
[2056] NPPM_DMMUPDATEDISPINFO
Updates (redraw) the dialog.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : HWND hDlg, is the handle of the dialog which should be updated.
Return value: : Returns True
[2059] NPPM_DMMVIEWOTHERTAB
Shows the plugin dialog with the given name. name should be the same value as previously used to register the dialog.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : wchar_t* name
Return value: : Returns True
[2113] NPPM_DOCLISTDISABLEEXTCOLUMN
Sets the extension column in Document List panel. If disableOrNot is True, extension column is hidden otherwise it is visible.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : BOOL disableOrNot
Return value: : Returns True
[2126] NPPM_DOCLISTDISABLEPATHCOLUMN
Sets the path column in Document List panel. If disableOrNot is True, path column is hidden otherwise it is visible.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : BOOL disableOrNot
Return value: : Returns True
[2101] NPPM_DOOPEN
Switches or openes a file with given fullPathName2Open.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : wchar_t * fullPathName2Open
Return value: : Returns The return value is True (1) if the operation is successful, otherwise False (0).
[2050] NPPM_ENCODESCI
Changes current buffer view to utf8. view must be either 0 = main view or 1 = second view.
Parameters:
wParam [in] : INT view
lParam [in] : int, must be zero.
Return value: : Returns The new encoding mode.
[2111] NPPM_GETAPPDATAPLUGINSALLOWED
Retrieves the information whether plugins are loadable from %APPDATA%.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns True if loading plugins from %APPDATA% is allowed, False otherwise
[2135] NPPM_GETBOOKMARKID
Returns the bookmark marker ID. This allows plugins to choose an ID different from the bookmark marker ID, or to intentionally make use of the bookmark marker ID. The plugin authors are encouraged to use this API (instead of using the static number from Notepad++ source code) to get bookmark marker ID dynamically. It garantees plugins get always the right bookmark marker ID even it’s been changed through the different Notepad++ versions.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns the bookmark ID value as an integer
[2090] NPPM_GETBUFFERENCODING
Retrieves the encoding from the document with the given bufferID.
Parameters:
wParam [in] : UINT_PTR bufferID
lParam [in] : int, must be zero.
Return value: : Returns -1 on error, otherwise the encoding number. Here are the possible values (enum UniMode):
0: ANSI
1: UTF-8 with BOM
2: UTF-16 Big Ending with BOM
3: UTF-16 Little Ending with BOM
4: UTF-8 without BOM
5: uni7Bit
6: UTF-16 Big Ending without BOM
7: UTF-16 Little Ending without BOM
[2092] NPPM_GETBUFFERFORMAT
Gets the current EOL format of the document with given bufferID.
Parameters:
wParam [in] : UINT_PTR bufferID
lParam [in] : int, must be zero.
Return value: : Returns -1 on error, otherwise documents EOL format type. Here are the possible values (EOL formatType):
0: Windows (CRLF)
1: Macos (CR)
2: Unix (LF)
3. Unknown
[2083] NPPM_GETBUFFERIDFROMPOS
Gets the document buffer ID from the given docIndex and viewIndex.
Parameters:
wParam [in] : int docIndex, a 0-based index which indicates which document to activate from the selected view’s list of documents.
lParam [in] : int viewIndex, which must be either 0 (main view) or 1 (secondary view).
Return value: : Returns 0 if given docIndex and viewIndex are invalid, otherwise the document buffer ID.
[2088] NPPM_GETBUFFERLANGTYPE
Retrieves the language type of the document with the given bufferID.
Parameters:
wParam [in] : UINT_PTR bufferID
lParam [in] : int, must be zero.
Return value: : Returns -1 on error, otherwise a value from enum LangType. Please see the enum LangType for all possible values.
[2084] NPPM_GETCURRENTBUFFERID
Returns the buffer ID of the active document.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns the buffer ID of the active document.
[2133] NPPM_GETCURRENTCMDLINE
Get the Current Command Line string. Users should call it with commandLineStr as NULL to get the required number of wchar_t (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.
Parameters:
wParam [in] : size_t strLen
lParam [out] : wchar_t * commandLineStr
Return value: : Returns the number of wchar_t copied/to copy.
[4033] NPPM_GETCURRENTCOLUMN
Retrieves the column of the caret.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns the current, 0-based, column position of the caret.
[4026] NPPM_GETCURRENTDIRECTORY
Retrieves the directory path of current document. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t directoryPathLen
lParam [out] : wchar_t * directoryPath
Return value: : Returns True on success and False if provided directoryPath buffer is not large enough
[2047] NPPM_GETCURRENTDOCINDEX
Retrieves the current document’s index in the given view.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int viewIndex, which must be either 0 (main view) or 1 (secondary view).
Return value: : Returns -1 if the view is invisible (hidden), otherwise returns the current document’s index in the given view.
[2029] NPPM_GETCURRENTLANGTYPE
Retrieves the language type of the current document.
Parameters:
wParam [ in ] : int, must be zero.
lParam [ out ] : int * langType, pointer to the buffer receiving the language type of the current document Please see the enum LangType for all possible values.
Return value : Returns always True
[4032] NPPM_GETCURRENTLINE
Retrieves the line of the caret.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns the current, 0-based, line position of the caret.
[4036] NPPM_GETCURRENTLINESTR
Retrieves the text of the current line. User is responsible to allocate a buffer which is large enough.
Parameters:
wParam [in] : size_t strLen
lParam [out] : wchar_t * strLine
Return value: : Returns True on success and False if provided strLine buffer is not large enough
[2130] NPPM_GETCURRENTMACROSTATUS
Gets the current macro status (idle, recording, stopped, and playing back) as an enumeration class object.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : An object of the enumeration class MacroStatus, with values:
MacroStatus::Idle- means macro is not in use and it’s emptyMacroStatus::RecordInProgress- macro is currently being recordedMacroStatus::RecordingStopped- macro recording has been stoppedMacroStatus::PlayingBack- macro is currently being played back
[2103] NPPM_GETCURRENTNATIVELANGENCODING
Retrieves the code page associated with the current localisation of Notepad++.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns As of v6.6.6, returned values are 1252 (ISO 8859-1), 437 (OEM US) or 950 (Big5).
[2028] NPPM_GETCURRENTSCINTILLA
Retrieves the current Scintilla view
Parameters:
wParam [in] : int, must be zero.
lParam [out] : int * currentEdit, pointer to the buffer receiving the current view. The returned value can be one of the following:
Value Meaning
0 The main view
1 The second view
-1 In case of an error
Return value: : Returns always True
[2112] NPPM_GETCURRENTVIEW
*Retrieves the current used view. *
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns Either 0 when main view is active or 1 if secondary view is active.
[4030] NPPM_GETCURRENTWORD
Retrieves the word containing the caret. User is responsible to allocate a buffer which is large enough.
Parameters:
wParam [in] : size_t currentWordLen
lParam [out] : wchar_t * currentWord
Return value: : Returns True on success and False if provided currentWord buffer is not large enough
[2132] NPPM_GETDARKMODECOLORS
Retrieves the colors used in Dark Mode. User is responsible to allocate a buffer which is large enough.
Parameters:
wParam [in]
: size_t cbSize - must be filled with sizeof(NppDarkMode::Colors)
lParam [out] : NppDarkMode::Colors* returnColors - must be a pre-allocated NppDarkMode::Colors struct
Return value: : Returns True on success and False if provided currentWord buffer is not large enough
Data Structure :
namespace NppDarkMode
{
struct Colors
{
COLORREF background = 0;
COLORREF softerBackground = 0; // ctrl background color
COLORREF hotBackground = 0;
COLORREF pureBackground = 0; // dlg background color
COLORREF errorBackground = 0;
COLORREF text = 0;
COLORREF darkerText = 0;
COLORREF disabledText = 0;
COLORREF linkText = 0;
COLORREF edge = 0;
COLORREF hotEdge = 0; // new to v8.4.3
COLORREF disabledEdge = 0; // new to v8.4.3
};
}
Notes: data structure source
[2115] NPPM_GETEDITORDEFAULTBACKGROUNDCOLOR
Retrieves the current editor default background color.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns The color as integer with hex format being 0x00bbggrr
[2114] NPPM_GETEDITORDEFAULTFOREGROUNDCOLOR
Retrieves the current editor default foreground.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns The color as integer with hex format being 0x00bbggrr
[2069] NPPM_GETENABLETHEMETEXTUREFUNC [DEPRECATED]
Deprecated v8.4.9: Use EnableThemeTexture from uxtheme.h instead.
NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED: Returns if visual style of the background of a dialog window is enabled or not.
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns A proc address or NULL
[2127] NPPM_GETEXTERNALLEXERAUTOINDENTMODE
Get ExternalLexerAutoIndentMode for an installed external programming language. Puts that mode in the output object.
Parameters:
wParam [in] : const wchar_t* languageName, the name of the language to get
lParam [out] : ExternalLexerAutoIndentMode &autoIndentMode, an object of the enumeration class ExternalLexerAutoIndentMode, with values:
ExternalLexerAutoIndentMode::Standard=> 0ExternalLexerAutoIndentMode::C_Like=> 1ExternalLexerAutoIndentMode::Custom=> 2
Return value: : TRUE for successful searches, otherwise FALSE.
[4029] NPPM_GETEXTPART
Retrieves the extension of the filename of the current document. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t extensionLen
lParam [out] : wchar_t * extension
Return value: : Returns True on success and False if provided extension buffer is not large enough
[2142] NPPM_GETTOOLBARICONSETCHOICE
Get Notepad++ toobar icon set choice (Fluent UI: small, Fluent UI: large, Filled Fluent UI: small, Filled Fluent UI: large and Standard icons: small).
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Return toolbar icon set choice as an integer value. Here are 5 possible values:
- `0`: Fluent UI: small
- `1`: Fluent UI: large
- `2`: Filled Fluent UI: small
- `3`: Filled Fluent UI: large
- `4`: Standard icons: small
[4027] NPPM_GETFILENAME
Retrieves the file name of current document. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t fileNameLen
lParam [out] : wchar_t * fileName
Return value: : Returns True on success and False if provided fileName buffer is not large enough
[4035] NPPM_GETFILENAMEATCURSOR
Retrieves the filename at the current caret position. Note, while this message has been created, and is used internally, to retrieve a filename at the current caret position, it does return anything which fulfills the requirements, even single words.
Parameters:
wParam [in] : INT length
lParam [out] : wchar_t* buffer
Return value: : Returns True if the size of the provided buffer is large enough, False otherwise.
[4025] NPPM_GETFULLCURRENTPATH
Retrieves the full path of the current document. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t fullPathLen
lParam [out] : wchar_t * fullPath
Return value: : Returns True on success and False if provided fullPath buffer is not large enough
[2082] NPPM_GETFULLPATHFROMBUFFERID
Gets the full path file name from the given bufferID. First call should be made with buffer set to NULL to retrieve the actual size needed. Second call is sent with correctly allocated buffer, +1 for trailing null, to retrieve the full path file name.
Parameters:
wParam [in] : UINT_PTR bufferID
lParam [out] : wchar_t * buffer
Return value: : Returns -1 if bufferID does not exist, otherwise the number of chars copied/to copy.
[2108] NPPM_GETLANGUAGEDESC
Retrieves the description of the current language used. First call should be made with buffer set to NULL to retrieve the actual size needed. Second call is sent with correctly allocated buffer to retrieve the description.
Parameters:
wParam [in] : int langTypeID
lParam [out] : wchar_t* buffer
Return value: : Returns The number of characters needed or copied
[2107] NPPM_GETLANGUAGENAME
Retrieves the name of the current language used. First call should be made with buffer set to NULL to retrieve the actual size needed. Second call is sent with correctly allocated buffer to retrieve the language name.
Parameters:
wParam [in] : int langTypeID
lParam [out] : wchar_t* buffer
Return value: : Returns The number of characters needed or copied
[2124] NPPM_GETLINENUMBERWIDTHMODE
Get line number margin width in dynamic width mode (LINENUMWIDTH_DYNAMIC) or constant width mode (LINENUMWIDTH_CONSTANT)
Parameters:
wParam [in] : int, must be zero.
lParam [in] : int, must be zero.
Return value: : Returns the line number margin width mode, either the LINENUMWIDTH_DYNAMIC or LINENUMWIDTH_CONSTANT value.
[2049] NPPM_GETMENUHANDLE
Retrieves either the plugin or the main menu handle of Notepad++.
Parameters:
wParam [in] : int whichMenu, which can be 0 (plugin menu) or 1 (main menu)
lParam [in] : int, must be zero.
Return value: : Returns the requested menu handle.
[4028] NPPM_GETNAMEPART
Retrieves the part of filename, without extension, of the current document. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t namePartLen
lParam [out] : wchar_t * namePart
Return value: : Returns True on success and False if provided namePart buffer is not large enough
[2140] NPPM_GETNATIVELANGFILENAME
Get the Current native language file name string. Use it after getting NPPN_READY notification to find out which native language is used.
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.
Parameters:
wParam [in] : size_t strLen, which is “language file name string” buffer length
lParam [out] : CHAR * nativeLangFileName, language file name string receives all copied native language file name string
Return value: : Returns the number of char copied/to copy
[2031] NPPM_GETNBOPENFILES
Retrieves the number of files currently open
Parameters:
wParam [in] : int, must be zero.
lParam [in] : Integer of one of the following values:
Value Meaning
0 the total number of files opened in Notepad++
1 number of files opened in the main view
2 number of files opened in the second view
Return value: : Returns number of open files
[2037] NPPM_GETNBSESSIONFILES
Retrieves the number of files to load in the session sessionFileName. sessionFileName should be a full path name of an xml file.
Parameters:
wParam [out] : BOOL* isValidXML, if the lParam pointer is null, then this parameter will be ignored. TRUE if XML is valid, otherwise FALSE.
lParam [in] : const wchar_t * sessionFileName
Return value: : Returns 0 if sessionFileName is an empty string/NULL, or XML session file is corrupted/invalid, else the number of files.
[2046] NPPM_GETNBUSERLANG
Retrieves the number of user defined languages and, optionally, the starting menu id. Note, udlID is optional, if not used set it to 0, otherwise an integer pointer is needed to retrieve the menu identifier.
Parameters:
wParam [in] : int, must be zero.
lParam [out] : INT* udlID
Return value: : Returns The number of user defined languages identified
[4031] NPPM_GETNPPDIRECTORY
Retrieves the full path of the directory where the Notepad++ binary is located. User is responsible to allocate a buffer which is large enough. MAX_PATH is suggested to use.
Parameters:
wParam [in] : size_t nppDirLen
lParam [out] : wchar_t * nppDir
Return value: : Returns True on success and False if provided nppDir buffer is not large enough
[4034] NPPM_GETNPPFULLFILEPATH
Retrieves the full path of the Notepad++ executable.
Parameters:
wParam [in] : INT length
lParam [out] : wchar_t* buffer
Return value: : Returns True if the provided buffer size was big enough to write the full path to it, False otherwise.
[2074] NPPM_GETNPPVERSION
Retrieves the current Notepad++ version.
The value is made up of 2 parts: the major version (the high word) and minor version (the low word).
Note that this message is supported by the v4.7 or higher version; earlier versions return 0.
It has the ability to pad the result to make comparisons between versions like 8.4.1 and 8.5 easier
(without the padding, they would have been 8|41 and 8|5, and since 5 is less than 41, it would have incorrectly shown up
as 8.5 coming before 8.41; with the padding flag on, they will be 8|410 and 8|500, so 8.5 will properly
come after 8.4.1).
Parameters:
wParam [in] : Boolean ADD_ZERO_PADDING, will add zero padding, as per the tables below:
ADD_ZERO_PADDING == TRUE
version | HIWORD | LOWORD
-----------------------------
8.9.6.4 | 8 | 964
9 | 9 | 0
6.9 | 6 | 900
6.6.6 | 6 | 660
13.6.6.6 | 13 | 666
ADD_ZERO_PADDING == FALSE
version | HIWORD | LOWORD
-----------------------------
8.9.6.4 | 8 | 964
9 | 9 | 0
6.9 | 6 | 9
6.6.6 | 6 | 66
13.6.6.6 | 13 | 666
lParam [in] : int, must be zero.
Return value: : Returns a LONG value containing the current version.
[2032] NPPM_GETOPENFILENAMES [DEPRECATED]
Deprecated in v8.8.2. It is kept for the compatibility. Use NPPM_GETBUFFERIDFROMPOS & NPPM_GETFULLPATHFROMBUFFERID instead.
NPPM_GETOPENFILENAMES_DEPRECATED: Retrieves the open files of both views.
User is responsible to allocate an big enough fileNames array.
Parameters:
wParam [out] : wchar_t ** fileNames, receives the full path names of all the opened files in Notepad++
lParam [in] : int nbFile, is the size of the fileNames array. Get this value by using NPPM_GETNBOPENFILES message with constant ALL_OPEN_FILES, then allocate fileNames array with this value (noting the size requirements for an Array of Path Strings).
Return value: : Returns The number of files copied into fileNames array.
[2041] NPPM_GETOPENFILENAMESPRIMARY [DEPRECATED]
Deprecated in v8.8.2. It is kept for the compatibility. Use NPPM_GETBUFFERIDFROMPOS & NPPM_GETFULLPATHFROMBUFFERID instead.
NPPM_GETOPENFILENAMESPRIMARY_DEPRECATED: Retrieves the open files of the main view.
User is responsible to allocate an big enough fileNames array.
Parameters:
wParam [out] : wchar_t ** fileNames, receives the full path names of the opened files in the primary view
lParam [in] : int nbFile, is the size of the fileNames array. Get this value by using NPPM_GETNBOPENFILES message with constant PRIMARY_VIEW, then allocate fileNames array with this value (noting the size requirements for an Array of Path Strings).
Return value: : Returns The number of files copied into fileNames array.
[2042] NPPM_GETOPENFILENAMESSECOND [DEPRECATED]
Deprecated in v8.8.2. It is kept for the compatibility. Use NPPM_GETBUFFERIDFROMPOS & NPPM_GETFULLPATHFROMBUFFERID instead.
NPPM_GETOPENFILENAMESSECOND_DEPRECATED: Retrieves the open files of the secondary view.
User is responsible to allocate an big enough fileNames array.
Parameters:
wParam [out] : wchar_t ** fileNames, receives the full path names of the opened files in the second view
lParam [in] : int nbFile, is the size of your fileNames array. You should get this value by using NPPM_GETNBOPENFILES message with constant SECOND_VIEW, then allocate fileNames array with this value (noting the size requirements for an Array of Path Strings).
Return value: : Returns The number of files copied into fileNames array.
[2121] NPPM_GETPLUGINHOMEPATH
Retrieves the plugin home root path. First call should be made with length set to 0 and buffer set to NULL to retrieve the actual size of the path. Second call sends the correct length and allocated buffer, both +1 for trailing NULL, to get the path name.
Parameters:
wParam [in] : SIZE_T length
lParam [out] : wchar_t* buffer
Return value: : Returns the number of wchar_t copied to buffer without trailing NULL.
[2070] NPPM_GETPLUGINSCONFIGDIR
Retrieves the path of the plugin config directory. User should call this message twice: The 1st call with “pluginsConfDir” be NULL to get the required number of wchar_t (not including the terminating nul character) The 2nd call to allocate “pluginsConfDir” buffer with the 1st call’s return value + 1, then call it again to get the path
Parameters:
wParam [in] : int strLen
lParam [out] : wchar_t *pluginsConfDir
Return value: : Return: The 1st call - the number of wchar_t to copy; The 2nd call - False on failure, True on success
Note: This gives the top level path for the plugin configuration hierarchy. Unless you are certain that your plugin will always only have one configuration file, it is best to use a subdirectory of this plugin configuration directory (named the same as your plugin DLL), so all your plugin’s configuration files can be kept isolated from those of other plugins.
[2081] NPPM_GETPOSFROMBUFFERID
Gets 0-based document viewIndex and docIndex from given buffer ID, encoded as a single 32-bit integer: The 30 lowest bits of the return value are the docIndex. Bit 30 indicates which viewIndex has the buffer (0 for main view, 1 for secondary view).
Parameters:
wParam [in] : UINT_PTR bufferID
lParam [in] : int priorityView, which must be either 0 (main view) or 1 (secondary view). It will search the chosen view first, but if the given bufferID cannot be found in the chosen view, the other view will also be searched.
Return value: : Returns -1 if bufferID doesn’t exist, else returns the encoded viewIndex and docIndex.
[2143] NPPM_GETNPPSETTINGSDIRPATH
Get path for the active Notepad++ settings: it will use -settingsDir path if that’s defined; if not, it will use the Cloud directory, if that’s enabled; if not, it will use the AppData settings directory; or, finally, the portable or installation path. This allows plugins to have one interface to find out where the active Notepad++ settings are stored, whichever location they are currently set to.
First call should be made with buffer set to NULL to retrieve the actual size needed. Second call is sent with correctly allocated buffer, +1 for trailing null, to retrieve the full path file name.
Parameters:
wParam [in] : size_t strLen, maximum bytes to read for the path string, including the final NULL byte
lParam [out] : wchar_t *settingsDirPath, the path for active settings directory obtained by this message
Return value: : Returns the length of the path string. If the return value is 0, then the “strLen” is not enough to copy the path, or the settings path could not be determined.
Note: This message is for the active Notepad++ configuration location. If you are looking for the settings directory for plugins (...\Plugins\Config\), use NPPM_GETPLUGINSCONFIGDIR instead.
[2122] NPPM_GETSETTINGSONCLOUDPATH
Get settings on cloud path. It’s useful if plugins want to store its settings on Cloud, if this path is set.
First call should be made with buffer set to NULL to retrieve the actual size needed. Second call is sent with correctly allocated buffer, +1 for trailing null, to retrieve the full path file name.
Parameters:
wParam [in] : size_t strLen, maximum bytes to read for the path string, including the final NULL byte
lParam [out] : wchar_t *settingsOnCloudPath, the path for cloud settings obtained by this message
Return value: : Returns the length of the path string
(本文超出站点单文档体积上限,已截断)
