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 DLL interface 19 * 20 * License: GPL-2.0 or later 21 */ 22 module npp_demo.gotolinedlg; 23 24 25 private static import core.sys.windows.basetsd; 26 private static import core.sys.windows.windef; 27 private static import core.sys.windows.winuser; 28 private static import npp_api.powereditor.misc.pluginsmanager.plugininterface; 29 private static import npp_api.powereditor.scitillacomponent.gotolinedlg; 30 private static import npp_api.pluginfunc.scintilla_msg; 31 private static import npp_api.powereditor.wincontrols.dockingwnd.dockingdlginterface; 32 private static import npp_api.pluginfunc.npp_msgs; 33 private static import npp_demo.resource; 34 35 extern (C) 36 extern npp_api.powereditor.misc.pluginsmanager.plugininterface.NppData nppData; 37 38 extern (C) 39 extern __gshared npp_api.powereditor.misc.pluginsmanager.plugininterface.NppData gshared_nppData; 40 41 class demo_dlg : npp_api.powereditor.wincontrols.dockingwnd.dockingdlginterface.DockingDlgInterface 42 { 43 pure nothrow @safe @nogc 44 this() 45 46 do 47 { 48 super(npp_demo.resource.IDD_PLUGINGOLINE_DEMO); 49 } 50 51 nothrow @nogc 52 override void display(bool toShow = true) 53 54 do 55 { 56 super.display(toShow); 57 58 if (toShow) { 59 core.sys.windows.winuser.SetFocus(core.sys.windows.winuser.GetDlgItem(this._hSelf, npp_demo.resource.ID_GOLINE_EDIT)); 60 } 61 } 62 63 nothrow @nogc 64 void setParent(core.sys.windows.windef.HWND parent2set) 65 66 do 67 { 68 this._hParent = parent2set; 69 } 70 71 protected: 72 extern (Windows) 73 nothrow @nogc 74 override core.sys.windows.basetsd.INT_PTR run_dlgProc(core.sys.windows.windef.UINT message, core.sys.windows.windef.WPARAM wParam, core.sys.windows.windef.LPARAM lParam) 75 76 do 77 { 78 switch (message) { 79 case core.sys.windows.winuser.WM_COMMAND: 80 switch (wParam) { 81 case core.sys.windows.winuser.IDOK: 82 npp_api.pluginfunc.scintilla_msg.line line = this.getLine(); 83 84 if (line != -1) { 85 // Get the current scintilla 86 int which = -1; 87 npp_api.pluginfunc.npp_msgs.send_NPPM_GETCURRENTSCINTILLA(gshared_nppData._nppHandle, which); 88 89 if (which == -1) { 90 return core.sys.windows.windef.FALSE; 91 } 92 93 core.sys.windows.windef.HWND curScintilla = (which == 0) ? (gshared_nppData._scintillaMainHandle) : (gshared_nppData._scintillaSecondHandle); 94 95 npp_api.pluginfunc.scintilla_msg.send_SCI_ENSUREVISIBLE(curScintilla, line - 1); 96 npp_api.pluginfunc.scintilla_msg.send_SCI_GOTOLINE(curScintilla, line - 1); 97 } 98 99 return core.sys.windows.windef.TRUE; 100 101 default: 102 break; 103 } 104 105 return core.sys.windows.windef.FALSE; 106 107 default: 108 return super.run_dlgProc(message, wParam, lParam); 109 } 110 } 111 112 private: 113 nothrow @nogc 114 npp_api.pluginfunc.scintilla_msg.line getLine() 115 116 do 117 { 118 core.sys.windows.windef.BOOL isSuccessful; 119 npp_api.pluginfunc.scintilla_msg.line line = core.sys.windows.winuser.GetDlgItemInt(this._hSelf, npp_demo.resource.ID_GOLINE_EDIT, &isSuccessful, core.sys.windows.windef.FALSE); 120 121 return (isSuccessful) ? (line) : (-1); 122 } 123 } 124 125 .demo_dlg _goToLine;