<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[plugin template, docking feature, and c++ core guidelines]]></title><description><![CDATA[<p dir="auto">I’ve been footling around with an existing plugin and I thought I’d try applying the c++ core guideline document (as MSVC has support for them) to the project</p>
<p dir="auto">It produced a bimcj of warnings for dockingfeature code from the plugin template (<a href="https://github.com/npp-plugins/plugintemplate" rel="nofollow ugc">https://github.com/npp-plugins/plugintemplate</a>) for methods not being noexcept.</p>
<p dir="auto">Having had a look at them, I’m a little confused, as there’s no documentation explaining this.</p>
<p dir="auto">In no particular order:</p>
<p dir="auto">There’s a lot of virtual functions in Window.h where it seems odd for them to be virtual. (getWindowRect for instance).</p>
<p dir="auto">It also ends up with the slightly odd situation that getHeight returns 0 if the window isn’t visible, but it doesn’t use the isVisible method (leading to code-nearly-duplication) - presumably because that is a virtual method and might have a different idea as to whether or not the window is visible to what windows does.</p>
<p dir="auto">Additionally two of the functions are commented as ‘should NEVER be const’ without any explanation as to why, because they <em>look</em> pretty const.</p>
<p dir="auto">Adding noexcept to a virtual function is generally a bit risky, as you don’t know how clients are going to override it, but I’m not sure I can see the point of overriding (e.g.) getHeight.</p>
<p dir="auto">Also (in passing) the getFocus method should probably be called setFocus.</p>
<p dir="auto">I suppose I should also point out that the init() method looks like a constructor, and why isn’t it one? At least in the plugin I’m working on, by the time it needs to create the docked window, it already knows enough to call the init method from the constructor for the class controlling the docked window.</p>
<p dir="auto">So I guess what I’m asking is ‘why?’, and what versions of C++ are used by plugins, and whether anyone either does or should rely on some of these methods being virtual.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/25103/plugin-template-docking-feature-and-c-core-guidelines</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 15:06:40 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/25103.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Nov 2023 08:56:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Mon, 06 Nov 2023 06:51:02 GMT]]></title><description><![CDATA[<p dir="auto">The essential point to remember is that the every facet of the API surface is C-compatible, just like the Win32 API, which underlies all of N++'s internal functions. The details of how N++ dispatches plugin messages naturally involves a few C++ semantics, because it’s a C++ application. Plugins can implement their own C++ types, too, but nothing in the API says they <em>have to</em>. If you just want to display a free-floating form, you can use whatever functions your plugin natively supports, from <code>::CreateDialogParam</code> to <code>System.Windows.Forms.Form.ShowDialog</code>.</p>
<p dir="auto">The (poorly documented) purpose of the docking API is to register a form with the Docking Manager. In practice, that means preserving the form’s position and geometry in <code>config.xml</code>, so that N++ can optionally reload it when the application starts. To do that, a plugin sends <code>NPPM_DMMREGASDCKDLG</code> with a pointer to a C-like structure filled with some basic parameters, <a href="https://npp-user-manual.org/docs/plugin-communication/#2057-nppm-dmmregasdckdlg" rel="nofollow ugc">as shown</a> in the developers’ manual.</p>
<p dir="auto">The form’s creation is entirely up to the plugin. N++ simply invokes the function that creates the form by <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/cb1f2d1479895d2a365eb34b79cd4697e00655f3/PowerEditor/src/Notepad_plus.cpp#L838-L844" rel="nofollow ugc">calling through a function pointer</a>. No plugin is required to instantiate a <code>DockingCont</code> or any other object derived from a C++ class. Examples of plugins that do this anyway are special cases, not illustrations of how the docking API works.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90315</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90315</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Mon, 06 Nov 2023 06:51:02 GMT</pubDate></item><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Mon, 06 Nov 2023 02:59:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/rdipardo" aria-label="Profile: rdipardo">@<bdi>rdipardo</bdi></a> said in <a href="/post/90312">plugin template, docking feature, and c++ core guidelines</a>:</p>
<blockquote>
<p dir="auto">To be precise, the LPARAM is converted to a DockingCont pointer by means of reinterpret_cast . The plugin only needs to provide the equivalent of an opaque pointer. It’s the job of N++ to (re-)interpret that pointer as something it can use.</p>
</blockquote>
<p dir="auto">Thank you for that clarification. I think I see, somewhat. The only reference to <strong>DockingCont</strong> in the plugin template is <a href="https://github.com/npp-plugins/plugintemplate/blob/fd051e4cadaa2adcbedfdc27a817bc72eb0ae174/src/DockingFeature/dockingResource.h#L65" rel="nofollow ugc">in a comment</a>. So your point, I take it, is that the pointer to <strong>DockingCont</strong> is opaque <em>to the plugin</em>; the address is something that would come from Notepad++. In the absence of documentation, though, it is not obvious — to me, anyway — how this pointer would be obtained. But then, it could be that the messages that use it (like <strong>DMM_FLOAT</strong>) are meant for Notepad++ internal use, and they’re only in the plugin demo code because they’re in the same file as the <strong>DMN_</strong>* notifications, which are apparently sent to the dialog procedure for the dockable dialog and must be meant for use by plugins.</p>
<p dir="auto">So, are we back to what I speculated earlier (and then doubted): that it <em>is</em> a C interface, and the <strong>DockingDlgInterface</strong> based on <strong>StaticDialog</strong> based on <strong>Window</strong> classes are just part of an example, not structures that need to be present as such in a plugin that implements a dockable dialog?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90313</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90313</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Mon, 06 Nov 2023 02:59:08 GMT</pubDate></item><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Mon, 06 Nov 2023 02:01:28 GMT]]></title><description><![CDATA[<blockquote>
<p dir="auto">I’m seeing that the <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/950236bb8f8e85d678912939c00183e85c6417f6/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp#L361" rel="nofollow ugc">DMM_FLOAT message in Notepad++</a> expects LPARAM to be a pointer to a <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/950236bb8f8e85d678912939c00183e85c6417f6/PowerEditor/src/WinControls/DockingWnd/DockingCont.h#L46" rel="nofollow ugc">DockingCont</a>, which is based on a <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/src/WinControls/StaticDialog" rel="nofollow ugc">StaticDialog</a> . . .</p>
</blockquote>
<p dir="auto">To be precise, the LPARAM is <em>converted</em> to a <code>DockingCont</code> pointer by means of <a href="https://en.cppreference.com/w/cpp/language/reinterpret_cast" rel="nofollow ugc">reinterpret_cast</a>. The plugin only needs to provide the equivalent of an opaque pointer. It’s the job of N++ to (re-)interpret that pointer as something it can use.</p>
<p dir="auto">It follows that <em>any</em> compiled language capable of addressing objects via pointers can use the plugin API. See, for example, the many re-implementations of the plugin template in <a href="https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net/blob/4f7a4d427e988d2a02615c54b5f893f44696a6f7/Visual%20Studio%20Project%20Template%20C%23/PluginInfrastructure/Docking_h.cs#L43" rel="nofollow ugc">C#</a>, <a href="https://bitbucket.org/rdipardo/delphiplugintemplate/src/b8bf754bc9d7a7903b030b40f8de6c8c0bc2d5d7/Source/Include/Npp.inc#lines-739" rel="nofollow ugc">Object Pascal</a> (and derivatives like <a href="https://en.wikipedia.org/wiki/Modula-2" rel="nofollow ugc">Modula-2</a> — e.g., the <a href="https://sourceforge.net/projects/npp-plugins/files/WebEdit/WebEdit%202.1/" rel="nofollow ugc">WebEdit</a> plugin), <a href="https://github.com/Ekopalypse/EnhanceAnyLexer/blob/e6321ae8e2e55112a2cbf72bc5dba453f75c1810/notepadpp/notepadpp.v#L11C25-L11C25" rel="nofollow ugc">V</a>, etc.</p>
<hr />
]]></description><link>https://community.notepad-plus-plus.org/post/90312</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90312</guid><dc:creator><![CDATA[rdipardo]]></dc:creator><pubDate>Mon, 06 Nov 2023 02:01:28 GMT</pubDate></item><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Sun, 05 Nov 2023 21:05:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thosrtanner" aria-label="Profile: ThosRTanner">@<bdi>ThosRTanner</bdi></a> said in <a href="/post/90308">plugin template, docking feature, and c++ core guidelines</a>:</p>
<blockquote>
<p dir="auto">DMN_DOCK message is sent to the plugin</p>
</blockquote>
<p dir="auto">I see. It does look like a number of messages and notifications are defined in <a href="https://github.com/npp-plugins/plugintemplate/blob/master/src/DockingFeature/dockingResource.h" rel="nofollow ugc">dockingResource.h</a> — and not listed in the <a href="https://npp-user-manual.org/docs/plugin-communication/" rel="nofollow ugc">Plugin Communication</a> section of the help.</p>
<blockquote>
<p dir="auto">undocked dialogues - not that I can find out how to make that happen</p>
</blockquote>
<p dir="auto">The user can drag the dialog into or out of the dock. Aside from that, I’d guess one sends the DMM_FLOAT message from dockingResource.h… which, on examination, leads me to retract most of what I said earlier in this thread.</p>
<p dir="auto">My presumption — that the interface for docking dialogs would be a C interface, like everything else for plugins — appears to have been mistaken. I’m seeing that the <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/950236bb8f8e85d678912939c00183e85c6417f6/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp#L361" rel="nofollow ugc">DMM_FLOAT message in Notepad++</a> expects LPARAM to be a pointer to a <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/950236bb8f8e85d678912939c00183e85c6417f6/PowerEditor/src/WinControls/DockingWnd/DockingCont.h#L46" rel="nofollow ugc">DockingCont</a>, which is based on a <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/src/WinControls/StaticDialog" rel="nofollow ugc">StaticDialog</a>, which is very much a C++ structure, not a C structure.</p>
<p dir="auto">So perhaps it is necessary to copy the entire set of C++ declarations: it looks like Notepad++ expects to see a very specific structure surrounding a docking dialog. That would also mean the compiler for a plugin that implements a docking dialog must be ABI compatible with the one used to compile Notepad++.</p>
<p dir="auto">All of which points back to the concerns in your original post being valid.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90311</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90311</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Sun, 05 Nov 2023 21:05:17 GMT</pubDate></item><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Sun, 05 Nov 2023 19:58:46 GMT]]></title><description><![CDATA[<p dir="auto">Hmmm. I’ve tried debugging this and found that the DMN_DOCK message is sent to the plugin, from <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/07041f456545b8339323d2b0441007923bec7571/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp#L691" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/blob/07041f456545b8339323d2b0441007923bec7571/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp#L691</a></p>
<p dir="auto">Which sort of implies that it is (or was) possible to have undocked dialogues - not that I can find out how to make that happen.</p>
<p dir="auto">So that header is also required.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90308</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90308</guid><dc:creator><![CDATA[ThosRTanner]]></dc:creator><pubDate>Sun, 05 Nov 2023 19:58:46 GMT</pubDate></item><item><title><![CDATA[Reply to plugin template, docking feature, and c++ core guidelines on Sat, 04 Nov 2023 17:51:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/thosrtanner" aria-label="Profile: ThosRTanner">@<bdi>ThosRTanner</bdi></a></p>
<p dir="auto">I haven’t written a plugin that uses the docking interface, but as far as I can tell, the only mandatory part of the DockingFeature folder is <a href="https://github.com/npp-plugins/plugintemplate/blob/master/src/DockingFeature/Docking.h" rel="nofollow ugc">Docking.h</a>, which is required by the <a href="https://npp-user-manual.org/docs/plugin-communication/#2057-nppm-dmmregasdckdlg" rel="nofollow ugc">NPPM_DMMREGASDCKDLG</a> method.</p>
<p dir="auto">The rest appears to form a C++ wrapper around a Windows dialog. It looks as if it is taken from Notepad++ source (<a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/src/WinControls/Window.h" rel="nofollow ugc">Window.h</a>, <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/src/WinControls/StaticDialog" rel="nofollow ugc">StaticDialog</a> and <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/tree/master/PowerEditor/src/WinControls/DockingWnd" rel="nofollow ugc">DockingWnd</a>); so my guess is that the GoToLineDlg example in the template was built up as quickly as possible based on structures and logic already available and familiar to Notepad++ authors.</p>
<p dir="auto">My point being that most of that code was written for Notepad++. My guess is that it was carried over intact as a quick way to build an example, not built from scratch in such a way that everything in it would make sense in the context of a typical plugin. Trying to “rationalize” it from that perspective is probably not possible.</p>
<p dir="auto">As I wrote above, I haven’t attempted to write a dockable dialog. If I were to do so, I would begin by taking only the Docking.h file as normative, and look to the rest only as a resource for discovering what a docking dialog is expected to do. Of course, actually trying that might change my mind…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90295</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90295</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Sat, 04 Nov 2023 17:51:38 GMT</pubDate></item></channel></rss>