From 5302fb822dee86e90dc2976b3f28684298ca72a4 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Sat, 19 Feb 2022 11:36:18 +0100 Subject: [PATCH] +fix: F/R-Dialog: Initial fill of replace template box --- src/Dialogs.c | 5 +++++ src/Dialogs.h | 1 + src/Edit.c | 31 ++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Dialogs.c b/src/Dialogs.c index 2fc58cdeb..444066df5 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -5235,6 +5235,11 @@ int ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, size_t cch) return len; } +void ComboBox_SetTextW(HWND hDlg, int nIDDlgItem, LPCWSTR wstr) +{ + ComboBox_SetText(GetDlgItem(hDlg, nIDDlgItem), wstr ? wstr : L""); +} + void ComboBox_SetTextHW(HWND hDlg, int nIDDlgItem, const HSTRINGW hstr) { ComboBox_SetText(GetDlgItem(hDlg, nIDDlgItem), StrgIsNotEmpty(hstr) ? StrgGet(hstr) : L""); diff --git a/src/Dialogs.h b/src/Dialogs.h index 4983b068a..6e635cf8e 100644 --- a/src/Dialogs.h +++ b/src/Dialogs.h @@ -98,6 +98,7 @@ UINT ComboBox_GetTextLengthEx(HWND hDlg, int nIDDlgItem); UINT ComboBox_GetCurSelEx(HWND hDlg, int nIDDlgItem); int ComboBox_GetTextHW(HWND hDlg, int nIDDlgItem, HSTRINGW hstr); int ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, size_t cch); +void ComboBox_SetTextW(HWND hDlg, int nIDDlgItem, LPCWSTR wstr); void ComboBox_SetTextHW(HWND hDlg, int nIDDlgItem, const HSTRINGW hstr); void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString); //void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString); diff --git a/src/Edit.c b/src/Edit.c index af5fba990..eefc58632 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5529,6 +5529,8 @@ static void _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr) lpefr->bStateChanged = true; } + StrgReset(hstr, L""); + ComboBox_GetTextHW(hwnd, IDC_REPLACETEXT, hstr); if (StringCchCompareX(StrgGet(hstr), StrgGet(lpefr->chReplaceTemplate)) != 0) { StrgReset(lpefr->chReplaceTemplate, StrgGet(hstr)); @@ -6152,9 +6154,17 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar SetWindowSubclass(cbInfoF.hwndItem, EditBoxForPasteFixes, 0, (DWORD_PTR) &(s_wchBufOut[0])); SHAutoComplete(cbInfoF.hwndItem, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF); } - if (!GetWindowTextLengthW(GetDlgItem(hwnd, IDC_FINDTEXT))) { - ComboBox_SetTextHW(hwnd, IDC_FINDTEXT, s_pEfrData->chFindPattern); + if (StrgIsNotEmpty(s_pEfrData->chFindPattern)) { + ComboBox_SetTextHW(hwnd, IDC_FINDTEXT, s_pEfrData->chFindPattern); + } + else if (MRU_Count(Globals.pMRUfind)) { + MRU_Enum(Globals.pMRUfind, 0, s_wchBufOut, COUNTOF(s_wchBufOut)); + ComboBox_SetTextW(hwnd, IDC_FINDTEXT, s_wchBufOut); + } + else { + ComboBox_SetTextW(hwnd, IDC_FINDTEXT, NULL); + } } if (s_bIsReplaceDlg) { @@ -6174,7 +6184,18 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar SetWindowSubclass(cbInfoR.hwndItem, EditBoxForPasteFixes, 0, (DWORD_PTR) &(s_wchBufOut[0])); SHAutoComplete(cbInfoR.hwndItem, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF); } - ComboBox_SetTextHW(hwnd, IDC_REPLACETEXT, s_pEfrData->chReplaceTemplate); + if (!GetWindowTextLengthW(GetDlgItem(hwnd, IDC_REPLACETEXT))) { + if (StrgIsNotEmpty(s_pEfrData->chReplaceTemplate)) { + ComboBox_SetTextHW(hwnd, IDC_REPLACETEXT, s_pEfrData->chReplaceTemplate); + } + else if (MRU_Count(Globals.pMRUreplace)) { + MRU_Enum(Globals.pMRUreplace, 0, s_wchBufOut, COUNTOF(s_wchBufOut)); + ComboBox_SetTextW(hwnd, IDC_REPLACETEXT, s_wchBufOut); + } + else { + ComboBox_SetTextW(hwnd, IDC_REPLACETEXT, NULL); + } + } } CheckDlgButton(hwnd, IDC_FINDREGEXP, SetBtn(s_pEfrData->bRegExprSearch)); @@ -7592,8 +7613,8 @@ int EditAddSearchFlags(int flags, bool bRegEx, bool bWordStart, bool bMatchCase, // void EditMarkAll(LPCWSTR wchFind, int sFlags, DocPos rangeStart, DocPos rangeEnd, bool bMultiSel) { - char chText[2048] = { L'\0' }; - WCHAR wchText[2048] = { L'\0' }; + char chText[FNDRPL_BUFFER] = { L'\0' }; + WCHAR wchText[FNDRPL_BUFFER] = { L'\0' }; DocPos iFindLength = 0;