mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-20 21:13:25 +08:00
Merge pull request #5019 from RaiKoHoff/Dev_Master
Update grepWinNP3 from current grepWin dev
This commit is contained in:
commit
20e0e2e5d3
Binary file not shown.
@ -437,6 +437,7 @@ BEGIN
|
||||
IDS_OPEN_MRU "Open list with recent entries"
|
||||
IDS_COPY_COLUMN "Copy column for all items"
|
||||
IDS_COPY_COLUMN_SEL "Copy column for selected items"
|
||||
IDS_REGEXEXCEPTION "Regex stack error"
|
||||
END
|
||||
|
||||
#endif // Neutral resources
|
||||
|
||||
@ -105,6 +105,23 @@ static SearchThreadMap s_SearchThreadMap;
|
||||
|
||||
// ==================================================================================
|
||||
|
||||
void drawRedEditBox(HWND hWnd, WPARAM wParam)
|
||||
{
|
||||
// make the border of the edit control red in case
|
||||
// the regex is invalid
|
||||
HDC hdc = nullptr;
|
||||
if (wParam == NULLREGION)
|
||||
hdc = GetDC(hWnd);
|
||||
else
|
||||
hdc = GetDCEx(hWnd, reinterpret_cast<HRGN>(wParam), DCX_WINDOW | DCX_INTERSECTRGN);
|
||||
RECT rc = {0};
|
||||
GetWindowRect(hWnd, &rc);
|
||||
MapWindowPoints(nullptr, hWnd, reinterpret_cast<LPPOINT>(&rc), 2);
|
||||
::SetBkColor(hdc, RGB(255, 0, 0));
|
||||
::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, nullptr, 0, nullptr);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK SearchEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR /*uIdSubclass*/, DWORD_PTR dwRefData)
|
||||
{
|
||||
switch (uMsg)
|
||||
@ -114,19 +131,47 @@ LRESULT CALLBACK SearchEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
auto searchDlg = reinterpret_cast<CSearchDlg*>(dwRefData);
|
||||
if (!searchDlg->isRegexValid())
|
||||
{
|
||||
// make the border of the edit control red in case
|
||||
// the regex is invalid
|
||||
HDC hdc = nullptr;
|
||||
if (wParam == NULLREGION)
|
||||
hdc = GetDC(hWnd);
|
||||
else
|
||||
hdc = GetDCEx(hWnd, reinterpret_cast<HRGN>(wParam), DCX_WINDOW | DCX_INTERSECTRGN);
|
||||
RECT rc = {0};
|
||||
GetWindowRect(hWnd, &rc);
|
||||
MapWindowPoints(nullptr, hWnd, reinterpret_cast<LPPOINT>(&rc), 2);
|
||||
::SetBkColor(hdc, RGB(255, 0, 0));
|
||||
::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, &rc, nullptr, 0, nullptr);
|
||||
ReleaseDC(hWnd, hdc);
|
||||
drawRedEditBox(hWnd, wParam);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK ExcludeDirEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR /*uIdSubclass*/, DWORD_PTR dwRefData)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_NCPAINT:
|
||||
{
|
||||
auto searchDlg = reinterpret_cast<CSearchDlg*>(dwRefData);
|
||||
if (!searchDlg->isExcludeDirsRegexValid())
|
||||
{
|
||||
drawRedEditBox(hWnd, wParam);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK FileNameMatchEditWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR /*uIdSubclass*/, DWORD_PTR dwRefData)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_NCPAINT:
|
||||
{
|
||||
auto searchDlg = reinterpret_cast<CSearchDlg*>(dwRefData);
|
||||
if (!searchDlg->isFileNameMatchRegexValid())
|
||||
{
|
||||
drawRedEditBox(hWnd, wParam);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -197,6 +242,8 @@ CSearchDlg::CSearchDlg(HWND hParent)
|
||||
, m_selectedItems(0)
|
||||
, m_bAscending(true)
|
||||
, m_isRegexValid(true)
|
||||
, m_isExcludeDirsRegexValid(true)
|
||||
, m_isFileNameMatchingRegexValid(true)
|
||||
, m_themeCallbackId(0)
|
||||
, m_pDropTarget(nullptr)
|
||||
, m_autoCompleteFilePatterns(bPortable ? &g_iniFile : nullptr)
|
||||
@ -318,6 +365,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
AddToolTip(IDC_REPLACETEXT, LPSTR_TEXTCALLBACK);
|
||||
|
||||
SetWindowSubclass(GetDlgItem(*this, IDC_SEARCHTEXT), SearchEditWndProc, SearchEditSubclassID, reinterpret_cast<DWORD_PTR>(this));
|
||||
SetWindowSubclass(GetDlgItem(*this, IDC_EXCLUDEDIRSPATTERN), ExcludeDirEditWndProc, SearchEditSubclassID, reinterpret_cast<DWORD_PTR>(this));
|
||||
SetWindowSubclass(GetDlgItem(*this, IDC_PATTERN), FileNameMatchEditWndProc, SearchEditSubclassID, reinterpret_cast<DWORD_PTR>(this));
|
||||
|
||||
if (m_searchPath.empty())
|
||||
{
|
||||
@ -468,7 +517,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
m_date2.dwLowDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date2Low", 0) : static_cast<DWORD>(m_regDate2Low);
|
||||
m_date2.dwHighDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date2High", 0) : static_cast<DWORD>(m_regDate2High);
|
||||
}
|
||||
else
|
||||
else if (m_date1.dwHighDateTime == 0 && m_date1.dwLowDateTime == 0)
|
||||
{
|
||||
// use the current date as default
|
||||
SYSTEMTIME st{};
|
||||
@ -895,8 +944,17 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
SendDlgItemMessage(*this, IDC_PROGRESS, PBM_SETMARQUEE, 1, 0);
|
||||
}
|
||||
break;
|
||||
//case SEARCH_FOUND:
|
||||
case SEARCH_PROGRESS:
|
||||
case SEARCH_FOUND:
|
||||
{
|
||||
auto searchInfo = reinterpret_cast<CSearchInfo*>(lParam);
|
||||
m_totalMatches += static_cast<int>(searchInfo->matchCount);
|
||||
if ((wParam != 0) || (m_searchString.empty()) || searchInfo->readError || !searchInfo->exception.empty() || IsNOTSearch())
|
||||
{
|
||||
AddFoundEntry(searchInfo);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SEARCH_PROGRESS:
|
||||
{
|
||||
const auto* const sInfo = (const CSearchInfo* const)(wParam);
|
||||
auto const nFound = static_cast<int>(lParam);
|
||||
@ -943,6 +1001,17 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
m_rtfDialog = std::make_unique<CInfoRtfDialog>();
|
||||
}
|
||||
m_rtfDialog->ShowModeless(g_hInst, *this, "grepWinNP3 help", IDR_INFODLG, L"RTF", IDI_GREPWIN, 400, 600);
|
||||
// ensure that the dialog is not too big and always visible on the screen
|
||||
RECT dlgRect{};
|
||||
GetWindowRect(*this, &dlgRect);
|
||||
WINDOWPLACEMENT placement{};
|
||||
placement.length = sizeof(WINDOWPLACEMENT);
|
||||
placement.showCmd = SW_SHOW;
|
||||
placement.rcNormalPosition = dlgRect;
|
||||
auto quarterWidth = (dlgRect.right - dlgRect.left) / 4;
|
||||
placement.rcNormalPosition.left += quarterWidth;
|
||||
placement.rcNormalPosition.right -= quarterWidth;
|
||||
SetWindowPlacement(*m_rtfDialog, &placement);
|
||||
}
|
||||
break;
|
||||
case WM_SYSCOMMAND:
|
||||
@ -1108,6 +1177,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
|
||||
SetDlgItemText(*this, IDC_EXCLUDEDIRSPATTERN, m_excludeDirsPatternRegex.c_str());
|
||||
SetDlgItemText(*this, IDC_PATTERN, m_patternRegex.c_str());
|
||||
DialogEnableWindow(IDC_WHOLEWORDS, IsDlgButtonChecked(hwndDlg, IDC_TEXTRADIO));
|
||||
CheckRegex();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1551,18 +1621,14 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
|
||||
break;
|
||||
case IDC_REGEXRADIO:
|
||||
case IDC_TEXTRADIO:
|
||||
case IDC_FILEPATTERNREGEX:
|
||||
case IDC_FILEPATTERNTEXT:
|
||||
{
|
||||
CheckRegex();
|
||||
DialogEnableWindow(IDC_TESTREGEX, !IsDlgButtonChecked(*this, IDC_TEXTRADIO));
|
||||
DialogEnableWindow(IDC_WHOLEWORDS, IsDlgButtonChecked(*this, IDC_TEXTRADIO));
|
||||
}
|
||||
break;
|
||||
case IDC_FILEPATTERNTEXT:
|
||||
case IDC_FILEPATTERNREGEX:
|
||||
{
|
||||
m_bUseRegexForPaths = (IsDlgButtonChecked(*this, IDC_FILEPATTERNREGEX) == BST_CHECKED);
|
||||
}
|
||||
break;
|
||||
case IDC_ADDTOBOOKMARKS:
|
||||
{
|
||||
auto buf = GetDlgItemText(IDC_SEARCHTEXT);
|
||||
@ -1708,6 +1774,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
|
||||
{
|
||||
if (m_autoCompleteFilePatterns.GetOptions() & ACO_NOPREFIXFILTERING)
|
||||
m_autoCompleteFilePatterns.SetOptions(ACO_UPDOWNKEYDROPSLIST | ACO_AUTOSUGGEST);
|
||||
CheckRegex();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1717,6 +1784,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
|
||||
{
|
||||
if (m_autoCompleteExcludeDirsPatterns.GetOptions() & ACO_NOPREFIXFILTERING)
|
||||
m_autoCompleteExcludeDirsPatterns.SetOptions(ACO_UPDOWNKEYDROPSLIST | ACO_AUTOSUGGEST);
|
||||
CheckRegex();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -2169,6 +2237,8 @@ void CSearchDlg::ShowContextMenu(HWND hWnd, int x, int y)
|
||||
case 2: // match count or read error
|
||||
if (pInfo->readError)
|
||||
copyText += sReadError.c_str();
|
||||
else if (!pInfo->exception.empty())
|
||||
copyText += pInfo->exception.c_str();
|
||||
else
|
||||
copyText += std::to_wstring(pInfo->matchCount);
|
||||
break;
|
||||
@ -2621,7 +2691,12 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
|
||||
CSearchInfo inf = m_items[iItem];
|
||||
|
||||
std::wstring matchString = inf.filePath + L"\n";
|
||||
std::wstring sFormat = TranslatedString(hResource, IDS_CONTEXTLINE);
|
||||
if (!inf.exception.empty())
|
||||
{
|
||||
matchString += inf.exception;
|
||||
matchString += L"\n";
|
||||
}
|
||||
std::wstring sFormat = TranslatedString(hResource, IDS_CONTEXTLINE);
|
||||
for (size_t i = 0; i < std::min<size_t>(inf.matchLines.size(), 5); ++i)
|
||||
{
|
||||
std::wstring matchText = inf.matchLines[i];
|
||||
@ -2639,13 +2714,15 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
|
||||
}
|
||||
if (lpNMItemActivate->hdr.code == LVN_GETDISPINFO)
|
||||
{
|
||||
static const std::wstring sBinary = TranslatedString(hResource, IDS_BINARY);
|
||||
static const std::wstring sBinary = TranslatedString(hResource, IDS_BINARY);
|
||||
static const std::wstring sReadError = TranslatedString(hResource, IDS_READERROR);
|
||||
static const std::wstring sRegexException = TranslatedString(hResource, IDS_REGEXEXCEPTION);
|
||||
|
||||
auto* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lpNMItemActivate);
|
||||
LV_ITEM* pItem = &(pDispInfo)->item;
|
||||
NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lpNMItemActivate);
|
||||
LV_ITEM* pItem = &(pDispInfo)->item;
|
||||
|
||||
int iItem = pItem->iItem;
|
||||
bool fileList = (IsDlgButtonChecked(*this, IDC_RESULTFILES) == BST_CHECKED);
|
||||
int iItem = pItem->iItem;
|
||||
bool fileList = (IsDlgButtonChecked(*this, IDC_RESULTFILES) == BST_CHECKED);
|
||||
|
||||
if (fileList)
|
||||
{
|
||||
@ -2663,7 +2740,9 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
|
||||
break;
|
||||
case 2: // match count or read error
|
||||
if (pInfo->readError)
|
||||
wcsncpy_s(pItem->pszText, pItem->cchTextMax, TranslatedString(hResource, IDS_READERROR).c_str(), pItem->cchTextMax - 1LL);
|
||||
wcsncpy_s(pItem->pszText, pItem->cchTextMax, sReadError.c_str(), pItem->cchTextMax - 1LL);
|
||||
else if (!pInfo->exception.empty())
|
||||
wcsncpy_s(pItem->pszText, pItem->cchTextMax, sRegexException.c_str(), pItem->cchTextMax - 1LL);
|
||||
else
|
||||
swprintf_s(pItem->pszText, pItem->cchTextMax, L"%lld", pInfo->matchCount);
|
||||
break;
|
||||
@ -4164,7 +4243,9 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
//SendMessage(*this, SEARCH_PROGRESS, 0, 0);
|
||||
//sInfo.exception = CUnicodeUtils::StdGetUnicode(ex.what());
|
||||
//SendMessage(*this, SEARCH_FOUND, 0, reinterpret_cast<LPARAM>(&sInfo));
|
||||
//SendMessage(*this, SEARCH_PROGRESS, 1, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -4402,10 +4483,14 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
//sInfo.exception = CUnicodeUtils::StdGetUnicode(ex.what());
|
||||
//SendMessage(*this, SEARCH_FOUND, 0, reinterpret_cast<LPARAM>(&sInfo));
|
||||
//SendMessage(*this, SEARCH_PROGRESS, 1, 0);
|
||||
return -1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
//SendMessage(*this, SEARCH_PROGRESS, 0, 0);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -4452,9 +4537,12 @@ void CSearchDlg::FormatDate(wchar_t dateNative[], const FILETIME& fileTime, bool
|
||||
|
||||
int CSearchDlg::CheckRegex()
|
||||
{
|
||||
m_isRegexValid = true;
|
||||
auto buf = GetDlgItemText(IDC_SEARCHTEXT);
|
||||
auto len = static_cast<int>(wcslen(buf.get()));
|
||||
m_isRegexValid = true;
|
||||
m_isExcludeDirsRegexValid = true;
|
||||
m_isFileNameMatchingRegexValid = true;
|
||||
|
||||
auto buf = GetDlgItemText(IDC_SEARCHTEXT);
|
||||
int len = static_cast<int>(wcslen(buf.get()));
|
||||
if (IsDlgButtonChecked(*this, IDC_REGEXRADIO) == BST_CHECKED)
|
||||
{
|
||||
m_bUseRegex = true;
|
||||
@ -4516,6 +4604,42 @@ int CSearchDlg::CheckRegex()
|
||||
RedrawWindow(GetDlgItem(*this, IDC_SEARCHTEXT), nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE);
|
||||
}
|
||||
|
||||
{
|
||||
buf = GetDlgItemText(IDC_EXCLUDEDIRSPATTERN);
|
||||
len = static_cast<int>(wcslen(buf.get()));
|
||||
if (len)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring sRegex = buf.get();
|
||||
boost::wregex expression = boost::wregex(sRegex);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
m_isExcludeDirsRegexValid = false;
|
||||
}
|
||||
}
|
||||
RedrawWindow(GetDlgItem(*this, IDC_EXCLUDEDIRSPATTERN), nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE);
|
||||
}
|
||||
if (IsDlgButtonChecked(*this, IDC_FILEPATTERNREGEX) == BST_CHECKED)
|
||||
{
|
||||
buf = GetDlgItemText(IDC_PATTERN);
|
||||
len = static_cast<int>(wcslen(buf.get()));
|
||||
if (len)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::wstring sRegex = buf.get();
|
||||
boost::wregex expression = boost::wregex(sRegex);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
m_isFileNameMatchingRegexValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
RedrawWindow(GetDlgItem(*this, IDC_PATTERN), nullptr, nullptr, RDW_FRAME | RDW_INVALIDATE);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
@ -47,10 +47,11 @@
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
#define SEARCH_START (WM_APP+1)
|
||||
#define SEARCH_PROGRESS (WM_APP+2)
|
||||
#define SEARCH_END (WM_APP+3)
|
||||
#define WM_GREPWIN_THREADEND (WM_APP+4)
|
||||
#define SEARCH_FOUND (WM_APP + 1)
|
||||
#define SEARCH_START (WM_APP + 2)
|
||||
#define SEARCH_PROGRESS (WM_APP + 3)
|
||||
#define SEARCH_END (WM_APP + 4)
|
||||
#define WM_GREPWIN_THREADEND (WM_APP + 5)
|
||||
|
||||
#define ID_ABOUTBOX 0x0010
|
||||
#define ID_CLONE 0x0011
|
||||
@ -140,6 +141,8 @@ public:
|
||||
inline void SetEndDialog() { m_endDialog = true; }
|
||||
inline void SetShowContent() { m_showContent = true; m_showContentSet = true; }
|
||||
inline bool isRegexValid() const { return m_isRegexValid; };
|
||||
inline bool isExcludeDirsRegexValid() const { return m_isExcludeDirsRegexValid; };
|
||||
inline bool isFileNameMatchRegexValid() const { return m_isFileNameMatchingRegexValid; };
|
||||
|
||||
protected:
|
||||
LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
|
||||
@ -247,6 +250,8 @@ private:
|
||||
std::wstring m_toolTipReplaceString;
|
||||
std::unique_ptr<CInfoRtfDialog> m_rtfDialog;
|
||||
bool m_isRegexValid;
|
||||
bool m_isExcludeDirsRegexValid;
|
||||
bool m_isFileNameMatchingRegexValid;
|
||||
|
||||
bool m_bStayOnTop;
|
||||
BYTE m_OpacityNoFocus;
|
||||
|
||||
@ -53,6 +53,7 @@ public:
|
||||
__int64 matchCount;
|
||||
CTextFile::UnicodeType encoding;
|
||||
FILETIME modifiedTime;
|
||||
std::wstring exception;
|
||||
bool readError;
|
||||
bool folder;
|
||||
};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// grepWin - regex search and replace for Windows
|
||||
|
||||
// Copyright (C) 2020-2021 - Stefan Kueng
|
||||
// Copyright (C) 2020-2021, 2023 - Stefan Kueng
|
||||
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -37,17 +37,17 @@ constexpr COLORREF darkBkColor = 0x202020;
|
||||
constexpr COLORREF darkTextColor = 0xDDDDDD;
|
||||
constexpr COLORREF darkDisabledTextColor = 0x808080;
|
||||
|
||||
constexpr auto SubclassID = 1234;
|
||||
constexpr auto SubclassID = 1234;
|
||||
|
||||
static int GetStateFromBtnState(LONG_PTR dwStyle, BOOL bHot, BOOL bFocus, LRESULT dwCheckState, int iPartId, BOOL bHasMouseCapture);
|
||||
static void GetRoundRectPath(Gdiplus::GraphicsPath* pPath, const Gdiplus::Rect& r, int dia);
|
||||
static void DrawRect(LPRECT prc, HDC hdcPaint, Gdiplus::DashStyle dashStyle, Gdiplus::Color clr, Gdiplus::REAL width);
|
||||
static void DrawFocusRect(LPRECT prcFocus, HDC hdcPaint);
|
||||
static void PaintControl(HWND hWnd, HDC hdc, RECT* prc, bool bDrawBorder);
|
||||
static BOOL DetermineGlowSize(int* piSize, LPCWSTR pszClassIdList = nullptr);
|
||||
static BOOL GetEditBorderColor(HWND hWnd, COLORREF* pClr);
|
||||
static int GetStateFromBtnState(LONG_PTR dwStyle, BOOL bHot, BOOL bFocus, LRESULT dwCheckState, int iPartId, BOOL bHasMouseCapture);
|
||||
static void GetRoundRectPath(Gdiplus::GraphicsPath* pPath, const Gdiplus::Rect& r, int dia);
|
||||
static void DrawRect(LPRECT prc, HDC hdcPaint, Gdiplus::DashStyle dashStyle, Gdiplus::Color clr, Gdiplus::REAL width);
|
||||
static void DrawFocusRect(LPRECT prcFocus, HDC hdcPaint);
|
||||
static void PaintControl(HWND hWnd, HDC hdc, RECT* prc, bool bDrawBorder);
|
||||
static BOOL DetermineGlowSize(int* piSize, LPCWSTR pszClassIdList = nullptr);
|
||||
static BOOL GetEditBorderColor(HWND hWnd, COLORREF* pClr);
|
||||
|
||||
HBRUSH CTheme::m_sBackBrush = nullptr;
|
||||
HBRUSH CTheme::m_sBackBrush = nullptr;
|
||||
|
||||
CTheme::CTheme()
|
||||
: m_bLoaded(false)
|
||||
@ -182,6 +182,9 @@ bool CTheme::SetThemeForDialog(HWND hWnd, bool bDark)
|
||||
|
||||
BOOL CTheme::AdjustThemeForChildrenProc(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
if (reinterpret_cast<LPARAM>(GetProp(hwnd, L"grepWinDarkMode")) == lParam)
|
||||
return TRUE;
|
||||
SetProp(hwnd, L"grepWinDarkMode", reinterpret_cast<HANDLE>(lParam));
|
||||
DarkModeHelper::Instance().AllowDarkModeForWindow(hwnd, static_cast<BOOL>(lParam));
|
||||
wchar_t szWndClassName[MAX_PATH] = {0};
|
||||
GetClassName(hwnd, szWndClassName, _countof(szWndClassName));
|
||||
@ -599,13 +602,13 @@ LRESULT CTheme::ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
BP_PAINTPARAMS params = {sizeof(BP_PAINTPARAMS)};
|
||||
params.dwFlags = BPPF_ERASE;
|
||||
|
||||
RECT rcExclusion = rcClient;
|
||||
params.prcExclude = &rcExclusion;
|
||||
RECT rcExclusion = rcClient;
|
||||
params.prcExclude = &rcExclusion;
|
||||
|
||||
// We have to calculate the exclusion rect and therefore
|
||||
// calculate the font height. We select the control's font
|
||||
// into the DC and fake a drawing operation:
|
||||
HFONT hFontOld = reinterpret_cast<HFONT>(SendMessage(hWnd, WM_GETFONT, 0L, NULL));
|
||||
HFONT hFontOld = reinterpret_cast<HFONT>(SendMessage(hWnd, WM_GETFONT, 0L, NULL));
|
||||
if (hFontOld)
|
||||
hFontOld = static_cast<HFONT>(SelectObject(hdc, hFontOld));
|
||||
|
||||
@ -658,7 +661,7 @@ LRESULT CTheme::ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
std::unique_ptr<Gdiplus::Graphics> myGraphics(new Gdiplus::Graphics(hdcPaint));
|
||||
int iY = RECTHEIGHT(rcDraw) / 2;
|
||||
Gdiplus::Rect rr = Gdiplus::Rect(rcClient.left, rcClient.top + iY,
|
||||
RECTWIDTH(rcClient), RECTHEIGHT(rcClient) - iY - 1);
|
||||
RECTWIDTH(rcClient), RECTHEIGHT(rcClient) - iY - 1);
|
||||
Gdiplus::GraphicsPath path;
|
||||
GetRoundRectPath(&path, rr, 5);
|
||||
myGraphics->DrawPath(myPen.get(), &path);
|
||||
@ -727,22 +730,22 @@ LRESULT CTheme::ButtonSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||
RECT rc;
|
||||
GetWindowRect(hWnd, &rc);
|
||||
GetCursorPos(&pt);
|
||||
BOOL bHot = PtInRect(&rc, pt);
|
||||
BOOL bFocus = GetFocus() == hWnd;
|
||||
BOOL bHot = PtInRect(&rc, pt);
|
||||
BOOL bFocus = GetFocus() == hWnd;
|
||||
|
||||
int iPartId = BP_CHECKBOX;
|
||||
int iPartId = BP_CHECKBOX;
|
||||
if (dwButtonType == BS_RADIOBUTTON || dwButtonType == BS_AUTORADIOBUTTON)
|
||||
iPartId = BP_RADIOBUTTON;
|
||||
|
||||
int iState = GetStateFromBtnState(dwStyle, bHot, bFocus, dwCheckState, iPartId, FALSE);
|
||||
int iState = GetStateFromBtnState(dwStyle, bHot, bFocus, dwCheckState, iPartId, FALSE);
|
||||
|
||||
int bmWidth = static_cast<int>(ceil(13.0 * CDPIAware::Instance().GetDPI(hWnd) / 96.0));
|
||||
int bmWidth = static_cast<int>(ceil(13.0 * CDPIAware::Instance().GetDPI(hWnd) / 96.0));
|
||||
|
||||
UINT uiHalfWidth = (RECTWIDTH(rcClient) - bmWidth) / 2;
|
||||
|
||||
// we have to use the whole client area, otherwise we get only partially
|
||||
// drawn areas:
|
||||
RECT rcPaint = rcClient;
|
||||
RECT rcPaint = rcClient;
|
||||
|
||||
if (dwButtonStyle & BS_LEFTTEXT)
|
||||
{
|
||||
@ -949,7 +952,7 @@ bool CTheme::IsDarkModeAllowed()
|
||||
auto major = std::stol(tokens[0]);
|
||||
auto minor = std::stol(tokens[1]);
|
||||
auto micro = std::stol(tokens[2]);
|
||||
//auto build = std::stol(tokens[3]);
|
||||
// auto build = std::stol(tokens[3]);
|
||||
|
||||
// the windows 10 update 1809 has the version
|
||||
// number as 10.0.17763.1
|
||||
@ -1037,7 +1040,7 @@ void CTheme::RGBtoHSL(COLORREF color, float& h, float& s, float& l)
|
||||
const float gPercent = static_cast<float>(GetGValue(color)) / 255;
|
||||
const float bPercent = static_cast<float>(GetBValue(color)) / 255;
|
||||
|
||||
float maxColor = 0;
|
||||
float maxColor = 0;
|
||||
if ((rPercent >= gPercent) && (rPercent >= bPercent))
|
||||
maxColor = rPercent;
|
||||
else if ((gPercent >= rPercent) && (gPercent >= bPercent))
|
||||
|
||||
@ -454,6 +454,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
std::wstring sPath = searchIni.GetValue(section.c_str(), L"searchpath");
|
||||
sPath = SanitizeSearchPaths(sPath);
|
||||
searchDlg.SetSearchPath(sPath);
|
||||
directlyPassedSearchPath.clear();
|
||||
}
|
||||
if (searchIni.GetValue(section.c_str(), L"searchfor"))
|
||||
searchDlg.SetSearchString(searchIni.GetValue(section.c_str(), L"searchfor"));
|
||||
|
||||
@ -90,6 +90,7 @@
|
||||
#define IDS_OPEN_MRU 176
|
||||
#define IDS_COPY_COLUMN 177
|
||||
#define IDS_COPY_COLUMN_SEL 178
|
||||
#define IDS_REGEXEXCEPTION 179
|
||||
#define IDC_SEARCHTEXT 1000
|
||||
#define IDC_REGEXRADIO 1001
|
||||
#define IDC_TEXTRADIO 1002
|
||||
|
||||
@ -23,6 +23,10 @@
|
||||
#include "Language.h"
|
||||
#include "SimpleIni.h"
|
||||
|
||||
#define BOOST_REGEX_BLOCKSIZE 4096
|
||||
#define BOOST_REGEX_MAX_BLOCKS (1024 * 32)
|
||||
#define BOOST_REGEX_MAX_CACHE_BLOCKS (16 * 32)
|
||||
|
||||
extern HINSTANCE g_hInst;
|
||||
extern bool bPortable;
|
||||
extern CSimpleIni g_iniFile;
|
||||
@ -30,4 +34,4 @@ extern std::wstring g_iniPath;
|
||||
|
||||
#define DEBUGOUTPUTREGPATH L"Software\\grepWinNP3\\DebugOutput"
|
||||
|
||||
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
Loading…
Reference in New Issue
Block a user