[NEW_FEATURE] Add 2 plugin messages : NPPN_SHORTCUTREMAPPED notification and NPPM_GETSHORTCUTBYCMDID message.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@393 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
fbf0ab11fe
commit
d7d78db3b7
@ -316,6 +316,13 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
// BOOL NPPM_ISSTATUSBARHIDDEN(0, 0)
|
||||
// returned value : TRUE if STATUSBAR is hidden, otherwise FALSE
|
||||
|
||||
#define NPPM_GETSHORTCUTBYCMDID (NPPMSG + 76)
|
||||
// BOOL NPPM_GETSHORTCUTBYCMDID(int cmdID, ShortcutKey *sk)
|
||||
// get your plugin command current mapped shortcut into sk via cmdID
|
||||
// You may need it after getting NPPN_READY notification
|
||||
// returned value : TRUE if this function call is successful and shorcut is enable, otherwise FALSE
|
||||
|
||||
|
||||
#define RUNCOMMAND_USER (WM_USER + 3000)
|
||||
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)
|
||||
#define NPPM_GETCURRENTDIRECTORY (RUNCOMMAND_USER + CURRENT_DIRECTORY)
|
||||
@ -412,5 +419,16 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
|
||||
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||
//scnNotification->nmhdr.idFrom = currentBufferID;
|
||||
|
||||
#define NPPN_SHORTCUTREMAPPED (NPPN_FIRST + 13) // To notify plugins that plugin command shortcut is remapped.
|
||||
//scnNotification->nmhdr.code = NPPN_SHORTCUTSREMAPPED;
|
||||
//scnNotification->nmhdr.hwndFrom = ShortcutKeyStructurePointer;
|
||||
//scnNotification->nmhdr.idFrom = cmdID;
|
||||
//where ShortcutKeyStructurePointer is pointer of struct ShortcutKey:
|
||||
//struct ShortcutKey {
|
||||
// bool _isCtrl;
|
||||
// bool _isAlt;
|
||||
// bool _isShift;
|
||||
// UCHAR _key;
|
||||
//};
|
||||
|
||||
#endif //NOTEPAD_PLUS_MSGS_H
|
||||
|
@ -213,6 +213,33 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
// return true if cmdID found and its shortcut is enable
|
||||
// false otherwise
|
||||
bool PluginsManager::getShortcutByCmdID(int cmdID, ShortcutKey *sk)
|
||||
{
|
||||
if (cmdID == 0 || !sk)
|
||||
return false;
|
||||
|
||||
const vector<PluginCmdShortcut> & pluginCmdSCList = (NppParameters::getInstance())->getPluginCommandList();
|
||||
|
||||
for (size_t i = 0 ; i < pluginCmdSCList.size() ; i++)
|
||||
{
|
||||
if (pluginCmdSCList[i].getID() == cmdID)
|
||||
{
|
||||
const KeyCombo & kc = pluginCmdSCList[i].getKeyCombo();
|
||||
if (kc._key == 0x00)
|
||||
return false;
|
||||
|
||||
sk->_isAlt = kc._isAlt;
|
||||
sk->_isCtrl = kc._isCtrl;
|
||||
sk->_isShift = kc._isShift;
|
||||
sk->_key = kc._key;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
|
||||
{
|
||||
if (hasPlugins())
|
||||
|
@ -94,6 +94,7 @@ public:
|
||||
};
|
||||
|
||||
void setMenu(HMENU hMenu, const TCHAR *menuName);
|
||||
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
|
||||
|
||||
void notify(SCNotification *notification) {
|
||||
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
||||
|
@ -7355,6 +7355,24 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED:
|
||||
{
|
||||
SCNotification scnN;
|
||||
scnN.nmhdr.code = NPPN_SHORTCUTREMAPPED;
|
||||
scnN.nmhdr.hwndFrom = (void *)lParam; // ShortcutKey structure
|
||||
scnN.nmhdr.idFrom = (uptr_t)wParam; // cmdID
|
||||
_pluginsManager.notify(&scnN);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
case NPPM_GETSHORTCUTBYCMDID:
|
||||
{
|
||||
int cmdID = wParam; // cmdID
|
||||
ShortcutKey *sk = (ShortcutKey *)lParam; // ShortcutKey structure
|
||||
|
||||
return _pluginsManager.getShortcutByCmdID(cmdID, sk);
|
||||
}
|
||||
|
||||
case NPPM_MENUCOMMAND :
|
||||
command(lParam);
|
||||
return TRUE;
|
||||
|
@ -202,7 +202,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
_babygrid.setText(row, 2, csc.toString().c_str());
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_CMDLIST_MODIFIED, (WPARAM)sc.c_str(), cmdID);
|
||||
|
||||
}
|
||||
break; }
|
||||
case STATE_MACRO: {
|
||||
@ -217,7 +217,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_MACROLIST_MODIFIED, 0, 0);
|
||||
|
||||
}
|
||||
break; }
|
||||
case STATE_USER: {
|
||||
@ -233,7 +233,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_USERCMDLIST_MODIFIED, 0, 0);
|
||||
|
||||
}
|
||||
break; }
|
||||
case STATE_PLUGIN: {
|
||||
@ -249,7 +249,14 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
|
||||
//Notify current Accelerator class to update everything
|
||||
nppParam->getAccelerator()->updateShortcuts();
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_PLUGINCMDLIST_MODIFIED, 0, 0);
|
||||
unsigned long cmdID = pcsc.getID();
|
||||
ShortcutKey shortcut;
|
||||
shortcut._isAlt = pcsc.getKeyCombo()._isAlt;
|
||||
shortcut._isCtrl = pcsc.getKeyCombo()._isCtrl;
|
||||
shortcut._isShift = pcsc.getKeyCombo()._isShift;
|
||||
shortcut._key = pcsc.getKeyCombo()._key;
|
||||
|
||||
::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, (LPARAM)&shortcut);
|
||||
}
|
||||
break; }
|
||||
case STATE_SCINTILLA: {
|
||||
@ -257,19 +264,18 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
||||
vector<ScintillaKeyMap> & shortcuts = nppParam->getScintillaKeyList();
|
||||
ScintillaKeyMap skm = shortcuts[row - 1], prevskm = shortcuts[row-1];
|
||||
skm.init(_hInst, _hSelf);
|
||||
if (skm.doDialog() != -1 && prevskm != skm) { //shortcut was altered
|
||||
if (skm.doDialog() != -1 && prevskm != skm)
|
||||
{
|
||||
//shortcut was altered
|
||||
nppParam->addScintillaModifiedIndex(row-1);
|
||||
shortcuts[row-1] = skm;
|
||||
_babygrid.setText(row, 2, skm.toString().c_str());
|
||||
|
||||
//Notify current Accelerator class to update key
|
||||
nppParam->getScintillaAccelerator()->updateKeys();
|
||||
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_BINDSCINTILLAKEY, scintillaSc.toKeyDef(), scintillaSc.getScintillaKey());
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_CLEARSCINTILLAKEY, scintillaShortcuts[index].toKeyDef(), 0);
|
||||
//::SendMessage(_hParent, NPPM_INTERNAL_SCINTILLAKEYMODIFIED, 0, 0);
|
||||
}
|
||||
break; }
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -300,8 +300,8 @@
|
||||
#define NPPM_INTERNAL_SWITCHVIEWFROMHWND (NOTEPADPLUS_USER_INTERNAL + 22)
|
||||
#define NPPM_INTERNAL_UPDATETITLEBAR (NOTEPADPLUS_USER_INTERNAL + 23)
|
||||
#define NPPM_INTERNAL_CANCEL_FIND_IN_FILES (NOTEPADPLUS_USER_INTERNAL + 24)
|
||||
#define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 24)
|
||||
|
||||
#define NPPM_INTERNAL_RELOADNATIVELANG (NOTEPADPLUS_USER_INTERNAL + 25)
|
||||
#define NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED (NOTEPADPLUS_USER_INTERNAL + 26)
|
||||
// See Notepad_plus_msgs.h
|
||||
//#define NOTEPADPLUS_USER (WM_USER + 1000)
|
||||
#define SCINTILLA_USER (WM_USER + 2000)
|
||||
|
Loading…
Reference in New Issue
Block a user