-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUnmanagedExports.cs
61 lines (55 loc) · 1.92 KB
/
UnmanagedExports.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Runtime.InteropServices;
using NppPluginNET;
using NppPlugin.DllExport;
namespace NppHashMaker
{
class UnmanagedExports
{
[DllExport(CallingConvention=CallingConvention.Cdecl)]
static bool isUnicode()
{
return true;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static void setInfo(NppData notepadPlusData)
{
PluginBase.nppData = notepadPlusData;
Main.CommandMenuInit();
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static IntPtr getFuncsArray(ref int nbF)
{
nbF = PluginBase._funcItems.Items.Count;
return PluginBase._funcItems.NativePointer;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static uint messageProc(uint Message, IntPtr wParam, IntPtr lParam)
{
return 1;
}
static IntPtr _ptrPluginName = IntPtr.Zero;
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static IntPtr getName()
{
if (_ptrPluginName == IntPtr.Zero)
_ptrPluginName = Marshal.StringToHGlobalUni(Main.PluginName);
return _ptrPluginName;
}
[DllExport(CallingConvention = CallingConvention.Cdecl)]
static void beNotified(IntPtr notifyCode)
{
SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification));
if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)
{
PluginBase._funcItems.RefreshItems();
Main.SetToolBarIcon();
}
else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN)
{
Main.PluginCleanUp();
Marshal.FreeHGlobal(_ptrPluginName);
}
}
}
}