GUI enhancement: Find in Finder dialog

- add key accelerator
- optimize dark mode
- add initializers
- fix override warnings

Fix #13624, close #13625
pull/13668/head
ozone10 2 years ago committed by Don Ho
parent 04e85241f3
commit af8b339296

@ -1302,8 +1302,8 @@ You can define several column markers by using white space to separate the diffe
<FindInFinder title="Find in search results">
<Item id="1" name="Find All"/>
<Item id="2" name="Close"/>
<Item id="1711" name="&amp;Find what :"/>
<Item id="1713" name="Search only in found lines"/>
<Item id="1711" name="&amp;Find what:"/>
<Item id="1713" name="Search &amp;only in found lines"/>
<Item id="1714" name="Match &amp;whole word only"/>
<Item id="1715" name="Match &amp;case"/>
<Item id="1716" name="Search Mode"/>

@ -1302,8 +1302,8 @@ You can define several column markers by using white space to separate the diffe
<FindInFinder title="Find in search results">
<Item id="1" name="Find All"/>
<Item id="2" name="Close"/>
<Item id="1711" name="&amp;Find what :"/>
<Item id="1713" name="Search only in found lines"/>
<Item id="1711" name="&amp;Find what:"/>
<Item id="1713" name="Search &amp;only in found lines"/>
<Item id="1714" name="Match &amp;whole word only"/>
<Item id="1715" name="Match &amp;case"/>
<Item id="1716" name="Search Mode"/>

