12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using System;
- using System.Runtime.InteropServices;
- namespace Demo
- {
- internal class UnmanagedExports
- {
- [DllExport(ExportName = "isUnicode", CallingConvention = CallingConvention.Cdecl)]
- private static bool IsUnicode()
- {
- return true;
- }
- [DllExport(ExportName = "setInfo", CallingConvention = CallingConvention.Cdecl)]
- private static void SetInfo(NppData notepadPlusData)
- {
- PluginBase.NppData = notepadPlusData;
- PluginBase.CommandMenuInit();
- }
- [DllExport(ExportName = "getFuncsArray", CallingConvention = CallingConvention.Cdecl)]
- private static IntPtr GetFuncsArray(ref int nbF)
- {
- nbF = PluginBase.FuncItems.Items.Count;
- return PluginBase.FuncItems.NativePointer;
- }
- [DllExport(ExportName = "messageProc", CallingConvention = CallingConvention.Cdecl)]
- private static uint MessageProc(uint message, IntPtr wParam, IntPtr lParam)
- {
- return 1;
- }
- private static IntPtr _ptrPluginName = IntPtr.Zero;
- [DllExport(ExportName = "getName", CallingConvention = CallingConvention.Cdecl)]
- private static IntPtr GetName()
- {
- if (_ptrPluginName == IntPtr.Zero)
- _ptrPluginName = Marshal.StringToHGlobalUni(PluginBase.PluginName);
- return _ptrPluginName;
- }
- [DllExport(ExportName = "beNotified", CallingConvention = CallingConvention.Cdecl)]
- private static void BeNotified(IntPtr notifyCode)
- {
- var nc = (ScNotification)Marshal.PtrToStructure(notifyCode, typeof(ScNotification));
- if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)
- {
- PluginBase.FuncItems.RefreshItems();
- PluginBase.SetToolBarIcon();
- }
- else if (nc.nmhdr.code == (uint)SciMsg.SCN_CHARADDED)
- {
- PluginBase.DoInsertHtmlCloseTag((char)nc.ch);
- }
- else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN)
- {
- PluginBase.PluginCleanUp();
- Marshal.FreeHGlobal(_ptrPluginName);
- }
- }
- }
- }
|