Add new Plugin message NPPM_GETPLUGINHOMEPATH in API

The new message NPPM_GETPLUGINHOMEPATH allows plugins to get plugin home root path. It's useful if plugins want to get its own path by appending <pluginFolderName> which is the name of plugin without extension part.
This commit is contained in:
Don HO 2018-11-07 23:30:59 +01:00
parent 8dea25feb5
commit a87e89ea92
2 changed files with 24 additions and 0 deletions

View File

@ -419,6 +419,14 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 };
// removes the assigned shortcut mapped to cmdID
// returned value : TRUE if function call is successful, otherwise FALSE
#define NPPM_GETPLUGINHOMEPATH (NPPMSG + 97)
// INT NPPM_GETPLUGINHOMEPATH(size_t strLen, TCHAR *pluginRootPath)
// Get plugin home root path. It's useful if plugins want to get its own path
// by appending <pluginFolderName> which is the name of plugin without extension part.
// Returns the number of TCHAR copied/to copy.
// Users should call it with pluginRootPath be NULL to get the required number of TCHAR (not including the terminating nul character),
// allocate pluginRootPath buffer with the return value + 1, then call it again to get the path.
#define RUNCOMMAND_USER (WM_USER + 3000)
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)

View File

@ -2061,6 +2061,22 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_GETPLUGINHOMEPATH:
{
generic_string pluginHomePath = pNppParam->getPluginRootDir();
if (lParam != 0)
{
if (pluginHomePath.length() >= static_cast<size_t>(wParam))
{
// Not message for users so no translation
::MessageBox(hwnd, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETPLUGINHOMEPATH error"), MB_OK);
return 0;
}
lstrcpy(reinterpret_cast<TCHAR *>(lParam), pluginHomePath.c_str());
}
return pluginHomePath.length();
}
case NPPM_MSGTOPLUGIN :
{
return _pluginsManager.relayPluginMessages(message, wParam, lParam);