@ -1022,27 +1022,25 @@ intptr_t CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
initFromOptions();
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
}
return TRUE;
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORLISTBOX:
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_PRINTCLIENT:
@ -1058,7 +1056,7 @@ intptr_t CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
RECT rc{};
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -1211,22 +1209,18 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORLISTBOX:
{
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORDLG:
case WM_CTLCOLORSTATIC:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_PRINTCLIENT:
@ -1242,7 +1236,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
RECT rc{};
getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -1810,10 +1804,10 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
case IDD_FINDINFILES_FIND_BUTTON:
{
setStatusbarMessage(TEXT(""), FSNoMessage);
const int filterSize = 512;
constexpr int filterSize = 512;
TCHAR filters[filterSize + 1] = { '\0' };
filters[filterSize] = '\0';
TCHAR directory[MAX_PATH];
TCHAR directory[MAX_PATH]{};
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
_options._filters = filters;
@ -1859,9 +1853,9 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
std::lock_guard<std::mutex> lock(findOps_mutex);
setStatusbarMessage(TEXT(""), FSNoMessage);
const int filterSize = 512;
TCHAR filters[filterSize];
TCHAR directory[MAX_PATH];
constexpr int filterSize = 512;
TCHAR filters[filterSize]{};
TCHAR directory[MAX_PATH]{};
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
_options._filters = filters;
@ -1900,8 +1894,8 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
std::lock_guard<std::mutex> lock(findOps_mutex);
setStatusbarMessage(TEXT(""), FSNoMessage);
const int filterSize = 512;
TCHAR filters[filterSize];
constexpr int filterSize = 512;
TCHAR filters[filterSize]{};
::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, filterSize);
addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO));
_options._filters = filters;
@ -2911,7 +2905,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
intptr_t nbChar = lend - lstart;
// use the static buffer
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH]{};
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
@ -2952,7 +2946,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
intptr_t nbChar = lend - lstart;
// use the static buffer
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH]{};
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
@ -4231,7 +4225,7 @@ void FindReplaceDlg::enableFindInFilesFunc()
_currentStatus = FINDINFILES_DLG;
gotoCorrectTab();
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left + _deltaWidth, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
TCHAR label[MAX_PATH];
TCHAR label[MAX_PATH]{};
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDD_FINDINFILES_FIND_BUTTON);
@ -4245,7 +4239,7 @@ void FindReplaceDlg::enableFindInProjectsFunc()
_currentStatus = FINDINPROJECTS_DLG;
gotoCorrectTab();
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _findInFilesClosePos.left + _deltaWidth, _findInFilesClosePos.top, _findInFilesClosePos.right, _findInFilesClosePos.bottom, TRUE);
TCHAR label[MAX_PATH];
TCHAR label[MAX_PATH]{};
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDD_FINDINFILES_FIND_BUTTON);
@ -4285,7 +4279,7 @@ void FindReplaceDlg::enableMarkFunc()
::MoveWindow(::GetDlgItem(_hSelf, IDC_REPLACEINSELECTION), _replaceInSelFramePos.left + _deltaWidth, _replaceInSelFramePos.top, _replaceInSelFramePos.right, _replaceInSelFramePos.bottom, TRUE);
::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), _markClosePos.left + _deltaWidth, _markClosePos.top, _markClosePos.right, _markClosePos.bottom, TRUE);
TCHAR label[MAX_PATH];
TCHAR label[MAX_PATH]{};
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
setDefaultButton(IDCMARKALL);
@ -4395,7 +4389,7 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
bgColor = getCtrlBgColor(_statusBar.getHSelf());
}
::SetBkColor(lpDrawItemStruct->hDC, bgColor);
RECT rect;
RECT rect{};
_statusBar.getClientRect(rect);
if (NppDarkMode::isEnabled())
@ -4407,7 +4401,7 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
if (_statusbarTooltipMsg.length() == 0) return;
SIZE size;
SIZE size{};
::GetTextExtentPoint32(lpDrawItemStruct->hDC, ptStr, lstrlen(ptStr), &size);
int s = (rect.bottom - rect.top) & 0x70; // limit s to available icon sizes and avoid uneven scalings
if (s > 0)
@ -4800,7 +4794,7 @@ void Finder::copy()
return;
}
size_t fromLine, toLine;
size_t fromLine = 0, toLine = 0;
{
const pair<size_t, size_t> lineRange = _scintView.getSelectionLinesRange();
fromLine = lineRange.first;
@ -5121,7 +5115,7 @@ intptr_t CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
case WM_SIZE :
{
RECT rc;
RECT rc{};
getClientRect(rc);
_scintView.reSizeTo(rc);
break;
@ -5335,7 +5329,7 @@ intptr_t CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPA
{
if (NppDarkMode::isEnabled())
{
RECT rcClient = {};
RECT rcClient{};
GetClientRect(_hSelf, &rcClient);
::FillRect(reinterpret_cast<HDC>(wParam), &rcClient, NppDarkMode::getDarkerBackgroundBrush());
return TRUE;
@ -5371,7 +5365,7 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt)
if (range.cpMin == range.cpMax)
return;
TCHAR text2Find[FINDREPLACE_MAXLENGTH];
TCHAR text2Find[FINDREPLACE_MAXLENGTH]{};
(*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, FINDREPLACE_MAXLENGTH, false); //do not expand selection (false)
opt->_str2Search = text2Find;
_pFRDlg->markAllInc(opt);
@ -5579,7 +5573,7 @@ void Progress::setPercent(unsigned percent, const TCHAR* fileName, int nbHitsSoF
{
::PostMessage(_hPBar, PBM_SETPOS, percent, 0);
::SendMessage(_hPathText, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(fileName));
TCHAR str[16];
TCHAR str[16]{};
_itow(nbHitsSoFar, str, 10);
::SendMessage(_hRunningHitsText, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(str));
}
@ -5593,7 +5587,7 @@ void Progress::setInfo(const TCHAR* info, int nbHitsSoFar) const
::SendMessage(_hPathText, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(info));
if (nbHitsSoFar != -1)
{
TCHAR str[16];
TCHAR str[16]{};
_itow(nbHitsSoFar, str, 10);
::SendMessage(_hRunningHitsText, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(str));
}
@ -5773,7 +5767,7 @@ LRESULT APIENTRY Progress::wndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM l
{
if (NppDarkMode::isEnabled())
{
RECT rc = {};
RECT rc{};
GetClientRect(hwnd, &rc);
::FillRect(reinterpret_cast<HDC>(wparam), &rc, NppDarkMode::getDarkerBackgroundBrush());
}

@ -145,7 +145,7 @@ public:
generic_string getHitsString(int count) const;
protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
bool notify(SCNotification *notification);
private:
@ -223,9 +223,6 @@ struct FindersInfo
class FindInFinderDlg : public StaticDialog
{
public:
void init(HINSTANCE hInst, HWND hPere) {
Window::init(hInst, hPere);
};
void doDialog(Finder *launcher, bool isRTL = false);
FindOption & getOption() { return _options; }
FindInFinderDlg() {
@ -237,7 +234,7 @@ private:
Finder *_pFinder2Search = nullptr;
FindOption _options;
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
void initFromOptions();
void writeOptions();
};
@ -265,7 +262,7 @@ public :
_ppEditView = ppEditView;
};
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true, bool toShow = true);
void create(int dialogID, bool isRTL = false, bool msgDestParent = true, bool toShow = true);
void initOptionsFromDlg();
@ -320,12 +317,12 @@ public :
bool isProjectPanel_3() const { return _env->_isProjectPanel_3; };
void saveFindHistory();
void changeTabName(DIALOG_TYPE index, const TCHAR *name2change) {
TCITEM tie;
TCITEM tie{};
tie.mask = TCIF_TEXT;
tie.pszText = (TCHAR *)name2change;
TabCtrl_SetItem(_tab.getHSelf(), index, &tie);
TCHAR label[MAX_PATH];
TCHAR label[MAX_PATH]{};
_tab.getCurrentTitle(label, MAX_PATH);
::SetWindowText(_hSelf, label);
}
@ -396,7 +393,7 @@ public :
protected :
void resizeDialogElements(LONG newWidth);
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
static WNDPROC originalFinderProc;
static WNDPROC originalComboEditProc;
@ -440,7 +437,7 @@ private :
bool _isRTL = false;
int _findAllResult;
int _findAllResult = 0;
TCHAR _findAllResultStr[1024] = {'\0'};
int _fileNameLenMax = 1024;
@ -525,8 +522,8 @@ class FindIncrementDlg : public StaticDialog
public :
FindIncrementDlg() = default;
void init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg, bool isRTL = false);
virtual void destroy();
virtual void display(bool toShow = true) const;
void destroy() override;
void display(bool toShow = true) const override;
void setSearchText(const TCHAR* txt2find, bool) {
::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(txt2find));
@ -545,9 +542,9 @@ private :
FindStatus _findStatus = FSFound;
ReBar* _pRebar = nullptr;
REBARBANDINFO _rbBand = {};
REBARBANDINFO _rbBand{};
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
void markSelectedTextInc(bool enable, FindOption *opt = NULL);
};

@ -51,11 +51,11 @@ BEGIN
CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,102,140,10
CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,114,140,10
GROUPBOX "Search Mode",IDC_MODE_STATIC,6,131,164,48
CONTROL "&Normal",IDNORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,143,126,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED,"Button",BS_AUTORADIOBUTTON,12,155,145,10
GROUPBOX "Search Mode",IDC_MODE_STATIC,6,131,200,48
CONTROL "&Normal",IDNORMAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,143,150,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED,"Button",BS_AUTORADIOBUTTON,12,155,150,10
CONTROL "Re&gular expression",IDREGEXP,"Button",BS_AUTORADIOBUTTON,12,167,78,10
CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,72,10
CONTROL "&. matches newline",IDREDOTMATCHNL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,101,10
GROUPBOX "",IDC_REPLACEINSELECTION,192,50,180,23
CONTROL "In select&ion",IDC_IN_SELECTION_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,58,59,10
@ -109,34 +109,34 @@ BEGIN
LTEXT "",IDC_INCFINDSTATUS,520,6,180,12
END
IDD_FINDRESULT DIALOGEX 26, 41, 223, 67
IDD_FINDRESULT DIALOGEX 0, 0, 223, 67
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Search results"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14, NOT WS_VISIBLE
DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14,NOT WS_VISIBLE // dummy control to prevent issue with focus (search result selection)
END
IDD_FINDINFINDER_DLG DIALOGEX 0, 0, 367, 200
IDD_FINDINFINDER_DLG DIALOGEX 0, 0, 365, 124
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Find in search results"
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
RTEXT "&Find what:",IDFINDWHAT_STATIC_FIFOLDER,6,22,75,8
COMBOBOX IDFINDWHAT_FIFOLDER,83,20,178,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
RTEXT "&Find what:",IDFINDWHAT_STATIC_FIFOLDER,6,11,75,8
COMBOBOX IDFINDWHAT_FIFOLDER,83,9,178,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP
CONTROL "Search only in found lines",IDC_MATCHLINENUM_CHECK_FIFOLDER,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,12,66,99,16
CONTROL "Match &whole word only",IDWHOLEWORD_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,88,140,10
CONTROL "Match &case",IDMATCHCASE_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,100,140,10
CONTROL "Search &only in found lines",IDC_MATCHLINENUM_CHECK_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,31,250,10
CONTROL "Match &whole word only",IDWHOLEWORD_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,43,140,10
CONTROL "Match &case",IDMATCHCASE_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,55,140,10
GROUPBOX "Search Mode",IDC_MODE_STATIC_FIFOLDER,6,131,164,48
CONTROL "&Normal",IDNORMAL_FIFOLDER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,143,126,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED_FIFOLDER, "Button",BS_AUTORADIOBUTTON,12,155,145,10
CONTROL "Re&gular expression",IDREGEXP_FIFOLDER,"Button",BS_AUTORADIOBUTTON,12,167,78,10
CONTROL "&. matches newline",IDREDOTMATCHNL_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,167,72,10
GROUPBOX "Search Mode",IDC_MODE_STATIC_FIFOLDER,6,70,200,48
CONTROL "&Normal",IDNORMAL_FIFOLDER,"Button",BS_AUTORADIOBUTTON | WS_GROUP,12,82,150,10
CONTROL "E&xtended (\\n, \\r, \\t, \\0, \\x...)",IDEXTENDED_FIFOLDER,"Button",BS_AUTORADIOBUTTON,12,94,150,10
CONTROL "Re&gular expression",IDREGEXP_FIFOLDER,"Button",BS_AUTORADIOBUTTON,12,106,78,10
CONTROL "&. matches newline",IDREDOTMATCHNL_FIFOLDER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,93,106,101,10
PUSHBUTTON "Find All",IDOK,268,20,90,14,WS_GROUP
PUSHBUTTON "Close",IDCANCEL,268,38,90,14
PUSHBUTTON "Find All",IDOK,268,9,90,14,WS_GROUP
PUSHBUTTON "Close",IDCANCEL,268,27,90,14
END

Loading…
Cancel
Save