NppPluginNETBase.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. namespace Demo
  3. {
  4. partial class PluginBase
  5. {
  6. #region " Fields "
  7. internal static NppData NppData;
  8. internal static FuncItems FuncItems = new FuncItems();
  9. #endregion
  10. #region " Helper "
  11. internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer)
  12. {
  13. SetCommand(index, commandName, functionPointer, new ShortcutKey(), false);
  14. }
  15. internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut)
  16. {
  17. SetCommand(index, commandName, functionPointer, shortcut, false);
  18. }
  19. internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, bool checkOnInit)
  20. {
  21. SetCommand(index, commandName, functionPointer, new ShortcutKey(), checkOnInit);
  22. }
  23. internal static void SetCommand(int index, string commandName, NppFuncItemDelegate functionPointer, ShortcutKey shortcut, bool checkOnInit)
  24. {
  25. var funcItem = new FuncItem();
  26. funcItem._cmdID = index;
  27. funcItem._itemName = commandName;
  28. if (functionPointer != null)
  29. funcItem._pFunc = new NppFuncItemDelegate(functionPointer);
  30. if (shortcut._key != 0)
  31. funcItem._pShKey = shortcut;
  32. funcItem._init2Check = checkOnInit;
  33. FuncItems.Add(funcItem);
  34. }
  35. internal static IntPtr GetCurrentScintilla()
  36. {
  37. int curScintilla;
  38. Win32.SendMessage(NppData._nppHandle, NppMsg.NPPM_GETCURRENTSCINTILLA, 0, out curScintilla);
  39. return (curScintilla == 0) ? NppData._scintillaMainHandle : NppData._scintillaSecondHandle;
  40. }
  41. #endregion
  42. }
  43. }