Add new plugin API NPPM_REMOVESHORTCUTBYCMDID to allows plugins to remove unneeded shortcuts
Fix #4674, close #4687
This commit is contained in:
parent
efbc3b2160
commit
84938b7b0f
@ -414,6 +414,11 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64 };
|
||||
#define NPPM_DISABLEAUTOUPDATE (NPPMSG + 95) // 2119 in decimal
|
||||
// VOID NPPM_DISABLEAUTOUPDATE(0, 0)
|
||||
|
||||
#define NPPM_REMOVESHORTCUTBYCMDID (NPPMSG + 96) // 2120 in decimal
|
||||
// BOOL NPPM_REMOVESHORTCUTASSIGNMENT(int cmdID)
|
||||
// removes the assigned shortcut mapped to cmdID
|
||||
// returned value : TRUE if function call is successful, otherwise FALSE
|
||||
|
||||
#define RUNCOMMAND_USER (WM_USER + 3000)
|
||||
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
|
||||
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
|
||||
|
@ -452,6 +452,31 @@ bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk)
|
||||
return false;
|
||||
}
|
||||
|
||||
// returns false if cmdID not provided, true otherwise
|
||||
bool PluginsManager::removeShortcutByCmdID(int cmdID)
|
||||
{
|
||||
if (cmdID == 0) { return false; }
|
||||
|
||||
NppParameters *nppParam = NppParameters::getInstance();
|
||||
vector<PluginCmdShortcut> & pluginCmdSCList = nppParam->getPluginCommandList();
|
||||
|
||||
for (size_t i = 0, len = pluginCmdSCList.size(); i < len; ++i)
|
||||
{
|
||||
if (pluginCmdSCList[i].getID() == (unsigned long)cmdID)
|
||||
{
|
||||
//remove shortcut
|
||||
pluginCmdSCList[i].clear();
|
||||
|
||||
// inform accelerator instance
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
|
||||
// set dirty flag to force writing shortcuts.xml on shutdown
|
||||
nppParam->setShortcutDirty();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PluginsManager::addInMenuFromPMIndex(int i)
|
||||
{
|
||||
|
@ -111,6 +111,7 @@ public:
|
||||
void addInMenuFromPMIndex(int i);
|
||||
HMENU setMenu(HMENU hMenu, const TCHAR *menuName, bool enablePluginAdmin = false);
|
||||
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
|
||||
bool removeShortcutByCmdID(int cmdID);
|
||||
|
||||
void notify(const SCNotification *notification);
|
||||
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
@ -2299,6 +2299,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
case NPPM_REMOVESHORTCUTBYCMDID:
|
||||
{
|
||||
int cmdID = static_cast<int32_t>(wParam);
|
||||
return _pluginsManager.removeShortcutByCmdID(cmdID);
|
||||
}
|
||||
|
||||
//
|
||||
// These are sent by Preferences Dialog
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user