|
|
@ -35,7 +35,6 @@
|
|
|
|
#include "Notepad_plus_Window.h"
|
|
|
|
#include "Notepad_plus_Window.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "keys.h"
|
|
|
|
#include "keys.h"
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int KEY_STR_LEN = 16;
|
|
|
|
const int KEY_STR_LEN = 16;
|
|
|
|
|
|
|
|
|
|
|
@ -454,7 +453,11 @@ BOOL CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
|
|
|
|
// return true if one of CommandShortcuts is deleted. Otherwise false.
|
|
|
|
// return true if one of CommandShortcuts is deleted. Otherwise false.
|
|
|
|
void Accelerator::updateShortcuts()
|
|
|
|
void Accelerator::updateShortcuts()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const std::array<int, 3> IFAccIds = { IDM_SEARCH_FINDNEXT, IDM_SEARCH_FINDPREV, IDM_SEARCH_FINDINCREMENT };
|
|
|
|
vector<int> IFAccIds;
|
|
|
|
|
|
|
|
IFAccIds.push_back(IDM_SEARCH_FINDNEXT);
|
|
|
|
|
|
|
|
IFAccIds.push_back(IDM_SEARCH_FINDPREV);
|
|
|
|
|
|
|
|
IFAccIds.push_back(IDM_SEARCH_FINDINCREMENT);
|
|
|
|
|
|
|
|
|
|
|
|
NppParameters *pNppParam = NppParameters::getInstance();
|
|
|
|
NppParameters *pNppParam = NppParameters::getInstance();
|
|
|
|
|
|
|
|
|
|
|
|
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
|
|
|
|
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
|
|
|
@ -475,20 +478,26 @@ void Accelerator::updateShortcuts()
|
|
|
|
int offset = 0;
|
|
|
|
int offset = 0;
|
|
|
|
size_t i = 0;
|
|
|
|
size_t i = 0;
|
|
|
|
//no validation performed, it might be that invalid shortcuts are being used by default. Allows user to 'hack', might be a good thing
|
|
|
|
//no validation performed, it might be that invalid shortcuts are being used by default. Allows user to 'hack', might be a good thing
|
|
|
|
for(i = 0; i < nbMenu; ++i) {
|
|
|
|
for(i = 0; i < nbMenu; ++i)
|
|
|
|
if (shortcuts[i].isEnabled()) {// && shortcuts[i].isValid()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (shortcuts[i].isEnabled())
|
|
|
|
|
|
|
|
{
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(shortcuts[i].getID());
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(shortcuts[i].getID());
|
|
|
|
_pAccelArray[offset].fVirt = shortcuts[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].fVirt = shortcuts[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].key = shortcuts[i].getKeyCombo()._key;
|
|
|
|
_pAccelArray[offset].key = shortcuts[i].getKeyCombo()._key;
|
|
|
|
|
|
|
|
|
|
|
|
// Special extra handling for shortcuts shared by Incremental Find dialog
|
|
|
|
// Special extra handling for shortcuts shared by Incremental Find dialog
|
|
|
|
if (std::find(IFAccIds.begin(), IFAccIds.end(), shortcuts[i].getID()) != IFAccIds.end())
|
|
|
|
if (std::find(IFAccIds.begin(), IFAccIds.end(), shortcuts[i].getID()) != IFAccIds.end())
|
|
|
|
IFAcc.push_back(_pAccelArray[offset]);
|
|
|
|
IFAcc.push_back(_pAccelArray[offset]);
|
|
|
|
|
|
|
|
|
|
|
|
++offset;
|
|
|
|
++offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < nbMacro; ++i) {
|
|
|
|
for(i = 0; i < nbMacro; ++i)
|
|
|
|
if (macros[i].isEnabled()) {// && macros[i].isValid()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (macros[i].isEnabled())
|
|
|
|
|
|
|
|
{
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(macros[i].getID());
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(macros[i].getID());
|
|
|
|
_pAccelArray[offset].fVirt = macros[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].fVirt = macros[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].key = macros[i].getKeyCombo()._key;
|
|
|
|
_pAccelArray[offset].key = macros[i].getKeyCombo()._key;
|
|
|
@ -496,8 +505,10 @@ void Accelerator::updateShortcuts()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < nbUserCmd; ++i) {
|
|
|
|
for(i = 0; i < nbUserCmd; ++i)
|
|
|
|
if (userCommands[i].isEnabled()) {// && userCommands[i].isValid()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (userCommands[i].isEnabled())
|
|
|
|
|
|
|
|
{
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(userCommands[i].getID());
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(userCommands[i].getID());
|
|
|
|
_pAccelArray[offset].fVirt = userCommands[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].fVirt = userCommands[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].key = userCommands[i].getKeyCombo()._key;
|
|
|
|
_pAccelArray[offset].key = userCommands[i].getKeyCombo()._key;
|
|
|
@ -505,8 +516,10 @@ void Accelerator::updateShortcuts()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < nbPluginCmd; ++i) {
|
|
|
|
for(i = 0; i < nbPluginCmd; ++i)
|
|
|
|
if (pluginCommands[i].isEnabled()) {// && pluginCommands[i].isValid()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pluginCommands[i].isEnabled())
|
|
|
|
|
|
|
|
{
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(pluginCommands[i].getID());
|
|
|
|
_pAccelArray[offset].cmd = (WORD)(pluginCommands[i].getID());
|
|
|
|
_pAccelArray[offset].fVirt = pluginCommands[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].fVirt = pluginCommands[i].getAcceleratorModifiers();
|
|
|
|
_pAccelArray[offset].key = pluginCommands[i].getKeyCombo()._key;
|
|
|
|
_pAccelArray[offset].key = pluginCommands[i].getKeyCombo()._key;
|
|
|
@ -522,9 +535,18 @@ void Accelerator::updateShortcuts()
|
|
|
|
if (_hAccTable)
|
|
|
|
if (_hAccTable)
|
|
|
|
::DestroyAcceleratorTable(_hAccTable);
|
|
|
|
::DestroyAcceleratorTable(_hAccTable);
|
|
|
|
_hAccTable = ::CreateAcceleratorTable(_pAccelArray, _nbAccelItems);
|
|
|
|
_hAccTable = ::CreateAcceleratorTable(_pAccelArray, _nbAccelItems);
|
|
|
|
|
|
|
|
|
|
|
|
if (_hIncFindAccTab)
|
|
|
|
if (_hIncFindAccTab)
|
|
|
|
::DestroyAcceleratorTable(_hIncFindAccTab);
|
|
|
|
::DestroyAcceleratorTable(_hIncFindAccTab);
|
|
|
|
_hIncFindAccTab = ::CreateAcceleratorTable(IFAcc.data(), IFAcc.size());
|
|
|
|
|
|
|
|
|
|
|
|
size_t nb = IFAcc.size();
|
|
|
|
|
|
|
|
ACCEL *tmpAccelArray = new ACCEL[nb];
|
|
|
|
|
|
|
|
for (i = 0; i < nb; ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
tmpAccelArray[i] = IFAcc[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_hIncFindAccTab = ::CreateAcceleratorTable(tmpAccelArray, nb);
|
|
|
|
|
|
|
|
delete tmpAccelArray;
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|