Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
Archivo: Main.cs Proyecto: chcg/ImgTag
        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());
        }
Ejemplo n.º 8
0
        /// <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;
        }
Ejemplo n.º 9
0
        /// <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());
        }
Ejemplo n.º 10
0
        /// <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);
        }
Ejemplo n.º 11
0
        /// <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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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());
        }
Ejemplo n.º 14
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, ref LangType lParam);
Ejemplo n.º 15
0
 public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, IntPtr wParam, int lParam)
 {
     return(SendMessage(hWnd, (uint)msg, wParam, new IntPtr(lParam)));
 }
Ejemplo n.º 16
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, out int lParam);
Ejemplo n.º 17
0
 public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, bool lParam)
 {
     return(SendMessage(hWnd, (uint)msg, new IntPtr(wParam), lParam.ToPointer()));
 }
Ejemplo n.º 18
0
 IntPtr Send(NppMsg command, int wParam, NppMenuCmd lParam)
 {
     return(Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)command, wParam, lParam));
 }
Ejemplo n.º 19
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
Ejemplo n.º 20
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, NppMenuCmd lParam);
Ejemplo n.º 21
0
 static int execute(NppMsg msg, int wParam, int lParam = 0)
 {
     return((int)Win32.SendMessage(Npp.NppHandle, msg, wParam, lParam));
 }
Ejemplo n.º 22
0
 IntPtr send(NppMsg command, IntPtr wParam, IntPtr lParam)
 {
     return(Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)command, wParam, lParam));
 }
Ejemplo n.º 23
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
Ejemplo n.º 24
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, int lParam);
Ejemplo n.º 25
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, int lParam);
Ejemplo n.º 26
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
Ejemplo n.º 27
0
 /// <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);
Ejemplo n.º 28
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, NppMenuCmd lParam);
Ejemplo n.º 29
0
 public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, IntPtr wParam, string lParam)
 {
     return(SendMessage(hWnd, (uint)msg, wParam, lParam));
 }
Ejemplo n.º 30
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, int wParam, ref LangType lParam);
Ejemplo n.º 31
0
 public static IntPtr SendMessage(IntPtr hWnd, NppMsg msg, int wParam, IntPtr lParam)
 {
     return(SendMessage(hWnd, (uint)msg, new IntPtr(wParam), lParam));
 }
Ejemplo n.º 32
0
 public static extern IntPtr SendMessage(IntPtr hWnd, NppMsg Msg, IntPtr wParam, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lParam);
Ejemplo n.º 33
0
        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);
        }