Re-using NppExec's console in developing a separate plugin for Notepad++ -- can it be done?

536 Views Asked by At

I am going to create my own plugin for notepad++. It is necessary to use a console in my plugin but I don't want create another one because there is one in the NppExec plugin. So my question is can I use NppExec console from my own plugin ?

1

There are 1 best solutions below

1
On

I got an answer from NppExec forum https://sourceforge.net/projects/npp-plugins/forums/forum/672146/topic/5287950

Edited Pasting from the link above:

Of course! You can look at NppExecPluginMsgTester inside NppExec's sources and use its code partly or entirely. The NppExecPluginMsgTester uses a "wrapper" of messages declared inside "NppExec\src\PluginCommunication\nppexec_msgs.h".

Here an example the NppExec source code:

#define  NPEM_PRINT             0x0401  // message
  /*
  Prints (shows) given text in NppExec's Console window. 
  You can separate text lines using _T('\n') or _T("\r\n").
  This text can be highlighted if NppExec's Console Highlight Filters are used.

  If plugin's state is "busy", this message is ignored.

  Example:

  const TCHAR* cszMyPlugin = _T("my_plugin");
  DWORD dwState = 0;
  CommunicationInfo ci = { NPEM_GETSTATE, 
                           cszMyPlugin, 
                           (void *) &dwState };
  ::SendMessage( hNppWnd, NPPM_MSGTOPLUGIN,
      (WPARAM) _T("NppExec.dll"), (LPARAM) &ci );

  if ( dwState == NPE_STATEREADY )
  {
    // the plugin is "ready"
    const TCHAR* szText = _T("Hello from my plugin!\n(test message)")
    CommunicationInfo ci = { NPEM_PRINT,
                             cszMyPlugin, 
                             (void *) szText };
    ::SendMessage( hNppWnd, NPPM_MSGTOPLUGIN,
        (WPARAM) _T("NppExec.dll"), (LPARAM) &ci );
  }
  */