Skip to content

Commit 2f3fba3

Browse files
Keep dialog visible on start.
1 parent eafa43f commit 2f3fba3

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

NppNavigateTo/NppNavigateTo.cs

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using System.Runtime.InteropServices;
88
using NavigateTo.Tests;
99
using Kbg.NppPluginNET.PluginInfrastructure;
10+
using NavigateTo.Plugin.Namespace;
11+
using NppPluginNET;
1012

1113
namespace Kbg.NppPluginNET
1214
{
@@ -24,7 +26,7 @@ static internal void PluginCleanUp()
2426
NavigateTo.Plugin.Namespace.Main.frmNavigateTo.Close();
2527
}
2628

27-
if (NavigateTo.Plugin.Namespace.Main.frmNavigateTo != null)
29+
if (NavigateTo.Plugin.Namespace.Main.frmSettings != null)
2830
{
2931
NavigateTo.Plugin.Namespace.Main.frmSettings.Close();
3032
}
@@ -41,6 +43,9 @@ public static void OnNotification(ScNotification notification)
4143
{
4244
switch (notification.Header.Code)
4345
{
46+
case (uint)NppMsg.NPPN_READY:
47+
NavigateTo.Plugin.Namespace.Main.NavigateToDlg();
48+
break;
4449
case (uint)NppMsg.NPPN_BEFORESHUTDOWN:
4550
NavigateTo.Plugin.Namespace.Main.isShuttingDown = true;
4651
break;
@@ -153,7 +158,7 @@ static internal void PluginCleanUp()
153158

154159
#region " Menu functions "
155160

156-
static void NavigateToDlg()
161+
public static void NavigateToDlg()
157162
{
158163
if (frmNavigateTo == null)
159164
{
@@ -182,9 +187,23 @@ static void NavigateToDlg()
182187
IntPtr _ptrNppTbData = Marshal.AllocHGlobal(Marshal.SizeOf(_nppTbData));
183188
Marshal.StructureToPtr(_nppTbData, _ptrNppTbData, false);
184189
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMREGASDCKDLG, 0, _ptrNppTbData);
185-
// Following message will toogle both menu item state and toolbar button
186-
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
187-
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 1);
190+
191+
if (FrmSettings.Settings.GetBoolSetting(Settings.keepDlgOpen))
192+
{
193+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMSHOW, 0,
194+
frmNavigateTo.Handle);
195+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
196+
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 1);
197+
frmNavigateTo.GrabFocus();
198+
}
199+
else
200+
{
201+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_DMMHIDE, 0,
202+
frmNavigateTo.Handle);
203+
Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK,
204+
PluginBase._funcItems.Items[idFormNavigateAll]._cmdID, 0);
205+
editor.GrabFocus();
206+
}
188207
}
189208
else
190209
{

0 commit comments

Comments
 (0)