diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index c5e5a2dd6..d6f916061 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -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) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 7ebb69120..cfdb15f1c 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -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 & 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) { diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 0e3c8d19d..a026bdba9 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -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); diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index a703d4a7b..35b93b33d 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -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(wParam); + return _pluginsManager.removeShortcutByCmdID(cmdID); + } + // // These are sent by Preferences Dialog //