Add shortcut mapper clear command
In the shortcut mapper, shortcuts can be cleared easily Close #2800
This commit is contained in:
parent
6388d48e0c
commit
7ab6458978
@ -174,6 +174,7 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
}
|
}
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), true);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||||
break; }
|
break; }
|
||||||
case STATE_MACRO: {
|
case STATE_MACRO: {
|
||||||
@ -192,6 +193,7 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
}
|
}
|
||||||
bool shouldBeEnabled = nrItems > 0;
|
bool shouldBeEnabled = nrItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
||||||
break; }
|
break; }
|
||||||
case STATE_USER: {
|
case STATE_USER: {
|
||||||
@ -210,6 +212,7 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
}
|
}
|
||||||
bool shouldBeEnabled = nrItems > 0;
|
bool shouldBeEnabled = nrItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), shouldBeEnabled);
|
||||||
break; }
|
break; }
|
||||||
case STATE_PLUGIN: {
|
case STATE_PLUGIN: {
|
||||||
@ -228,6 +231,7 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
}
|
}
|
||||||
bool shouldBeEnabled = nrItems > 0;
|
bool shouldBeEnabled = nrItems > 0;
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), shouldBeEnabled);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), shouldBeEnabled);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||||
break; }
|
break; }
|
||||||
case STATE_SCINTILLA: {
|
case STATE_SCINTILLA: {
|
||||||
@ -255,6 +259,7 @@ void ShortcutMapper::fillOutBabyGrid()
|
|||||||
isMarker = _babygrid.setMarker(false);
|
isMarker = _babygrid.setMarker(false);
|
||||||
}
|
}
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_MODIFY), true);
|
||||||
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_CLEAR), false);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDM_BABYGRID_DELETE), false);
|
||||||
break; }
|
break; }
|
||||||
}
|
}
|
||||||
@ -352,6 +357,120 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case IDM_BABYGRID_CLEAR :
|
||||||
|
{
|
||||||
|
if (_babygrid.getNumberRows() < 1)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
NppParameters *nppParam = NppParameters::getInstance();
|
||||||
|
int row = _babygrid.getSelectedRow();
|
||||||
|
bool isModified = false;
|
||||||
|
|
||||||
|
switch(_currentState)
|
||||||
|
{
|
||||||
|
case STATE_MENU:
|
||||||
|
{
|
||||||
|
//Get CommandShortcut corresponding to row
|
||||||
|
vector<CommandShortcut> & shortcuts = nppParam->getUserShortcuts();
|
||||||
|
CommandShortcut csc = shortcuts[row - 1];
|
||||||
|
csc.clear();
|
||||||
|
shortcuts[row - 1] = csc;
|
||||||
|
//shortcut was altered
|
||||||
|
nppParam->addUserModifiedIndex(row-1);
|
||||||
|
|
||||||
|
//save the current view
|
||||||
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
|
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||||
|
fillOutBabyGrid();
|
||||||
|
|
||||||
|
isModified = true;
|
||||||
|
|
||||||
|
//Notify current Accelerator class to update everything
|
||||||
|
nppParam->getAccelerator()->updateShortcuts();
|
||||||
|
nppParam->setShortcutDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_MACRO:
|
||||||
|
{
|
||||||
|
//Get MacroShortcut corresponding to row
|
||||||
|
vector<MacroShortcut> & shortcuts = nppParam->getMacroList();
|
||||||
|
MacroShortcut msc = shortcuts[row - 1];
|
||||||
|
msc.clear();
|
||||||
|
shortcuts[row - 1] = msc;
|
||||||
|
//save the current view
|
||||||
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
|
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||||
|
fillOutBabyGrid();
|
||||||
|
|
||||||
|
isModified = true;
|
||||||
|
|
||||||
|
//Notify current Accelerator class to update everything
|
||||||
|
nppParam->getAccelerator()->updateShortcuts();
|
||||||
|
nppParam->setShortcutDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_USER:
|
||||||
|
{
|
||||||
|
//Get UserCommand corresponding to row
|
||||||
|
vector<UserCommand> & shortcuts = nppParam->getUserCommandList();
|
||||||
|
UserCommand ucmd = shortcuts[row - 1];
|
||||||
|
ucmd.clear();
|
||||||
|
|
||||||
|
//shortcut was altered
|
||||||
|
shortcuts[row - 1] = ucmd;
|
||||||
|
|
||||||
|
//save the current view
|
||||||
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
|
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||||
|
fillOutBabyGrid();
|
||||||
|
|
||||||
|
isModified = true;
|
||||||
|
|
||||||
|
//Notify current Accelerator class to update everything
|
||||||
|
nppParam->getAccelerator()->updateShortcuts();
|
||||||
|
nppParam->setShortcutDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_PLUGIN:
|
||||||
|
{
|
||||||
|
//Get PluginCmdShortcut corresponding to row
|
||||||
|
vector<PluginCmdShortcut> & shortcuts = nppParam->getPluginCommandList();
|
||||||
|
PluginCmdShortcut pcsc = shortcuts[row - 1];
|
||||||
|
pcsc.clear();
|
||||||
|
//shortcut was altered
|
||||||
|
nppParam->addPluginModifiedIndex(row-1);
|
||||||
|
shortcuts[row - 1] = pcsc;
|
||||||
|
|
||||||
|
//save the current view
|
||||||
|
_lastHomeRow[_currentState] = _babygrid.getHomeRow();
|
||||||
|
_lastCursorRow[_currentState] = _babygrid.getSelectedRow();
|
||||||
|
fillOutBabyGrid();
|
||||||
|
|
||||||
|
isModified = true;
|
||||||
|
|
||||||
|
//Notify current Accelerator class to update everything
|
||||||
|
nppParam->getAccelerator()->updateShortcuts();
|
||||||
|
unsigned long cmdID = pcsc.getID();
|
||||||
|
ShortcutKey shortcut;
|
||||||
|
shortcut._isAlt = FALSE;
|
||||||
|
shortcut._isCtrl = FALSE;
|
||||||
|
shortcut._isShift = FALSE;
|
||||||
|
shortcut._key = '\0';
|
||||||
|
|
||||||
|
::SendMessage(_hParent, NPPM_INTERNAL_PLUGINSHORTCUTMOTIFIED, cmdID, reinterpret_cast<LPARAM>(&shortcut));
|
||||||
|
nppParam->setShortcutDirty();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STATE_SCINTILLA:
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (not isModified)
|
||||||
|
::SendMessage(_hSelf, WM_COMMAND, MAKEWPARAM(IDD_BABYGRID_ID1, BGN_ROWCHANGED), row);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
case IDM_BABYGRID_MODIFY :
|
case IDM_BABYGRID_MODIFY :
|
||||||
{
|
{
|
||||||
if (_babygrid.getNumberRows() < 1)
|
if (_babygrid.getNumberRows() < 1)
|
||||||
@ -639,6 +758,7 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
vector<MenuItemUnit> itemUnitArray;
|
vector<MenuItemUnit> itemUnitArray;
|
||||||
itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_MODIFY, TEXT("Modify")));
|
itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_MODIFY, TEXT("Modify")));
|
||||||
itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_DELETE, TEXT("Delete")));
|
itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_DELETE, TEXT("Delete")));
|
||||||
|
itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_CLEAR, TEXT("Clear")));
|
||||||
_rightClickMenu.create(_hSelf, itemUnitArray);
|
_rightClickMenu.create(_hSelf, itemUnitArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,10 +766,16 @@ INT_PTR CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
{
|
{
|
||||||
_rightClickMenu.enableItem(IDM_BABYGRID_MODIFY, false);
|
_rightClickMenu.enableItem(IDM_BABYGRID_MODIFY, false);
|
||||||
_rightClickMenu.enableItem(IDM_BABYGRID_DELETE, false);
|
_rightClickMenu.enableItem(IDM_BABYGRID_DELETE, false);
|
||||||
|
_rightClickMenu.enableItem(IDM_BABYGRID_CLEAR, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_rightClickMenu.enableItem(IDM_BABYGRID_MODIFY, true);
|
_rightClickMenu.enableItem(IDM_BABYGRID_MODIFY, true);
|
||||||
|
_rightClickMenu.enableItem(IDM_BABYGRID_DELETE, true);
|
||||||
|
if (_currentState == STATE_SCINTILLA)
|
||||||
|
_rightClickMenu.enableItem(IDM_BABYGRID_CLEAR, false);
|
||||||
|
else
|
||||||
|
_rightClickMenu.enableItem(IDM_BABYGRID_CLEAR, true);
|
||||||
switch(_currentState) {
|
switch(_currentState) {
|
||||||
case STATE_MACRO:
|
case STATE_MACRO:
|
||||||
case STATE_USER: {
|
case STATE_USER: {
|
||||||
|
@ -42,7 +42,8 @@ FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
|||||||
BEGIN
|
BEGIN
|
||||||
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",WS_TABSTOP,4,6,384,12
|
||||||
DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,319,47,14
|
DEFPUSHBUTTON "Modify",IDM_BABYGRID_MODIFY,118,319,47,14
|
||||||
DEFPUSHBUTTON "Delete",IDM_BABYGRID_DELETE,172,319,47,14
|
DEFPUSHBUTTON "Clear", IDM_BABYGRID_CLEAR,172,319,47,14
|
||||||
DEFPUSHBUTTON "Close",IDOK,226,319,47,14
|
DEFPUSHBUTTON "Delete", IDM_BABYGRID_DELETE, 226, 319, 47, 14
|
||||||
|
DEFPUSHBUTTON "Close",IDOK,280,319,47,14
|
||||||
EDITTEXT IDC_BABYGRID_INFO,4,279,383,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
EDITTEXT IDC_BABYGRID_INFO,4,279,383,29,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP
|
||||||
END
|
END
|
||||||
|
@ -35,5 +35,6 @@
|
|||||||
#define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3)
|
#define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3)
|
||||||
#define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4)
|
#define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4)
|
||||||
#define IDC_BABYGRID_INFO (IDD_SHORTCUTMAPPER_DLG + 5)
|
#define IDC_BABYGRID_INFO (IDD_SHORTCUTMAPPER_DLG + 5)
|
||||||
|
#define IDM_BABYGRID_CLEAR (IDD_SHORTCUTMAPPER_DLG + 6)
|
||||||
|
|
||||||
#endif// SHORTCUTMAPPER_RC_H
|
#endif// SHORTCUTMAPPER_RC_H
|
||||||
|
@ -174,6 +174,14 @@ public:
|
|||||||
|
|
||||||
void setName(const TCHAR * name);
|
void setName(const TCHAR * name);
|
||||||
|
|
||||||
|
void clear(){
|
||||||
|
_keyCombo._isCtrl = false;
|
||||||
|
_keyCombo._isAlt = false;
|
||||||
|
_keyCombo._isShift = false;
|
||||||
|
_keyCombo._key = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
KeyCombo _keyCombo;
|
KeyCombo _keyCombo;
|
||||||
virtual INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
virtual INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
|
Loading…
Reference in New Issue
Block a user