Plugins HOWTO
How to install a plugin
The plugin (in the DLL form) should be placed in Notepad++\plugins directory. Once you installed the plugin, you can use (and you may configure) it via the menu "Plugins".
How to develop a plugin
The Windows Message System is used to avoid the overhead. It means the plugins system makes available some Notepad++ handles in order to give more flexibility and possibility to the plugin developers. There're 3 window handles available for the moment: The main Notepad++ handle and 2 Scintilla Window handles.
With these 3 window handles, we can do almost everything, just send the appropriate message to the right handle to get what you want.
Here's a plugin demo projects named NppInsertPlugin, which is a complete working project , and which may give you more idea how it works.
Check the newest header file Notepad_plus_msgs.h that you may need to use the new Notepad++ message.
The interface (the header file) of plugin is written in C for both C/C++ programmer. However, if you translate it in order to develop in another language, please let me know. I'll include it for the other language development.
Plugin template for Delphi is now available.
Notepad++ messages :
- NPPM_GETCURRENTSCINTILLA
wParam |
lParam |
0 |
[out] int * currentEdit |
currentEdit indicates the current Scintilla view : 0 is the main Scintilla view 1 is the second Scintilla view.
- NPPM_GETCURRENTLANGTYPE
wParam |
lParam |
0 |
[out] int * langType |
langType indicates the language type of current Scintilla view document : please see the enum LangType in "PluginInterface.h" for all possible value.
- NPPM_SETCURRENTLANGTYPE
wParam |
lParam |
0 |
[in] int langTypeToSet |
langTypeToSet is used to set the language type of current Scintilla view document : please see the enum LangType in "PluginInterface.h" for all possible value.
- NPPM_GETFULLCURRENTPATH
wParam |
lParam |
[in] size_t fullPathLen |
[out] char * fullPath |
fullPath receives the full path of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETCURRENTDIRECTORY
wParam |
lParam |
[in] size_t directoryPathLen |
[out] char * directoryPath |
directoryPath receives the directory path of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETFILENAME
wParam |
lParam |
[in] size_t fileNameLen |
[out] char * fileName |
fileName receives the file name of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETNAMEPART
wParam |
lParam |
[in] size_t namePartLen |
[out] char * namePart |
namePart receives the part of name (without extension) of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETEXTPART
wParam |
lParam |
[in] size_t extensionLen |
[out] char * extension |
extension receives the part of extension of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETCURRENTWORD
wParam |
lParam |
[in] size_t currentWordLen |
[out] char * currentWord |
currentWord receives the word on which cursor is currently of current Scintilla view document. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETNPPDIRECTORY
wParam |
lParam |
[in] size_t nppDirLen |
[out] char * nppDir |
nppDir receives the full path of directory where located Notepad++ binary. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_GETNBOPENFILES
wParam |
lParam |
0 |
[in] int nbType |
The return value is :
- the total number of files opened in Notepad++ if nbType is ALL_OPEN_FILES.
- the number of files opened in the primary view if nbType is PRIMARY_VIEW.
- the number of files opened in the second view if nbType is SECOND_VIEW.
- NPPM_GETOPENFILENAMES
wParam |
lParam |
[out] char ** fileNames |
[in] int nbFile |
- nbFile is the size of your fileNames array. You should get this value by using NPPM_NBOPENFILES message with constant ALL_OPEN_FILES, then allocate fileNames array with this value.
- fileNames receives the full path names of all the opened files in Notepad++. User is responsible to allocate fileNames array with an enough size.
- The return value is the number of file full path names copied in fileNames array.
- NPPM_GETOPENFILENAMESPRIMARY
wParam |
lParam |
[out] char ** fileNames |
[in] int nbFile |
- nbFile is the size of your fileNames array. You should get this value by using NPPM_NBOPENFILES message with constant PRIMARY_VIEW, then allocate fileNames array with this value.
- fileNames receives the full path names of the opened files in the primary view. User is responsible to allocate fileNames array with an enough size.
- The return value is the number of file full path names copied in fileNames array.
- NPPM_GETOPENFILENAMESSECOND
wParam |
lParam |
[out] char ** fileNames |
[in] int nbFile |
- nbFile is the size of your fileNames array. You should get this value by using NPPM_NBOPENFILES message with constant SECOND_VIEW, then allocate fileNames array with this value.
- fileNames receives the full path names of the opened files in the second view. User is responsible to allocate fileNames array with an enough size.
- The return value is the number of file full path names copied in fileNames array.
- NPPM_DOOPEN
wParam |
lParam |
0 |
[in] char * fullPathName2Open |
- fullPathName2Open indicates the full file path name to be opened.
- The return value is TRUE (1) if the operation is successful, otherwise FALSE (0).
- NPPM_MODELESSDIALOG
wParam |
lParam |
[in] HWND hDlg |
[in] int op |
For each created dialog in your plugin, you should register it (and unregister while destroy it) to Notepad++ by using this message.
If this message is ignored, then your dialog won't react with the key stroke messages such as TAB key.
For the good functioning of your plugin dialog, you're recommended to not ignore this message.
- hDlg is the handle of the dialog to be registed.
- op : the operation mode. MODELESSDIALOGADD is to register; MODELESSDIALOGREMOVE is to unregister.
- NPPM_SAVECURRENTSESSION
wParam |
lParam |
0 |
[in] const char *sessionFileName |
You can save the current opened files in Notepad++ as a group of files (session) by using this message. Notepad++ saves the current opened files' full pathe names and their current stats in a xml file. The xml full path name is provided by sessionFileName.
- NPPM_SAVESESSION
wParam |
lParam |
0 |
[in] sessionInfo sessionInfomation |
This message let plugins save a session file (xml format) by providing an array of full files path name. sessionInfomation is a struct contain :
struct sessionInfo {
char* sessionFilePathName; //the full path name of session file to save
int nbFile; // the number of files in the session
char** files; // files' full path
};
- NPPM_GETNBSESSIONFILES
wParam |
lParam |
0 |
[in] const char * sessionFileName |
This message return the number of files to load in the session sessionFileName. sessionFileName should be a full path name of an xml file. 0 is returned if sessionFileName is NULL or an empty string
- NPPM_GETSESSIONFILES
wParam |
lParam |
[out] char ** sessionFileArray |
[in]const char * |
Send this message to get files' full path name from a session file.
- sessionFileName is the session file from which you retrieve the files.
- sessionFileArray : the array in which the files' full path of the same group are written. You should send message NPPM_GETNBSESSIONFILES before to allocate this array with the proper size.
- NPPM_LOADSESSION
wParam |
lParam |
0 |
[in] const char * sessionFileName |
Open all files of same session in Notepad++ via a xml format session file sessionFileName.
- NPPM_CREATESCINTILLAHANDLE
wParam |
lParam |
0 |
[in] HWND pluginWindowHandle |
A plugin can create a Scintilla for its usage by sending this message to Notepad++. The return value is created Scintilla handle. The handle should be destroyed by NPPM_DESTROYSCINTILLAHANDLE message while exit the plugin. If pluginWindowHandle is set (non NULL), it will be set as parent window of this created Scintilla handle, otherwise the parent window is Notepad++.
- NPPM_DESTROYSCINTILLAHANDLE
wParam |
lParam |
0 |
[in] HWND scintillaHandle2Destroy |
If plugin called NPPM_DESTROYSCINTILLAHANDLE to create a Scintilla handle, it should call this message to destroy this handle while it exit.
- NPPM_GETCURRENTDOCINDEX
wParam |
lParam |
0 |
[in] int iView |
Sending this message to get the current index in the view that you indicates in iView : MAIN_VIEW or SUB_VIEW. Returned value is -1 if the view is invisible (hidden), otherwise is the current index.
- NPPM_ACTIVATEDOC
wParam |
lParam |
[in] int iView |
[in] int index2Activate |
When Notepad++ receives this message, it switches to iView (MAIN_VIEW or SUB_VIEW) as current view, then it switches to index2Activate from the current document.
- NPPM_GETMENUHANDLE
wParam |
lParam |
[in] int whichMenu |
0 |
This message help plugins to get the plugins menu handle of Notepad++, whichMenu must be NPPPLUGINMENU.
- NPPM_RELOADFILE
wParam |
lParam |
[in] BOOL withAlert |
[in] char *filePathName2Reload |
This Message reloads the file indicated in filePathName2Reload. If withAlert is TRUE, then an alert message box will be launched.
- NPPM_SWITCHTOFILE
wParam |
lParam |
0 |
[in] char *filePathName2switch |
When this message is received, Notepad++ switches to the document which matches with the given filePathName2switch.
- NPPM_GETWINDOWSVERSION
The return value is windows version of enum winVer. The possible value is WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV_S2003, WV_XPX64 and WV_VISTA
- NPPM_SAVECURRENTFILE
Send this message to Notepad++ to save the current document.
- NPPM_SAVEALLFILES
Send this message to Notepad++ to save all opened document.
- NPPM_GETPLUGINSCONFIGDIR
wParam |
lParam |
[in] int strLen |
[out] char *pluginsConfDir |
pluginsConfDir receives the directory path of plugin config files. User is responsible to allocate (or use automatic variable) a buffer with an enough size. MAX_PATH is suggested to use.
- NPPM_SETMENUITEMCHECK
wParam |
lParam |
[in] int cmdID |
[in] BOOL doCheck |
Use this message to set/remove the check on menu item. cmdID is the command ID which corresponds to the menu item.
- NPPM_LAUNCHFINDINFILESDLG
wParam |
lParam |
[in] char * dir2Search |
[in] char * filtre |
This message triggers the Find in files dialog. The fields Directory and filters are filled by respectively dir2Search and filtre if those parameters are not NULL or empty.
- NPPM_DMMREGASDCKDLG
wParam |
lParam |
0 |
[in] tTbData * dockingData |
From v4.0, Notepad++ supports the dockable dialog feature for the plugins. This message passes the necessary data dockingData to Notepad++ in order to make your dialog dockable. Here is tTbData looks like :
typedef struct {
HWND hClient;
char *pszName;
int dlgID;
UINT uMask;
HICON hIconTab;
char *pszAddInfo;
RECT rcFloat;
int iPrevCont;
const char *pszModuleName;
} tTbData;
Minimum informations you need to fill out before sending it by NPPM_DMMREGASDCKDLG message is hClient, pszName, dlgID, uMask and pszModuleName. Notice that rcFloat and iPrevCont shouldn't be filled. They are used internally.
- hClient is your dockable dialog handle.
- pszName is the name of your plugin dialog.
- dlgID is the index of menu entry where the dialog in question will be triggered.
- uMask contains the behaviour informations of your dialog. It can be one of the following value : DWS_DF_CONT_LEFT, DWS_DF_CONT_RIGHT, DWS_DF_CONT_TOP, DWS_DF_CONT_BOTTOM and DWS_DF_FLOATING combined (optional) with DWS_ICONTAB, DWS_ICONBAR and DWS_ADDINFO.
- pszModuleName is the name of your plugin module (with extension .dll).
- NPPM_DMMSHOW
wParam |
lParam |
0 |
[in] HWND hDlg |
This message is used for your plugin's dockable dialog. Send this message to show the dialog. hDlg is the handle of your dialog to be shown.
- NPPM_DMMHIDE
wParam |
lParam |
0 |
[in] HWND hDlg |
This message is used for your plugin's dockable dialog. Send this message to hide the dialog. hDlg is the handle of your dialog to be hidden.
- NPPM_DMMUPDATEDISPINFO
wParam |
lParam |
0 |
[in] HWND hDlg |
This message is used for your plugin's dockable dialog. Send this message to update (redraw) the dialog. hDlg is the handle of your dialog to be updated.
- NPPM_DMMGETPLUGINHWNDBYNAME
wParam |
lParam |
[in] const char * windowName |
[in] const char * moduleName |
This message returns the dialog handle corresponds to the windowName and moduleName. You may need this message if you want to communicate with another plugin "dockable" dialog, by knowing its name and its plugin module name. If moduleName is NULL, then return value is NULL. If windowName is NULL, then the first found window handle which matches with the moduleName will be returned.
- NPPM_MSGTOPLUGIN
wParam |
lParam |
[in] char * destModuleName |
[in][out] CommunicationInfo * info |
This message allows the communication between 2 plugins.
For example, plugin X can execute a command of plugin Y if plugin X knows the
command ID and the file name of plugin Y.
destModuleName is the complete module name (with the extesion .dll) of plugin with which you want to communicate (plugin Y).
communicationInfo is a poniter of structure type :
struct CommunicationInfo {
long internalMsg;
char * srcModuleName;
void * info; // defined by plugin
};
internalMsg is an interger defined by plugin Y, known by plugin X.
srcModuleName is the complete module name (with the extesion .dll) of caller(plugin X).
info is the informations to be exchanged between X and Y. It's a void pointer so it should be defined by plugin Y and known by plugin X.
The returned value is TRUE if Notepad++ found the plugin by its module name
(destModuleName), and pass the info (communicationInfo) to the module.
The returned value is FALSE if no plugin with such name is found.
- NPPM_MENUCOMMAND
wParam |
lParam |
0 |
[in] int commandID |
This message allows plugins to call all the Notepad++ menu commands.
commandID are the command ID used in Notepad++.
All the command ID are defined in menuCmdID.h.`
- NPPM_TRIGGERTABBARCONTEXTMENU
wParam |
lParam |
[in] int whichView |
[in] int index2Activate |
This message switches to iView (MAIN_VIEW or SUB_VIEW) as current view, and it switchs to index2Activate from the current document. Finally it triggers the tabbar context menu for the current document.
- NPPM_GETNPPVERSION
You can get Notepad++ version via this message.
The return value is made up of 2 parts : the major version (the high word) and minor version (the low word).
For example, the 4.7.5 version will be :
HIWORD(version) == 4
LOWORD(version) == 75
Note that this message is supported by the v4.7 or upper version. For the anterior version the return value is 0.
- NPPM_HIDETABBAR
wParam |
lParam |
0 |
[in] BOOL hideOrNot |
If hideOrNot == TRUE, then this message will hide the tabbar, otherwises it makes tabbar shown.
The returned value is the previous staus before this operation.
- NPPM_ISTABBARHIDE
Via this message plugin is able to know the current status of tabbar.
TRUE if the tabbar is hidden, FALSE otherwise.
Notepad++ notifications :
- NPPN_READY
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that all the procedures of launchment of notepad++ are done.
- NPPN_TBMODIFICATION
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that toolbar icons can be registered.
- NPPN_FILEBEFORECLOSE
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that the current file is about to be closed
- NPPN_FILECLOSED
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that the current file is just closed
- NPPN_FILEBEFOREOPEN
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that a file is being opened
- NPPN_FILEOPENED
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that the current file is just opened
- NPPN_FILEBEFORESAVE
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that the current file is about to be saved
- NPPN_FILESAVED
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that the current file is just saved
- NPPN_SHUTDOWN
hwndFrom |
idFrom |
hwndNpp |
0 |
It notifies plugins that Notepad++ is about to be shutdowned.
Scintilla messages :
Here you can find the document for all the messages of Scintilla.
|