notepad++ plugin development


//z 因想修改一个插入日期的插件稍微看了一下,做了点笔记。可以看英文的直接看英文去哈。。。

切记:一定要预先选定一种适当的字符编码(unicode或者ansi),要不然很痛苦。。。

1. 下载 Notepad++Plugin Template 2. 在vs中打开NppPluginTemplate.vcproj
3. 在PluginDefinition.h中定义插件名称

#define PLUGIN_NAMEL"InsertDate"

// The getName function tells Notepad++ plugins system its nameconstTCHAR *__cdeclgetName(void) {
      returnPLUGIN_NAME;
}


4. 在 PluginDefinition.h中定义插件命令数目

// The getFuncsArray function gives Notepad++ plugins system the pointerFuncItem Array
// and the size of this array (the number of functions)
struct FuncItem *__cdeclgetFuncsArray(int *nbF) {
      *nbF =NELEM(funcItem);
returnfuncItem;
 }

// The setInfo function gets the needed infos fromNotepad++ plugins systemvoid__cdeclsetInfo(structNppDatanotpadPlusData) {
      nppData =notpadPlusData;
}


5. 在PluginDefinition.cpp中定制命令名称和相关函数名称

struct FuncItem funcItem[]={
      {L"CurrentFull Path",pfinsertCurrentFullPath,0,FALSE},
      {L"CurrentFile Name",pfinsertCurrentFileName,0,FALSE},
      {L"CurrentDirectory",pfinsertCurrentDirectory,0,FALSE},
      {L"Date&& Time - short format",pfinsertShortDateTime,0,FALSE},
      {L"Date&& Time - long format",pfinsertLongDateTime,0,FALSE},
      {L"CloseHTML/XML tag automatically",pfinsertHtmlCloseTag,0,FALSE},
      {L"About",pfabout,0,FALSE},
};



6. 定义相关函数

在PluginDefinition.h andPluginDefinition.cpp中有如下这些注释指引着你:
//-- STEP 1. DEFINE YOUR PLUGIN NAME --// 定义你的插件名//-- STEP 2. DEFINE YOUR PLUGIN COMMAND NUMBER --// 定义你的插件命令
//-- STEP 3. CUSTOMIZE YOUR PLUGIN COMMANDS --// 定制你的插件命令
//-- STEP 4. DEFINE YOUR ASSOCIATED FUNCTIONS --// 实现相关函数

/*

执行顺序:

1. Notepad++调用DllMain()载入插件

2. N++调用getFuncsArray,SetInfo,getName得到初始的操作信息

3.当编辑的时候beNotified不断被调用

*/

 //z 上述只供自己备忘;详细请见以下资料:
http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Development_Quick_Start_Guide

http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Plugin_Development#How_to_develop_a_plugin

Notepad++ plugin(插件)开发之消息HOOK (文件保存,文件打开,文件关闭)


Mod版本的TaskList