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 * plugin demo 19 * 20 * License: GPL-2.0 or later 21 */ 22 module npp_demo.commands; 23 24 25 private static import core.stdc.stdint; 26 private static import core.stdc.stdio; 27 private static import core.stdc.stdlib; 28 private static import core.stdc.string; 29 private static import core.stdc.time; 30 private static import core.sys.windows.basetsd; 31 private static import core.sys.windows.winbase; 32 private static import core.sys.windows.windef; 33 private static import core.sys.windows.winnls; 34 private static import core.sys.windows.winnt; 35 private static import core.sys.windows.winuser; 36 private static import std.path; 37 private static import std.string; 38 private static import npp_api.pluginfunc.npp_msgs; 39 private static import npp_api.pluginfunc.path; 40 private static import npp_api.pluginfunc.scintilla_msg; 41 private static import npp_api.pluginfunc.string; 42 private static import npp_api.powereditor.menucmdid; 43 private static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 44 private static import npp_api.powereditor.misc.pluginsmanager.plugininterface; 45 private static import npp_api.powereditor.scitillacomponent.gotolinedlg; 46 private static import npp_api.powereditor.wincontrols.dockingwnd.docking; 47 private static import npp_api.scintilla.scintilla; 48 private static import npp_demo.plugin_dll; 49 50 version (Windows): 51 52 pragma(lib, "kernel32.lib"); 53 pragma(lib, "user32.lib"); 54 55 enum DOCKABLE_DEMO_INDEX = 15; 56 enum bool shortDate = true; 57 enum bool longDate = false; 58 59 extern (C) 60 extern npp_api.powereditor.misc.pluginsmanager.plugininterface.NppData nppData; 61 62 extern (C) 63 extern __gshared npp_api.powereditor.misc.pluginsmanager.plugininterface.NppData gshared_nppData; 64 65 /** 66 * 67 */ 68 extern (Windows) 69 nothrow @nogc 70 package core.sys.windows.windef.DWORD threadZoomer(void*) 71 72 in 73 { 74 } 75 76 do 77 { 78 static import core.stdc.stdint; 79 static import core.sys.windows.winbase; 80 static import core.sys.windows.windef; 81 static import npp_api.pluginfunc.npp_msgs; 82 static import npp_api.pluginfunc.scintilla_msg; 83 static import npp_api.scintilla.scintilla; 84 85 // Get the current scintilla 86 int currentEdit = -1; 87 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(.gshared_nppData._nppHandle, currentEdit); 88 89 if (currentEdit == -1) { 90 return core.sys.windows.windef.FALSE; 91 } 92 93 core.sys.windows.windef.HWND curScintilla = (currentEdit == 0) ? (.gshared_nppData._scintillaMainHandle) : (.gshared_nppData._scintillaSecondHandle); 94 95 core.stdc.stdint.intptr_t currentZoomLevel = npp_api.pluginfunc.scintilla_msg.send_SCI_GETZOOM(curScintilla); 96 97 core.stdc.stdint.intptr_t i = currentZoomLevel; 98 99 for (size_t j = 0 ; j < 4 ; ++j) { 100 for ( ; i >= -10 ; i--) { 101 npp_api.pluginfunc.scintilla_msg.send_SCI_SETZOOM(curScintilla, i); 102 core.sys.windows.winbase.Sleep(30); 103 } 104 105 core.sys.windows.winbase.Sleep(100); 106 107 for ( ; i <= 20 ; ++i) { 108 core.sys.windows.winbase.Sleep(30); 109 npp_api.pluginfunc.scintilla_msg.send_SCI_SETZOOM(curScintilla, i); 110 } 111 112 core.sys.windows.winbase.Sleep(100); 113 } 114 115 core.sys.windows.winbase.Sleep(100); 116 117 for ( ; i >= currentZoomLevel ; i--) { 118 core.sys.windows.winbase.Sleep(30); 119 npp_api.pluginfunc.scintilla_msg.send_SCI_SETZOOM(curScintilla, i); 120 } 121 122 return core.sys.windows.windef.TRUE; 123 } 124 125 /** 126 * 127 */ 128 extern (Windows) 129 nothrow @nogc 130 package core.sys.windows.windef.DWORD threadTextPlayer(void* text2display) 131 132 in 133 { 134 } 135 136 do 137 { 138 static import core.stdc.string; 139 static import core.stdc.time; 140 static import core.sys.windows.winbase; 141 static import core.sys.windows.windef; 142 static import npp_api.pluginfunc.npp_msgs; 143 static import npp_api.pluginfunc.scintilla_msg; 144 static import npp_api.powereditor.menucmdid; 145 static import npp_api.scintilla.scintilla; 146 147 enum RAND_MAX = 0x7FFF; 148 149 // Open a new document 150 npp_api.pluginfunc.npp_msgs.send_NPPM_MENUCOMMAND(.gshared_nppData._nppHandle, npp_api.powereditor.menucmdid.IDM_FILE_NEW); 151 152 // Get the current scintilla 153 int currentEdit = -1; 154 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(.gshared_nppData._nppHandle, currentEdit); 155 156 if (currentEdit == -1) { 157 return core.sys.windows.windef.FALSE; 158 } 159 160 core.sys.windows.windef.HWND curScintilla = (currentEdit == 0) ? (.gshared_nppData._scintillaMainHandle) : (.gshared_nppData._scintillaSecondHandle); 161 core.stdc.stdlib.srand(cast(uint)(core.stdc.time.time(core.sys.windows.windef.NULL))); 162 int rangeMin = 0; 163 int rangeMax = 250; 164 size_t length = core.stdc..string.strlen(cast(char*)(text2display)); 165 166 for (size_t i = 0 ; i < length; ++i) { 167 char[2] charToShow = [*((cast(char*)(text2display)) + i), '\0']; 168 169 version (none) { 170 int ranNum = rangeMin + cast(int)(cast(double)(core.stdc.stdlib.rand()) / (cast(double)(RAND_MAX) + 1) * rangeMax); 171 core.sys.windows.winbase.Sleep(ranNum + 30); 172 } 173 174 npp_api.pluginfunc.scintilla_msg.send_SCI_APPENDTEXT(curScintilla, 1, &(charToShow[0])); 175 npp_api.pluginfunc.scintilla_msg.send_SCI_GOTOPOS(curScintilla, npp_api.pluginfunc.scintilla_msg.send_SCI_GETLENGTH(curScintilla)); 176 } 177 178 return core.sys.windows.windef.TRUE; 179 } 180 181 /** 182 * plugin command 183 */ 184 extern (C) 185 nothrow @nogc 186 void hello() 187 188 do 189 { 190 static import core.sys.windows.windef; 191 static import npp_api.pluginfunc.npp_msgs; 192 static import npp_api.pluginfunc.scintilla_msg; 193 static import npp_api.powereditor.menucmdid; 194 195 // Open a new document 196 npp_api.pluginfunc.npp_msgs.send_NPPM_MENUCOMMAND(.nppData._nppHandle, npp_api.powereditor.menucmdid.IDM_FILE_NEW); 197 198 // Get the current scintilla 199 int currentEdit = -1; 200 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(.nppData._nppHandle, currentEdit); 201 202 if (currentEdit == -1) { 203 return; 204 } 205 206 core.sys.windows.windef.HWND curScintilla = (currentEdit == 0) ? (.nppData._scintillaMainHandle) : (.nppData._scintillaSecondHandle); 207 208 // Say hello now : 209 // Scintilla control has no Unicode mode, so we use (char*) here 210 enum string msg_text = "Hello, Notepad++!\0"; 211 npp_api.pluginfunc.scintilla_msg.send_SCI_SETTEXT(curScintilla, &(msg_text[0])); 212 } 213 214 /** 215 * plugin command 216 */ 217 extern (C) 218 nothrow @nogc 219 void helloFX() 220 221 do 222 { 223 static import core.sys.windows.basetsd; 224 static import core.sys.windows.winbase; 225 static import core.sys.windows.windef; 226 227 hello(); 228 core.sys.windows.basetsd.HANDLE hThread = core.sys.windows.winbase.CreateThread(core.sys.windows.windef.NULL, 0, &threadZoomer, core.sys.windows.windef.NULL, 0, core.sys.windows.windef.NULL); 229 core.sys.windows.winbase.CloseHandle(hThread); 230 } 231 232 /** 233 * plugin command 234 */ 235 extern (C) 236 nothrow @nogc 237 void WhatIsNpp() 238 239 do 240 { 241 static import core.sys.windows.basetsd; 242 static import core.sys.windows.winbase; 243 static import core.sys.windows.windef; 244 static import core.sys.windows.winnt; 245 246 string text2display = `Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. 247 Running in the MS Windows environment, its use is governed by GPL License. 248 249 Based on a powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. 250 By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.` ~ "\0"; 251 core.sys.windows.basetsd.HANDLE hThread = core.sys.windows.winbase.CreateThread(core.sys.windows.windef.NULL, 0, &.threadTextPlayer, cast(core.sys.windows.winnt.LPVOID*)(&(text2display[0])), 0, core.sys.windows.windef.NULL); 252 core.sys.windows.winbase.CloseHandle(hThread); 253 } 254 255 /** 256 * 257 */ 258 nothrow @nogc 259 void insertCurrentPath(int which) 260 261 do 262 { 263 static import core.sys.windows.windef; 264 static import core.sys.windows.winnls; 265 static import core.sys.windows.winnt; 266 static import core.sys.windows.winuser; 267 static import npp_api.pluginfunc.npp_msgs; 268 static import npp_api.pluginfunc.path; 269 static import npp_api.pluginfunc.scintilla_msg; 270 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 271 static import npp_api.scintilla.scintilla; 272 273 int msg; 274 275 switch (which) { 276 case npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.FILE_NAME: 277 msg = npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.NPPM_GETFILENAME; 278 279 break; 280 281 case npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.CURRENT_DIRECTORY: 282 msg = npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.NPPM_GETCURRENTDIRECTORY; 283 284 break; 285 286 default: 287 msg = npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.NPPM_GETFULLCURRENTPATH; 288 289 break; 290 } 291 292 int currentEdit; 293 core.sys.windows.winnt.WCHAR[npp_api.pluginfunc.path.OS_MAX_PATH] path = '\0'; 294 295 // A message to Notepad++ to get a multibyte string (if ANSI mode) or a wide char string (if Unicode mode) 296 core.sys.windows.winuser.SendMessageW(.nppData._nppHandle, msg, path.length, cast(core.sys.windows.windef.LPARAM)(&(path[0]))); 297 298 // 299 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(.nppData._nppHandle, currentEdit); 300 core.sys.windows.windef.HWND curScint = (currentEdit == 0) ? (.nppData._scintillaMainHandle) : (.nppData._scintillaSecondHandle); 301 302 int encoding = cast(int)(npp_api.pluginfunc.scintilla_msg.send_SCI_GETCODEPAGE(curScint)); 303 char[core.sys.windows.windef.MAX_PATH] pathA; 304 core.sys.windows.winnls.WideCharToMultiByte(encoding, 0, &(path[0]), -1, &(pathA[0]), core.sys.windows.windef.MAX_PATH, core.sys.windows.windef.NULL, core.sys.windows.windef.NULL); 305 npp_api.pluginfunc.scintilla_msg.send_SCI_REPLACESEL(curScint, &(pathA[0])); 306 } 307 308 /** 309 * plugin command 310 */ 311 extern (C) 312 nothrow @nogc 313 void insertCurrentFullPath() 314 315 do 316 { 317 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 318 319 .insertCurrentPath(npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.FULL_CURRENT_PATH); 320 } 321 322 /** 323 * plugin command 324 */ 325 extern (C) 326 nothrow @nogc 327 void insertCurrentFileName() 328 329 do 330 { 331 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 332 333 .insertCurrentPath(npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.FILE_NAME); 334 } 335 336 /** 337 * plugin command 338 */ 339 extern (C) 340 nothrow 341 void insertCurrentDirectory() 342 343 do 344 { 345 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 346 347 .insertCurrentPath(npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.CURRENT_DIRECTORY); 348 } 349 350 /** 351 * 352 */ 353 nothrow @nogc 354 void insertDateTime(bool format) 355 356 do 357 { 358 static import core.sys.windows.winbase; 359 static import core.sys.windows.windef; 360 static import core.sys.windows.winnls; 361 static import core.sys.windows.winnt; 362 static import core.sys.windows.winuser; 363 static import npp_api.pluginfunc.npp_msgs; 364 static import npp_api.pluginfunc.scintilla_msg; 365 static import npp_api.pluginfunc.string; 366 static import npp_api.scintilla.scintilla; 367 368 core.sys.windows.winnt.WCHAR[128] date; 369 core.sys.windows.winnt.WCHAR[128] time; 370 core.sys.windows.winnt.WCHAR[256] dateTime; 371 372 core.sys.windows.winbase.SYSTEMTIME st; 373 core.sys.windows.winbase.GetLocalTime(&st); 374 core.sys.windows.winnls.GetDateFormatW(core.sys.windows.winnls.LOCALE_USER_DEFAULT, ((format == .shortDate) ? (core.sys.windows.winnls.DATE_SHORTDATE) : (core.sys.windows.winnls.DATE_LONGDATE)), &st, core.sys.windows.windef.NULL, &(date[0]), 128); 375 core.sys.windows.winnls.GetTimeFormatW(core.sys.windows.winnls.LOCALE_USER_DEFAULT, core.sys.windows.winnls.TIME_NOSECONDS, &st, core.sys.windows.windef.NULL, &(time[0]), 128); 376 377 core.sys.windows.winuser.wsprintfW(&(dateTime[0]), &(npp_api.pluginfunc..string.c_wstring!("%s %s"w)[0]), &(time[0]), &(date[0])); 378 379 int currentEdit; 380 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(.nppData._nppHandle, currentEdit); 381 core.sys.windows.windef.HWND curScint = (currentEdit == 0) ? (.nppData._scintillaMainHandle) : (.nppData._scintillaSecondHandle); 382 int encoding = cast(int)(npp_api.pluginfunc.scintilla_msg.send_SCI_GETCODEPAGE(curScint)); 383 char[core.sys.windows.windef.MAX_PATH] dateTimeA; 384 core.sys.windows.winnls.WideCharToMultiByte(encoding, 0, &(dateTime[0]), -1, &(dateTimeA[0]), core.sys.windows.windef.MAX_PATH, core.sys.windows.windef.NULL, core.sys.windows.windef.NULL); 385 npp_api.pluginfunc.scintilla_msg.send_SCI_REPLACESEL(curScint, &(dateTimeA[0])); 386 } 387 388 /** 389 * plugin command 390 */ 391 extern (C) 392 nothrow @nogc 393 void insertShortDateTime() 394 395 do 396 { 397 .insertDateTime(.shortDate); 398 } 399 400 /** 401 * plugin command 402 */ 403 extern (C) 404 nothrow @nogc 405 void insertLongDateTime() 406 407 do 408 { 409 .insertDateTime(.longDate); 410 } 411 412 /** 413 * plugin command 414 */ 415 extern (C) 416 nothrow @nogc 417 void getFileNamesDemo() 418 419 do 420 { 421 static import core.stdc.stdio; 422 static import core.stdc.stdlib; 423 static import core.sys.windows.windef; 424 static import core.sys.windows.winnt; 425 static import core.sys.windows.winuser; 426 static import npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs; 427 static import npp_api.pluginfunc.npp_msgs; 428 429 size_t malloc_count = 0; 430 int nbFile = cast(int)(npp_api.pluginfunc.npp_msgs.send_NPPM_GETNBOPENFILES(.nppData._nppHandle, npp_api.powereditor.misc.pluginsmanager.notepad_plus_msgs.ALL_OPEN_FILES)); 431 char[16] temp = '\0'; 432 433 if (nbFile > 1) { 434 nbFile--; 435 } 436 437 core.stdc.stdio.snprintf(&(temp[0]), 4, &("%d\0"[0]), nbFile); 438 core.sys.windows.winuser.MessageBoxA(.nppData._nppHandle, &(temp[0]), &("Notepad++ opened files\0"[0]), core.sys.windows.winuser.MB_OK); 439 440 core.sys.windows.winnt.WCHAR** fileNames = cast(core.sys.windows.winnt.WCHAR**)(core.stdc.stdlib.malloc((core.sys.windows.winnt.WCHAR*).sizeof * nbFile)); 441 442 if (fileNames == null) { 443 return; 444 } 445 446 scope (exit) { 447 core.stdc.stdlib.free(fileNames); 448 fileNames = null; 449 } 450 451 for (size_t i = 0 ; i < nbFile; ++i) { 452 *(fileNames + i) = cast(core.sys.windows.winnt.WCHAR*)(core.stdc.stdlib.malloc(core.sys.windows.winnt.WCHAR.sizeof * core.sys.windows.windef.MAX_PATH)); 453 454 if ((*(fileNames + i)) == null) { 455 for (size_t j; j < malloc_count; ++j) { 456 core.stdc.stdlib.free(*(fileNames + j)); 457 } 458 459 return; 460 } 461 462 ++malloc_count; 463 } 464 465 scope (exit) { 466 for (size_t j; j < malloc_count; ++j) { 467 core.stdc.stdlib.free(*(fileNames + j)); 468 fileNames[j] = null; 469 } 470 } 471 472 if (npp_api.pluginfunc.npp_msgs.send_NPPM_GETOPENFILENAMES(.nppData._nppHandle, fileNames, nbFile)) { 473 for (size_t i = 0 ; i < nbFile; ++i) { 474 core.sys.windows.winuser.MessageBoxW(.nppData._nppHandle, *(fileNames + i), &("\0"w[0]), core.sys.windows.winuser.MB_OK); 475 } 476 } 477 } 478 479 /** 480 * plugin command 481 */ 482 extern (C) 483 nothrow @nogc 484 void getSessionFileNamesDemo() 485 486 do 487 { 488 static import core.stdc.stdio; 489 static import core.stdc.stdlib; 490 static import core.sys.windows.windef; 491 static import core.sys.windows.winnt; 492 static import core.sys.windows.winuser; 493 static import npp_api.pluginfunc.npp_msgs; 494 static import npp_api.pluginfunc.string; 495 496 size_t malloc_count = 0; 497 const core.sys.windows.winnt.WCHAR[] sessionFullPath = npp_api.pluginfunc..string.c_wstring!("c:\\test.session"w); 498 char[16] temp = '\0'; 499 size_t nbFile = npp_api.pluginfunc.npp_msgs.send_NPPM_GETNBSESSIONFILES(.nppData._nppHandle, &(sessionFullPath[0])); 500 501 if (nbFile == 0) { 502 core.sys.windows.winuser.MessageBoxW(.nppData._nppHandle, &(npp_api.pluginfunc..string.c_wstring!("Please modify \"sessionFullPath\" in \"NppInsertPlugin.cpp\" in order to point to a valide session file")[0]), &(npp_api.pluginfunc..string.c_wstring!("Error :"w)[0]), core.sys.windows.winuser.MB_OK); 503 504 return; 505 } 506 507 core.stdc.stdio.snprintf(&(temp[0]), 4, &("%d\0"[0]), nbFile); 508 core.sys.windows.winuser.MessageBoxA(.nppData._nppHandle, &(temp[0]), &("Notepad++ session files\0"[0]), core.sys.windows.winuser.MB_OK); 509 510 core.sys.windows.winnt.WCHAR** fileNames = cast(core.sys.windows.winnt.WCHAR**)(core.stdc.stdlib.malloc((core.sys.windows.winnt.WCHAR*).sizeof * nbFile)); 511 512 if (fileNames == null) { 513 return; 514 } 515 516 scope (exit) { 517 core.stdc.stdlib.free(fileNames); 518 fileNames = null; 519 } 520 521 for (size_t i = 0 ; i < nbFile; ++i) { 522 *(fileNames + i) = cast(core.sys.windows.winnt.WCHAR*)(core.stdc.stdlib.malloc(core.sys.windows.winnt.WCHAR.sizeof * core.sys.windows.windef.MAX_PATH)); 523 524 if ((*(fileNames + i)) == null) { 525 for (size_t j; j < malloc_count; ++j) { 526 core.stdc.stdlib.free(*(fileNames + j)); 527 } 528 529 return; 530 } 531 532 ++malloc_count; 533 } 534 535 scope (exit) { 536 for (size_t j; j < malloc_count; ++j) { 537 core.stdc.stdlib.free(*(fileNames + j)); 538 fileNames[j] = null; 539 } 540 } 541 542 if (npp_api.pluginfunc.npp_msgs.send_NPPM_GETSESSIONFILES(.nppData._nppHandle, fileNames, &(sessionFullPath[0]))) { 543 for (size_t i = 0 ; i < nbFile ; ++i) { 544 core.sys.windows.winuser.MessageBoxW(.nppData._nppHandle, *(fileNames + i), &(npp_api.pluginfunc..string.c_wstring!("session file name :"w)[0]), core.sys.windows.winuser.MB_OK); 545 } 546 } 547 } 548 549 /** 550 * plugin command 551 */ 552 extern (C) 553 nothrow @nogc 554 void saveCurrentSessionDemo() 555 556 do 557 { 558 static import core.sys.windows.windef; 559 static import core.sys.windows.winnt; 560 static import core.sys.windows.winuser; 561 static import npp_api.pluginfunc.npp_msgs; 562 static import npp_api.pluginfunc.string; 563 564 const (core.sys.windows.winnt.WCHAR)* sessionPath = npp_api.pluginfunc.npp_msgs.send_NPPM_SAVECURRENTSESSION(.nppData._nppHandle, core.sys.windows.windef.NULL); 565 566 if (sessionPath != null) { 567 core.sys.windows.winuser.MessageBoxW(.nppData._nppHandle, sessionPath, &(npp_api.pluginfunc..string.c_wstring!("Saved Session File :"w)[0]), core.sys.windows.winuser.MB_OK); 568 } 569 } 570 571 /** 572 * plugin command 573 * Dockable Dialog Demo 574 * 575 * This demonstration shows you how to do a dockable dialog. 576 * You can create your own non dockable dialog - in this case you don't nedd this demonstration. 577 * You have to create your dialog by inherented DockingDlgInterface class in order to make your dialog dockable 578 * - please see DemoDlg.h and DemoDlg.cpp to have more informations. 579 */ 580 extern (C) 581 nothrow 582 void DockableDlgDemo() 583 584 do 585 { 586 static import core.sys.windows.windef; 587 static import core.sys.windows.winuser; 588 static import npp_api.pluginfunc.npp_msgs; 589 static import npp_api.powereditor.wincontrols.dockingwnd.docking; 590 static import npp_demo.gotolinedlg; 591 static import npp_demo.plugin_dll; 592 593 npp_demo.gotolinedlg._goToLine.setParent(.gshared_nppData._nppHandle); 594 npp_api.powereditor.wincontrols.dockingwnd.docking.tTbData data; 595 596 try { 597 if (!npp_demo.gotolinedlg._goToLine.isCreated()) { 598 npp_demo.gotolinedlg._goToLine.create(&npp_demo.gotolinedlg._goToLine, data); 599 600 // define the default docking behaviour 601 data.uMask = npp_api.powereditor.wincontrols.dockingwnd.docking.DWS_DF_CONT_RIGHT; 602 603 data.pszModuleName = npp_demo.gotolinedlg._goToLine.getPluginFileName(); 604 605 // the dlgDlg should be the index of func_list where the current function pointer is 606 // in this case is DOCKABLE_DEMO_INDEX 607 data.dlgID = .DOCKABLE_DEMO_INDEX; 608 npp_api.pluginfunc.npp_msgs.send_NPPM_DMMREGASDCKDLG(.gshared_nppData._nppHandle, &data); 609 } 610 611 npp_demo.gotolinedlg._goToLine.display(); 612 } catch (Exception e) { 613 //ToDo: 614 core.sys.windows.winuser.MessageBoxW(.nppData._nppHandle, &("Exception\0"w[0]), &(npp_demo.plugin_dll.plugin_name[0]), core.sys.windows.winuser.MB_OK); 615 } 616 }