1 //this file is part of notepad++ 2 //Copyright (C)2003 Don HO <donho@altern.org> 3 // 4 //This program is free software; you can redistribute it and/or 5 //modify it under the terms of the GNU General Public License 6 //as published by the Free Software Foundation; either 7 //version 2 of the License, or (at your option) any later version. 8 // 9 //This program is distributed in the hope that it will be useful, 10 //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 //GNU General Public License for more details. 13 // 14 //You should have received a copy of the GNU General Public License 15 //along with this program; if not, write to the Free Software 16 //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 /** 18 * Notepad++ hello plugin 19 * 20 * License: GPL-2.0 or later 21 */ 22 module npp_api.example.hello; 23 24 25 version (Windows): 26 27 import npp_api.pluginfunc; 28 29 extern (C) 30 npp_api.powereditor.misc.pluginsmanager.plugininterface.NppData nppData; 31 32 /** 33 * plugin config 34 */ 35 enum npp_plugin_definition plugin_def = 36 { 37 name: "hello plugin", 38 version_string: "0.1", 39 author: "", 40 menu_items: 41 [ 42 { 43 func_item: 44 { 45 _itemName: "Hello Notepad++"w, 46 _pFunc: &hello, 47 _init2Check: false, 48 _pShKey: null, 49 }, 50 }, 51 ], 52 }; 53 54 /** 55 * plugin menu item 56 * show "Hello, World" message 57 */ 58 extern (C) 59 nothrow @nogc 60 void hello() 61 62 do 63 { 64 MessageBoxW(.nppData._nppHandle, &(c_wstring!("Hello, Notepad++!"w)[0]), &(c_wstring!(plugin_def.name)[0]), MB_OK); 65 } 66 67 /** 68 * This function is called within the "DllMain" function. 69 * 70 * You can delete this function. 71 */ 72 pragma(inline, true) 73 nothrow 74 void pluginInit(HANDLE hModule) 75 76 do 77 { 78 } 79 80 /** 81 * This function is called within the "DllMain" function. 82 * 83 * You can delete this function. 84 */ 85 pragma(inline, true) 86 nothrow 87 void pluginCleanUp() 88 89 do 90 { 91 } 92 93 /** 94 * This function is called within the "setInfo" function. 95 * 96 * You can delete this function. 97 */ 98 pragma(inline, true) 99 nothrow 100 void pluginSetInfo(ref NppData notpadPlusData) 101 102 do 103 { 104 } 105 106 /** 107 * This function is called within the "beNotified" function. 108 * 109 * You can delete this function. 110 */ 111 pragma(inline, true) 112 nothrow 113 void pluginBeNotified(ref SCNotification notifyCode) 114 115 do 116 { 117 /* 118 switch (notifyCode.nmhdr.code) { 119 case NPPN_READY: 120 case NPPN_TBMODIFICATION: 121 case NPPN_FILEBEFORECLOSE: 122 case NPPN_FILEOPENED: 123 case NPPN_FILECLOSED: 124 case NPPN_FILEBEFOREOPEN: 125 case NPPN_FILEBEFORESAVE: 126 case NPPN_FILESAVED: 127 case NPPN_SHUTDOWN: 128 case NPPN_BUFFERACTIVATED: 129 case NPPN_LANGCHANGED: 130 case NPPN_WORDSTYLESUPDATED: 131 case NPPN_SHORTCUTREMAPPED: 132 case NPPN_FILEBEFORELOAD: 133 case NPPN_FILELOADFAILED: 134 case NPPN_READONLYCHANGED: 135 case NPPN_DOCORDERCHANGED: 136 case NPPN_SNAPSHOTDIRTYFILELOADED: 137 case NPPN_BEFORESHUTDOWN: 138 case NPPN_CANCELSHUTDOWN: 139 case NPPN_FILEBEFORERENAME: 140 case NPPN_FILERENAMECANCEL: 141 case NPPN_FILERENAMED: 142 case NPPN_FILEBEFOREDELETE: 143 case NPPN_FILEDELETEFAILED: 144 case NPPN_FILEDELETED: 145 break; 146 147 default: 148 break; 149 } 150 */ 151 } 152 153 /** 154 * This function is called within the "messageProc" function. 155 * 156 * You can delete this function. 157 */ 158 pragma(inline, true) 159 nothrow 160 bool pluginMessageProc(UINT Message, WPARAM wParam, LPARAM lParam) 161 162 do 163 { 164 /* 165 switwch (Message) { 166 case WM_MOVE: 167 case WM_SIZE: 168 case WM_COMMAND: 169 break; 170 171 default: 172 break; 173 } 174 */ 175 176 return true; 177 } 178 179 /** 180 * mixin Notepad++ interface 181 */ 182 mixin npp_plugin_interface!(.plugin_def);