From 7cfa79b8cd164d09ff170ff168ac07a7d16cf7fb Mon Sep 17 00:00:00 2001 From: ozone10 Date: Sat, 13 Apr 2024 08:34:05 +0200 Subject: [PATCH] Allow Ctrl-TAB to switch tabs in FindReplace dialog Fix #14975, close #14988 --- .../src/ScintillaComponent/FindReplaceDlg.cpp | 57 +++++++++++++++++++ .../src/WinControls/shortcut/shortcut.cpp | 5 ++ PowerEditor/src/resource.h | 3 + 3 files changed, 65 insertions(+) diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 4529a7f7c..808d7cdb9 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -1693,6 +1693,63 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA enableMarkFunc(); return TRUE; + case IDC_NEXT_TAB: + case IDC_PREV_TAB: + { + const int lastTab = TabCtrl_GetItemCount(_tab.getHSelf()) - 1; + int selTab = TabCtrl_GetCurSel(_tab.getHSelf()); + + if (LOWORD(wParam) == IDC_NEXT_TAB) + { + if (selTab++ == lastTab) + { + selTab = 0; + } + } + else + { + if (selTab-- == 0) + { + selTab = lastTab; + } + } + + switch (static_cast(selTab)) + { + case DIALOG_TYPE::FIND_DLG: + { + enableReplaceFunc(false); + break; + } + + case DIALOG_TYPE::REPLACE_DLG: + { + enableReplaceFunc(true); + break; + } + + case DIALOG_TYPE::FINDINFILES_DLG: + { + enableFindInFilesFunc(); + break; + } + + case DIALOG_TYPE::FINDINPROJECTS_DLG: + { + enableFindInProjectsFunc(); + break; + } + + case DIALOG_TYPE::MARK_DLG: + { + enableMarkFunc(); + break; + } + } + + return TRUE; + } + case IDREPLACE: { std::lock_guard lock(findOps_mutex); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index e5f95f2e2..f0b16cc98 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -626,6 +626,11 @@ void Accelerator::updateShortcuts() if (_hFindAccTab) ::DestroyAcceleratorTable(_hFindAccTab); + + ACCEL accNextTab{ BYTE{FVIRTKEY | FCONTROL}, VK_TAB, IDC_NEXT_TAB }; + ACCEL accPrevTab{ BYTE{FVIRTKEY | FCONTROL | FSHIFT}, VK_TAB, IDC_PREV_TAB }; + findReplaceAcc.emplace_back(accNextTab); + findReplaceAcc.emplace_back(accPrevTab); size_t nbFindReplaceAcc = findReplaceAcc.size(); if (nbFindReplaceAcc) { diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index c34f7ac64..81f6d4361 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -439,6 +439,9 @@ //#define IDC_KEY_SELECT_2_HOME (IDCMD+8) //#define IDC_KEY_SELECT_2_END (IDCMD+9) + #define IDC_NEXT_TAB IDC_NEXT_DOC + #define IDC_PREV_TAB IDC_PREV_DOC + #define IDCMD_LIMIT (IDCMD+20) #define IDSCINTILLA 60000