private void UnmanagedEvents_BeNotified(object sender, UnmanagedEvents.NppNotifyEventArgs e) { NppMsg msgCode = (NppMsg)e.Notification.nmhdr.code; switch (msgCode) { case NppMsg.NPPN_TBMODIFICATION: _funcItems.RefreshItems(); SetToolBarIcon(); break; case NppMsg.NPPN_SHUTDOWN: PluginCleanUp(); break; case NppMsg.NPPN_BUFFERACTIVATED: //this seems to fit mostly for file opened if (_gitWindow != null && _gitWindow.Visible) { _gitWindow.FileChanged(); } break; default: Trace.TraceInformation($"BeNotified unhandled: {msgCode.ToString()}"); break; } }
/// <summary> /// Sends the message. /// </summary> /// <param name="editor">The editor.</param> /// <param name="Msg">The MSG.</param> /// <param name="wParam">The w parameter.</param> /// <param name="lParam">The l parameter.</param> /// <param name="expectedSize">The expected size.</param> public static void SendMessage(this NotepadPPGateway editor, NppMsg Msg, int wParam, out string lParam, int expectedSize = 2000) { var path = new StringBuilder(expectedSize); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETFULLCURRENTPATH, path.Capacity, path); lParam = path.ToString(); }
public static IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, out string lParam) { var text = new StringBuilder(Win32.MAX_PATH); IntPtr retval = Win32.SendMessage(hWnd, (uint)Msg, wParam, text); lParam = text.ToString(); return(retval); }
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, out string lParam) { var text = new StringBuilder(MaxPath); IntPtr retval = SendMessage(hWnd, msg, 0, text); lParam = text.ToString(); return(retval); }
public static string GetStringFromNpp(NppMsg message) { message = message | NppMsg.RUNCOMMAND_USER; StringBuilder sb = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(NppHandle, message, 0, sb); return(sb.ToString()); }
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, out long lParam) { IntPtr outVal; IntPtr retval = SendMessage(hWnd, (uint)msg, new IntPtr(wParam), out outVal); lParam = outVal.ToInt64(); return(retval); }
static string currentDir() { NppMsg msg = NppMsg.NPPM_GETCURRENTDIRECTORY; StringBuilder path = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, msg, 0, path); return(path.ToString()); }
/// <summary> /// /// </summary> /// <param name="show"></param> /// <returns></returns> public void ToggleToolbarIcon(bool show = true) { //To show or not to show NppMsg msg = show ? NppMsg.NPPM_DMMSHOW : NppMsg.NPPM_DMMHIDE; // Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)msg, 0, this.renderer.Handle); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_SETMENUITEMCHECK, PluginBase._funcItems.Items[this.commandId]._cmdID, show ? 1 : 0); // this.rendererVisible = this.renderer.Visible; }
/// <summary> /// This method incapsulates a common pattern in the Notepad++ API: when /// you need to retrieve a string, you can first query the buffer size. /// This method queries the necessary buffer size, allocates the temporary /// memory, then returns the string retrieved through that buffer. /// </summary> /// <param name="message">Message ID of the data string to query.</param> /// <returns>String returned by Notepad++.</returns> public string GetString(NppMsg message) { int len = Win32.SendMessage( PluginBase.nppData._nppHandle, (uint)message, Unused, Unused).ToInt32() + 1; var res = new StringBuilder(len); _ = Win32.SendMessage( PluginBase.nppData._nppHandle, (uint)message, len, res); return(res.ToString()); }
/// <summary> /// Return name of active file /// </summary> /// <returns></returns> public static string GetNameOfActiveFile() { string name = ""; NppMsg msg = NppMsg.NPPM_GETFULLCURRENTPATH; StringBuilder path = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, msg, 0, path); name = path.ToString(); return(name); }
/// <summary> /// Gets the file path of each file currently opened in the secondary view /// </summary> /// <returns></returns> private static List <string> GetOpenedFilesIn(NppMsg view, NppMsg mode) { var output = new List <string>(); int nbFile = (int)Win32Api.SendMessage(Handle, NppMsg.NPPM_GETNBOPENFILES, 0, (int)view); using (Win32Api.UnmanagedStringArray cStrArray = new Win32Api.UnmanagedStringArray(nbFile, Win32Api.MaxPath)) { if (Win32Api.SendMessage(Handle, mode, cStrArray.NativePointer, nbFile) != IntPtr.Zero) { output.AddRange(cStrArray.ManagedStringsUnicode); } } return(output); }
static void insertCurrentPath(NppMsg which) { NppMsg msg = NppMsg.NPPM_GETFULLCURRENTPATH; if (which == NppMsg.FILE_NAME) { msg = NppMsg.NPPM_GETFILENAME; } else if (which == NppMsg.CURRENT_DIRECTORY) { msg = NppMsg.NPPM_GETCURRENTDIRECTORY; } StringBuilder path = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(nppData._nppHandle, msg, 0, path); Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_REPLACESEL, 0, path); }
static void insertCurrentPath(NppMsg which) { NppMsg msg = NppMsg.NPPM_GETFULLCURRENTPATH; if (which == NppMsg.FILE_NAME) { msg = NppMsg.NPPM_GETFILENAME; } else if (which == NppMsg.CURRENT_DIRECTORY) { msg = NppMsg.NPPM_GETCURRENTDIRECTORY; } StringBuilder path = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)msg, 0, path); editor.ReplaceSel(path.ToString()); }
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, ref LangType lParam);
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, IntPtr wParam, int lParam) { return(SendMessage(hWnd, (uint)msg, wParam, new IntPtr(lParam))); }
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, out int lParam);
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, bool lParam) { return(SendMessage(hWnd, (uint)msg, new IntPtr(wParam), lParam.ToPointer())); }
IntPtr Send(NppMsg command, int wParam, NppMenuCmd lParam) { return(Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)command, wParam, lParam)); }
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, NppMenuCmd lParam);
static int execute(NppMsg msg, int wParam, int lParam = 0) { return((int)Win32.SendMessage(Npp.NppHandle, msg, wParam, lParam)); }
IntPtr send(NppMsg command, IntPtr wParam, IntPtr lParam) { return(Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)command, wParam, lParam)); }
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, int lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
/// <summary> /// Sends the message. /// </summary> /// <param name="editor">The editor.</param> /// <param name="Msg">The MSG.</param> /// <param name="wParam">The w parameter.</param> /// <param name="lParam">The l parameter.</param> /// <returns></returns> public static int SendMessage(this NotepadPPGateway editor, NppMsg Msg, int wParam, int lParam) => (int)Win32.SendMessage(editor.Handle, Msg, wParam, lParam);
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, IntPtr wParam, string lParam) { return(SendMessage(hWnd, (uint)msg, wParam, lParam)); }
public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, IntPtr lParam) { return(SendMessage(hWnd, (uint)msg, new IntPtr(wParam), lParam)); }
public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
static void insertCurrentPath(NppMsg which) { NppMsg msg = NppMsg.NPPM_GETFULLCURRENTPATH; if (which == NppMsg.FILE_NAME) msg = NppMsg.NPPM_GETFILENAME; else if (which == NppMsg.CURRENT_DIRECTORY) msg = NppMsg.NPPM_GETCURRENTDIRECTORY; StringBuilder path = new StringBuilder(Win32.MAX_PATH); Win32.SendMessage(nppData._nppHandle, msg, 0, path); Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_REPLACESEL, 0, path); }