Browse Source

Add the capacity to switch among Find/Replace/FiF/Mark via their shortcuts

Add Find/Replace/Find in fles/Mark shortcuts detection capacity in Find Replace dialog.

Fix #10019, close #10177
pull/10199/head
Don Ho 3 years ago
parent
commit
aa69711d4c
  1. 14
      PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp
  2. 20
      PowerEditor/src/WinControls/shortcut/shortcut.cpp

14
PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp

@ -1207,7 +1207,19 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
return TRUE;
case IDM_SEARCH_FIND:
goToCenter();
enableReplaceFunc(false); // enable relace false so only find
return TRUE;
case IDM_SEARCH_REPLACE:
enableReplaceFunc(true);
return TRUE;
case IDM_SEARCH_FINDINFILES:
enableFindInFilesFunc();
return TRUE;
case IDM_SEARCH_MARK:
enableMarkFunc();
return TRUE;
case IDREPLACE :

20
PowerEditor/src/WinControls/shortcut/shortcut.cpp

@ -496,10 +496,9 @@ void Accelerator::updateShortcuts()
size_t nbPluginCmd = pluginCommands.size();
delete [] _pAccelArray;
_pAccelArray = new ACCEL[nbMenu+nbMacro+nbUserCmd+nbPluginCmd];
_pAccelArray = new ACCEL[nbMenu + nbMacro+nbUserCmd + nbPluginCmd];
vector<ACCEL> incrFindAcc;
ACCEL *pSearchFindAccel = nullptr;
vector<ACCEL> findReplaceAcc;
int offset = 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
@ -515,8 +514,9 @@ void Accelerator::updateShortcuts()
if (std::find(incrFindAccIds.begin(), incrFindAccIds.end(), shortcuts[i].getID()) != incrFindAccIds.end())
incrFindAcc.push_back(_pAccelArray[offset]);
if (shortcuts[i].getID() == IDM_SEARCH_FIND)
pSearchFindAccel = &_pAccelArray[offset];
if (shortcuts[i].getID() == IDM_SEARCH_FIND || shortcuts[i].getID() == IDM_SEARCH_REPLACE ||
shortcuts[i].getID() == IDM_SEARCH_FINDINFILES || shortcuts[i].getID() == IDM_SEARCH_MARK)
findReplaceAcc.push_back(_pAccelArray[offset]);
++offset;
}
@ -582,11 +582,13 @@ void Accelerator::updateShortcuts()
if (_hFindAccTab)
::DestroyAcceleratorTable(_hFindAccTab);
if (pSearchFindAccel != nullptr)
size_t nbFindReplaceAcc = findReplaceAcc.size();
if (nbFindReplaceAcc)
{
ACCEL *tmpFindAccelArray = new ACCEL[1];
tmpFindAccelArray[0] = *pSearchFindAccel;
_hFindAccTab = ::CreateAcceleratorTable(tmpFindAccelArray, 1);
ACCEL* tmpFindAccelArray = new ACCEL[nbFindReplaceAcc];
for (size_t i = 0; i < nbFindReplaceAcc; ++i)
tmpFindAccelArray[i] = findReplaceAcc[i];
_hFindAccTab = ::CreateAcceleratorTable(tmpFindAccelArray, static_cast<int>(nbFindReplaceAcc));
delete[] tmpFindAccelArray;
}

Loading…
Cancel
Save