+upd: gerepWinNP3 based on grepWin v2.0.8.1054

This commit is contained in:
Rainer Kottenhoff 2021-07-02 10:45:18 +02:00
parent 65496aab82
commit ee184c7162
23 changed files with 399 additions and 250 deletions

View File

@ -5,6 +5,8 @@ This modified code is licensed under the [same license (GPL-3.0)](https://github
as the [original source code by Stefan Küng](https://github.com/stefankueng/grepWin).
[![Build Status](https://dev.azure.com/tortoisesvn/tortoisesvnGitHub/_apis/build/status/stefankueng.grepWin?branchName=master)](https://dev.azure.com/tortoisesvn/tortoisesvnGitHub/_build/latest?definitionId=8&branchName=master)
[![CodeQL](https://github.com/stefankueng/grepWin/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/stefankueng/grepWin/actions/workflows/codeql-analysis.yml)
grepWin is a simple search and replace tool which can use [regular expressions](https://en.wikipedia.org/wiki/Regular_expression) to do its job. This allows to do much more powerful searches and replaces.
In case you're not familiar with regular expressions, we have a very short [regular expression tutorial](https://tools.stefankueng.com/regexhelp.html) for you.

View File

@ -209,7 +209,7 @@
</exec>
</target>
<target name="setup" depends="grepWin">
<target name="setup" depends="grepWinNP3,pot">
<description>
Uses WiX to create an msi installer file.
</description>

View File

@ -1,4 +1,4 @@
// sktoolslib - common files for SK tools
// sktoolslib - common files for SK tools
// Copyright (C) 2019-2021 - Stefan Kueng
@ -17,7 +17,7 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#pragma once
#include <uxtheme.h>
#include <Uxtheme.h>
/// helper class for the Windows 10 dark mode
/// note: we use undocumented APIs here, so be careful!

View File

@ -145,7 +145,9 @@ DWORD CRegBaseCommon<S>::removeKey()
HKEY hKey = nullptr;
RegOpenKeyEx(m_base, GetPlainString(m_path), 0, KEY_WRITE | m_sam, &hKey);
return SHDeleteKey(m_base, GetPlainString(m_path));
auto ret = SHDeleteKey(m_base, GetPlainString(m_path));
RegCloseKey(hKey);
return ret;
}
template <class S>
@ -156,7 +158,9 @@ LONG CRegBaseCommon<S>::removeValue()
HKEY hKey = nullptr;
RegOpenKeyEx(m_base, GetPlainString(m_path), 0, KEY_WRITE | m_sam, &hKey);
return RegDeleteValue(hKey, GetPlainString(m_key));
auto ret = RegDeleteValue(hKey, GetPlainString(m_key));
RegCloseKey(hKey);
return ret;
}
/**
@ -354,7 +358,7 @@ public:
* Data access.
*/
operator const T&();
operator const T&();
virtual CRegTypedBase<T, Base>& operator=(const T& rhs);
};
@ -709,8 +713,8 @@ CRegStringCommon<Base>::CRegStringCommon(DWORD lookupInterval, const typename Ba
template <class Base>
void CRegStringCommon<Base>::InternalRead(HKEY hKey, typename Base::StringT& value)
{
DWORD size = 0;
DWORD type = 0;
DWORD size = 0;
DWORD type = 0;
Base::m_lastError = RegQueryValueEx(hKey, Base::GetPlainString(Base::m_key), nullptr, &type, nullptr, &size);
if (Base::m_lastError == ERROR_SUCCESS)
@ -806,8 +810,8 @@ public:
CRegTypedBase<CRect, CRegBase>::operator=(rhs);
return *this;
}
operator LPCRECT() { return (LPCRECT)(CRect) * this; }
operator LPRECT() { return (LPRECT)(CRect) * this; }
operator LPCRECT() { return (LPCRECT)(CRect) * this; }
operator LPRECT() { return (LPRECT)(CRect) * this; }
CRegRect& operator+=(POINT r) { return *this = (CRect) * this + r; }
CRegRect& operator+=(SIZE r) { return *this = (CRect) * this + r; }
CRegRect& operator+=(LPCRECT r) { return *this = (CRect) * this + r; }

View File

@ -361,7 +361,7 @@ LRESULT CRichStatusBar::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
{
if ((m_hoverPart >= 0) && m_parts[m_hoverPart].hoverActive)
{
auto transHot = Animator::Instance().CreateLinearTransition(m_animVars[m_hoverPart], 0.3, 1.0);
auto transHot = Animator::Instance().CreateSmoothStopTransition(m_animVars[m_hoverPart], 0.3, 1.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
if (storyBoard && transHot)
{
@ -375,7 +375,7 @@ LRESULT CRichStatusBar::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
}
if (oldHover >= 0)
{
auto transHot = Animator::Instance().CreateLinearTransition(m_animVars[oldHover], 0.3, 0.0);
auto transHot = Animator::Instance().CreateSmoothStopTransition(m_animVars[oldHover], 0.3, 0.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
if (storyBoard && transHot)
{
@ -399,7 +399,7 @@ LRESULT CRichStatusBar::WinMsgHandler(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
TrackMouseEvent(&tme);
if (m_hoverPart >= 0)
{
auto transHot = Animator::Instance().CreateLinearTransition(m_animVars[m_hoverPart], 0.3, 0.0);
auto transHot = Animator::Instance().CreateSmoothStopTransition(m_animVars[m_hoverPart], 0.3, 0.0);
auto storyBoard = Animator::Instance().CreateStoryBoard();
if (storyBoard && transHot)
{

View File

@ -151,15 +151,15 @@ struct STRINGRESOURCEIMAGE
int LoadStringEx(HINSTANCE hInstance, UINT uID, LPWSTR lpBuffer, int nBufferMax, WORD wLanguage)
{
STRINGRESOURCEIMAGE* pImage;
STRINGRESOURCEIMAGE* pImageEnd;
ULONG nResourceSize;
HGLOBAL hGlobal;
UINT iIndex;
STRINGRESOURCEIMAGE* pImage = nullptr;
STRINGRESOURCEIMAGE* pImageEnd = nullptr;
ULONG nResourceSize = 0;
HGLOBAL hGlobal = nullptr;
UINT iIndex = 0;
#ifndef UNICODE
BOOL defaultCharUsed;
#endif
int ret;
int ret = 0;
if (lpBuffer == nullptr)
return 0;
@ -234,9 +234,13 @@ int GetCodepageFromBuf(LPVOID pBuffer, int cb, bool& hasBOM, bool& inconclusive,
// scan the whole buffer for a 0x00000000 sequence
// if found, we assume a binary file
int nDwords = cb / 4;
int nullCount = 0;
int maxNull = max(1, nDwords / 256);
for (int i = 0; i < nDwords; ++i)
{
if (0x00000000 == pVal32[i])
++nullCount;
if (nullCount > maxNull)
return -1;
}
if (*pVal16 == 0xFEFF)
@ -266,7 +270,7 @@ int GetCodepageFromBuf(LPVOID pBuffer, int cb, bool& hasBOM, bool& inconclusive,
bool bNonAnsi = false;
int nNeedData = 0;
int i = 0;
int nullCount = 0;
nullCount = 0;
for (; i < cb; ++i)
{
UINT8 zChar = pVal8[i];

View File

@ -113,6 +113,8 @@ LRESULT CAboutDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
}
}
break;
default:
break;
}
}
break;
@ -130,11 +132,13 @@ LRESULT CAboutDlg::DoCommand(int id, int /*msg*/)
{
switch (id)
{
case IDOK:
// fall through
case IDCANCEL:
EndDialog(*this, id);
break;
case IDOK:
// fall through
case IDCANCEL:
EndDialog(*this, id);
break;
default:
break;
}
return 1;
}

View File

@ -92,6 +92,7 @@ void CBookmarks::AddBookmark(const Bookmark& bm)
SetValue(bm.Name.c_str(), L"casesensitive", bm.CaseSensitive ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"dotmatchesnewline", bm.DotMatchesNewline ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"backup", bm.Backup ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"wholewords", bm.WholeWords ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"utf8", bm.Utf8 ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"includesystem", bm.IncludeSystem ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"includefolder", bm.IncludeFolder ? L"true" : L"false");
@ -117,6 +118,7 @@ void CBookmarks::RemoveBookmark(const std::wstring& name)
Delete(name.c_str(), L"casesensitive", true);
Delete(name.c_str(), L"dotmatchesnewline", true);
Delete(name.c_str(), L"backup", true);
Delete(name.c_str(), L"wholewords", true);
Delete(name.c_str(), L"utf8", true);
Delete(name.c_str(), L"includesystem", true);
Delete(name.c_str(), L"includefolder", true);
@ -140,6 +142,7 @@ Bookmark CBookmarks::GetBookmark(const std::wstring& name) const
bk.CaseSensitive = wcscmp(GetValue(name.c_str(), L"casesensitive", L"false"), L"true") == 0;
bk.DotMatchesNewline = wcscmp(GetValue(name.c_str(), L"dotmatchesnewline", L"false"), L"true") == 0;
bk.Backup = wcscmp(GetValue(name.c_str(), L"backup", L"false"), L"true") == 0;
bk.WholeWords = wcscmp(GetValue(name.c_str(), L"wholewords", L"false"), L"true") == 0;
bk.Utf8 = wcscmp(GetValue(name.c_str(), L"utf8", L"false"), L"true") == 0;
bk.IncludeSystem = wcscmp(GetValue(name.c_str(), L"includesystem", L"false"), L"true") == 0;
bk.IncludeFolder = wcscmp(GetValue(name.c_str(), L"includefolder", L"false"), L"true") == 0;

View File

@ -29,6 +29,7 @@ public:
, CaseSensitive(false)
, DotMatchesNewline(false)
, Backup(false)
, WholeWords(false)
, Utf8(false)
, Binary(false)
, IncludeSystem(false)
@ -49,6 +50,7 @@ public:
bool CaseSensitive;
bool DotMatchesNewline;
bool Backup;
bool WholeWords;
bool Utf8;
bool Binary;
bool IncludeSystem;

View File

@ -37,6 +37,7 @@ CBookmarksDlg::CBookmarksDlg(HWND hParent)
, m_bCaseSensitive(false)
, m_bDotMatchesNewline(false)
, m_bBackup(false)
, m_bWholeWords(false)
, m_bUtf8(false)
, m_bForceBinary(false)
, m_bIncludeSystem(false)
@ -255,6 +256,8 @@ LRESULT CBookmarksDlg::DoCommand(int id, int /*msg*/)
}
}
break;
default:
break;
}
return 1;
}
@ -364,6 +367,7 @@ void CBookmarksDlg::PrepareSelected()
m_bCaseSensitive = wcscmp(m_bookmarks.GetValue(buf.get(), L"casesensitive", L"false"), L"true") == 0;
m_bDotMatchesNewline = wcscmp(m_bookmarks.GetValue(buf.get(), L"dotmatchesnewline", L"false"), L"true") == 0;
m_bBackup = wcscmp(m_bookmarks.GetValue(buf.get(), L"backup", L"false"), L"true") == 0;
m_bWholeWords = wcscmp(m_bookmarks.GetValue(buf.get(), L"wholewords", L"false"), L"true") == 0;
m_bUtf8 = wcscmp(m_bookmarks.GetValue(buf.get(), L"utf8", L"false"), L"true") == 0;
m_bForceBinary = wcscmp(m_bookmarks.GetValue(buf.get(), L"binary", L"false"), L"true") == 0;
m_bIncludeSystem = wcscmp(m_bookmarks.GetValue(buf.get(), L"includesystem", L"false"), L"true") == 0;

View File

@ -42,6 +42,7 @@ public:
bool GetSelectedSearchCase() const { return m_bCaseSensitive; }
bool GetSelectedDotMatchNewline() const { return m_bDotMatchesNewline; }
bool GetSelectedBackup() const { return m_bBackup; }
bool GetSelectedWholeWords() const { return m_bWholeWords; }
bool GetSelectedTreatAsUtf8() const { return m_bUtf8; }
bool GetSelectedTreatAsBinary() const { return m_bForceBinary; }
bool GetSelectedIncludeSystem() const { return m_bIncludeSystem; }
@ -70,6 +71,7 @@ private:
bool m_bCaseSensitive;
bool m_bDotMatchesNewline;
bool m_bBackup;
bool m_bWholeWords;
bool m_bUtf8;
bool m_bForceBinary;
bool m_bIncludeSystem;

View File

@ -101,6 +101,8 @@ LRESULT CNameDlg::DoCommand(int id, int /*msg*/)
case IDCANCEL:
EndDialog(*this, id);
break;
default:
break;
}
return 1;
}

View File

@ -162,6 +162,8 @@ LRESULT CRegexTestDlg::DoCommand(int id, int msg)
}
}
break;
default:
break;
}
return 1;
}

Binary file not shown.

View File

@ -53,15 +53,16 @@ STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_
CAPTION "grepWinNP3"
FONT 9, "Segoe UI", 400, 0, 0x1
BEGIN
LTEXT "Press F1 for help...",IDC_HELPLABEL,362,50,104,8
LTEXT "Press F1 for help...",IDC_HELPLABEL,400,50,100,8
CONTROL "<a>about grepWinNP3...</a>",IDC_ABOUTLINK,"SysLink",LWS_RIGHT | WS_TABSTOP,486,2,87,8
PUSHBUTTON "/",IDC_PATHMRU,14,20,11,12
EDITTEXT IDC_SEARCHPATH,31,20,516,12,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
PUSHBUTTON "...",IDC_SEARCHPATHBROWSE,552,20,13,12
PUSHBUTTON "Y",IDC_NEWINSTANCE,570,20,13,12
GROUPBOX "Search in",IDC_GROUPSEARCHIN,7,10,587,29
CONTROL "Regex search",IDC_REGEXRADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,84,50,100,10
CONTROL "Text search",IDC_TEXTRADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,198,50,105,10
CONTROL "Regex search",IDC_REGEXRADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,84,50,90,10
CONTROL "Text search",IDC_TEXTRADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,180,50,90,10
CONTROL "&Whole word",IDC_WHOLEWORDS,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP, 274,50,90,10
RTEXT "",IDC_REGEXOKLABEL,476,50,98,8
LTEXT "Search &for:",IDC_SEARCHFORLABEL,14,65,64,8
EDITTEXT IDC_SEARCHTEXT,83,64,484,12,ES_AUTOHSCROLL
@ -105,7 +106,7 @@ BEGIN
PUSHBUTTON "&Replace",IDC_REPLACE,457,198,62,14
CONTROL "Search",IDOK,"Button",BS_DEFSPLITBUTTON | WS_TABSTOP,523,198,62,14
GROUPBOX "Limit search",IDC_GROUPLIMITSEARCH,7,128,587,65
CONTROL "",IDC_RESULTLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS| LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,14,234,571,81
CONTROL "",IDC_RESULTLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,14,234,571,81
LTEXT "",IDC_SEARCHINFOLABEL,14,321,580,8
GROUPBOX "Search results",IDC_GROUPSEARCHRESULTS,7,214,587,118
CONTROL "Files",IDC_RESULTFILES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,84,222,89,10
@ -422,6 +423,7 @@ BEGIN
IDS_NEWINSTANCE_TT "Start new grepWinNP3 window"
IDS_STAY_ON_TOP "Stay On Top"
IDS_REPLACEUTF8 "You have the option ""%s"" enabled.\r\nWhen replacing, this option can lead to corrupted files.\r\nDo you want to proceed anyway?"
IDS_INFOLABELSEL "Searched %ld files, skipped %ld files. Found %ld matches in %ld files. %ld results selected."
END
#endif // Neutral resources

View File

@ -67,7 +67,7 @@
</head>
<body>
<p>this help file shows only the basics of a regular expression search, and
<p>This help file shows only the basics of a regular expression search, and
it's here only to show the flavor of the used regex.</p>
<p>If you're not familiar with regular expressions, please consult
a tutorial like <a href="https://www.regular-expressions.info/tutorial.html"
@ -287,4 +287,4 @@
</table>
</body>
</html>
</html>

View File

@ -64,7 +64,7 @@
#include <fstream>
#include <iterator>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <Commdlg.h>
#pragma warning(push)
@ -109,7 +109,7 @@ CSearchDlg::CSearchDlg(HWND hParent)
: m_hParent(hParent)
//, m_dwThreadRunning(FALSE)
//, m_cancelled(FALSE)
, m_pBookmarksDlg(nullptr)
, m_bookmarksDlg(nullptr)
, m_bUseRegex(false)
, m_bUseRegexForPaths(false)
, m_bAllSize(false)
@ -127,6 +127,8 @@ CSearchDlg::CSearchDlg(HWND hParent)
, m_bCreateBackupC(false)
, m_bCreateBackupInFolders(false)
, m_bCreateBackupInFoldersC(false)
, m_bWholeWords(false)
, m_bWholeWordsC(false)
, m_bUTF8(false)
, m_bUTF8C(false)
, m_bForceBinary(false)
@ -151,6 +153,7 @@ CSearchDlg::CSearchDlg(HWND hParent)
, m_totalItems(0)
, m_searchedItems(0)
, m_totalMatches(0)
, m_selectedItems(0)
, m_bAscending(true)
, m_themeCallbackId(0)
, m_pDropTarget(nullptr)
@ -168,6 +171,7 @@ CSearchDlg::CSearchDlg(HWND hParent)
, m_regIncludeSubfolders(L"Software\\grepWinNP3\\IncludeSubfolders", 1)
, m_regIncludeBinary(L"Software\\grepWinNP3\\IncludeBinary", 1)
, m_regCreateBackup(L"Software\\grepWinNP3\\CreateBackup")
, m_regWholeWords(L"Software\\grepWinNP3\\WholeWords")
, m_regUTF8(L"Software\\grepWinNP3\\UTF8")
, m_regCaseSensitive(L"Software\\grepWinNP3\\CaseSensitive")
, m_regDotMatchesNewline(L"Software\\grepWinNP3\\DotMatchesNewline")
@ -198,8 +202,6 @@ CSearchDlg::~CSearchDlg()
{
if (m_pDropTarget)
delete m_pDropTarget;
if (m_pBookmarksDlg)
delete m_pBookmarksDlg;
}
LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
@ -377,46 +379,49 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(hwndDlg, IDC_SIZECOMBO, CB_INSERTSTRING, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(static_cast<LPCWSTR>(TranslatedString(hResource, IDS_EQUALTO).c_str())));
SendDlgItemMessage(hwndDlg, IDC_SIZECOMBO, CB_INSERTSTRING, static_cast<WPARAM>(-1), reinterpret_cast<LPARAM>(static_cast<LPCWSTR>(TranslatedString(hResource, IDS_GREATERTHAN).c_str())));
if (!m_bIncludeSubfoldersC)
m_bIncludeSubfolders = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeSubfolders", true) : !!DWORD(m_regIncludeSubfolders);
m_bIncludeSubfolders = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeSubfolders", true) : !!static_cast<DWORD>(m_regIncludeSubfolders);
if (!m_bIncludeSystemC)
m_bIncludeSystem = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeSystem", true) : !!DWORD(m_regIncludeSystem);
m_bIncludeSystem = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeSystem", true) : !!static_cast<DWORD>(m_regIncludeSystem);
if (!m_bIncludeHiddenC)
m_bIncludeHidden = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeHidden", false) : !!DWORD(m_regIncludeHidden);
m_bIncludeHidden = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeHidden", false) : !!static_cast<DWORD>(m_regIncludeHidden);
if (!m_bIncludeBinaryC)
m_bIncludeBinaryC = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeBinary", false) : !!DWORD(m_regIncludeBinary);
m_bIncludeBinaryC = bPortable ? g_iniFile.GetBoolValue(L"global", L"IncludeBinary", false) : !!static_cast<DWORD>(m_regIncludeBinary);
if (!m_bCaseSensitiveC)
m_bCaseSensitive = bPortable ? g_iniFile.GetBoolValue(L"global", L"CaseSensitive", false) : !!DWORD(m_regCaseSensitive);
m_bCaseSensitive = bPortable ? g_iniFile.GetBoolValue(L"global", L"CaseSensitive", false) : !!static_cast<DWORD>(m_regCaseSensitive);
if (!m_bDotMatchesNewlineC)
m_bDotMatchesNewline = bPortable ? g_iniFile.GetBoolValue(L"global", L"DotMatchesNewline", false) : !!DWORD(m_regDotMatchesNewline);
m_bDotMatchesNewline = bPortable ? g_iniFile.GetBoolValue(L"global", L"DotMatchesNewline", false) : !!static_cast<DWORD>(m_regDotMatchesNewline);
if (!m_bCreateBackupC)
m_bCreateBackup = bPortable ? g_iniFile.GetBoolValue(L"global", L"CreateBackup", false) : !!DWORD(m_regCreateBackup);
m_bCreateBackup = bPortable ? g_iniFile.GetBoolValue(L"global", L"CreateBackup", false) : !!static_cast<DWORD>(m_regCreateBackup);
if (!m_bCreateBackupInFoldersC)
m_bCreateBackupInFolders = bPortable ? g_iniFile.GetBoolValue(L"settings", L"backupinfolder", false) : !!DWORD(m_regBackupInFolder);
if (!m_bUTF8C) {
m_bUTF8 = bPortable ? g_iniFile.GetBoolValue(L"global", L"UTF8", false) : !!DWORD(m_regUTF8);
m_bForceBinary = bPortable ? !!g_iniFile.GetBoolValue(L"global", L"Binary", false) : !!DWORD(m_regBinary);
m_bCreateBackupInFolders = bPortable ? g_iniFile.GetBoolValue(L"settings", L"backupinfolder", false) : !!static_cast<DWORD>(m_regBackupInFolder);
if (!m_bWholeWordsC)
m_bWholeWords = bPortable ? g_iniFile.GetBoolValue(L"global", L"WholeWords", false) : !!static_cast<DWORD>(m_regWholeWords);
if (!m_bUTF8C)
{
m_bUTF8 = bPortable ? g_iniFile.GetBoolValue(L"global", L"UTF8", false) : !!static_cast<DWORD>(m_regUTF8);
m_bForceBinary = bPortable ? !!g_iniFile.GetBoolValue(L"global", L"Binary", false) : !!static_cast<DWORD>(m_regBinary);
}
if (!m_bDotMatchesNewlineC)
m_bDotMatchesNewline = bPortable ? g_iniFile.GetBoolValue(L"global", L"DotMatchesNewline", false) : !!DWORD(m_regDotMatchesNewline);
m_bDotMatchesNewline = bPortable ? g_iniFile.GetBoolValue(L"global", L"DotMatchesNewline", false) : !!static_cast<DWORD>(m_regDotMatchesNewline);
if (!m_bSizeC)
{
m_bAllSize = bPortable ? g_iniFile.GetBoolValue(L"global", L"AllSize", false) : !!DWORD(m_regAllSize);
m_sizeCmp = bPortable ? g_iniFile.GetLongValue(L"global", L"SizeCombo", 0) : (int)DWORD(m_regSizeCombo);
m_bAllSize = bPortable ? g_iniFile.GetBoolValue(L"global", L"AllSize", false) : !!static_cast<DWORD>(m_regAllSize);
m_sizeCmp = bPortable ? g_iniFile.GetLongValue(L"global", L"SizeCombo", 0) : (int)static_cast<DWORD>(m_regSizeCombo);
}
if (!m_bDateLimitC)
{
m_dateLimit = bPortable ? g_iniFile.GetLongValue(L"global", L"DateLimit", 0) : (int)DWORD(m_regDateLimit);
m_date1.dwLowDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date1Low", 0) : DWORD(m_regDate1Low);
m_date1.dwHighDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date1High", 0) : DWORD(m_regDate1High);
m_date2.dwLowDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date2Low", 0) : DWORD(m_regDate2Low);
m_date2.dwHighDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date2High", 0) : DWORD(m_regDate2High);
m_dateLimit = bPortable ? g_iniFile.GetLongValue(L"global", L"DateLimit", 0) : (int)static_cast<DWORD>(m_regDateLimit);
m_date1.dwLowDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date1Low", 0) : static_cast<DWORD>(m_regDate1Low);
m_date1.dwHighDateTime = bPortable ? g_iniFile.GetLongValue(L"global", L"Date1High", 0) : static_cast<DWORD>(m_regDate1High);
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);
}
m_bUseRegex = (bPortable ? g_iniFile.GetBoolValue(L"global", L"UseRegex", false) : DWORD(m_regUseRegex));
m_bUseRegex = (bPortable ? g_iniFile.GetBoolValue(L"global", L"UseRegex", false) : static_cast<DWORD>(m_regUseRegex));
m_bStayOnTop = (BYTE)(bPortable ? g_iniFile.GetBoolValue(L"global", L"StayOnTop", false) : DWORD(m_regStayOnTop));
m_bStayOnTop = (BYTE)(bPortable ? g_iniFile.GetBoolValue(L"global", L"StayOnTop", false) : static_cast<DWORD>(m_regStayOnTop));
m_OpacityNoFocus = (BYTE)(bPortable ? g_iniFile.GetLongValue(L"global", L"OpacityNoFocus", 100) : DWORD(m_regOpacityNoFocus));
m_OpacityNoFocus = (BYTE)(bPortable ? g_iniFile.GetLongValue(L"global", L"OpacityNoFocus", 100) : static_cast<DWORD>(m_regOpacityNoFocus));
m_OpacityNoFocus = (m_OpacityNoFocus > 100) ? 100 : m_OpacityNoFocus;
SendDlgItemMessage(hwndDlg, IDC_SIZECOMBO, CB_SETCURSEL, m_sizeCmp, 0);
@ -434,7 +439,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
CheckRadioButton(hwndDlg, IDC_REGEXRADIO, IDC_TEXTRADIO, (bPortable ? g_iniFile.GetLongValue(L"global", L"UseRegex", 0) : static_cast<DWORD>(m_regUseRegex)) ? IDC_REGEXRADIO : IDC_TEXTRADIO);
CheckRadioButton(hwndDlg, IDC_ALLSIZERADIO, IDC_SIZERADIO, m_bAllSize ? IDC_ALLSIZERADIO : IDC_SIZERADIO);
CheckRadioButton(hwndDlg, IDC_FILEPATTERNREGEX, IDC_FILEPATTERNTEXT, m_bUseRegexForPaths ? IDC_FILEPATTERNREGEX : IDC_FILEPATTERNTEXT);
SendDlgItemMessage(hwndDlg, IDC_WHOLEWORDS, BM_SETCHECK, m_bWholeWords ? BST_CHECKED : BST_UNCHECKED, 0);
DialogEnableWindow(IDC_WHOLEWORDS, IsDlgButtonChecked(hwndDlg, IDC_TEXTRADIO));
if (!m_searchString.empty())
CheckRadioButton(*this, IDC_REGEXRADIO, IDC_TEXTRADIO, m_bUseRegex ? IDC_REGEXRADIO : IDC_TEXTRADIO);
@ -457,7 +463,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
CheckRadioButton(*this, IDC_RESULTFILES, IDC_RESULTCONTENT, m_showContent ? IDC_RESULTCONTENT : IDC_RESULTFILES);
CheckRadioButton(hwndDlg, IDC_RADIO_DATE_ALL, IDC_RADIO_DATE_BETWEEN, m_dateLimit + IDC_RADIO_DATE_ALL);
SYSTEMTIME sysTime;
SYSTEMTIME sysTime{};
auto hTime1 = GetDlgItem(hwndDlg, IDC_DATEPICK1);
FileTimeToSystemTime(&m_date1, &sysTime);
DateTime_SetSystemtime(hTime1, GDT_VALID, &sysTime);
@ -481,6 +487,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
m_resizer.AddControl(hwndDlg, IDC_GROUPSEARCHFOR, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_REGEXRADIO, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_TEXTRADIO, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_WHOLEWORDS, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_SEARCHFORLABEL, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_SEARCHTEXT, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_EDITMULTILINE1, RESIZER_TOPRIGHT);
@ -693,6 +700,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
return TRUE;
}
default:
break;
}
break;
#ifdef NP3_ALLOW_UPDATE
@ -710,6 +719,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
break;
}
default:
break;
}
break;
#endif
@ -728,6 +739,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
break;
}
default:
break;
}
break;
}
@ -766,6 +779,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
m_totalItems = 0;
m_searchedItems = 0;
m_totalMatches = 0;
m_selectedItems = 0;
UpdateInfoLabel();
SetTimer(*this, LABELUPDATETIMER, 200, nullptr);
SendDlgItemMessage(*this, IDC_PROGRESS, PBM_SETSTATE, PBST_NORMAL, 0);
@ -840,6 +854,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
CheckMenuItem(GetSystemMenu(*this, FALSE), ID_STAY_ON_TOP, m_bStayOnTop ? MF_BYCOMMAND | MF_CHECKED : MF_BYCOMMAND | MF_UNCHECKED);
}
break;
default:
break;
}
}
break;
@ -917,6 +933,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(*this, IDC_SEARCHPATH, WM_KEYDOWN, VK_DOWN, 0);
}
break;
default:
break;
}
return TRUE;
}
@ -928,27 +946,28 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
break;
case WM_BOOKMARK:
{
if (m_pBookmarksDlg)
if (m_bookmarksDlg)
{
m_searchString = m_pBookmarksDlg->GetSelectedSearchString();
m_replaceString = m_pBookmarksDlg->GetSelectedReplaceString();
m_bUseRegex = m_pBookmarksDlg->GetSelectedUseRegex();
m_searchString = m_bookmarksDlg->GetSelectedSearchString();
m_replaceString = m_bookmarksDlg->GetSelectedReplaceString();
m_bUseRegex = m_bookmarksDlg->GetSelectedUseRegex();
m_bCaseSensitive = m_pBookmarksDlg->GetSelectedSearchCase();
m_bDotMatchesNewline = m_pBookmarksDlg->GetSelectedDotMatchNewline();
m_bCreateBackup = m_pBookmarksDlg->GetSelectedBackup();
m_bUTF8 = m_pBookmarksDlg->GetSelectedTreatAsUtf8();
m_bForceBinary = m_pBookmarksDlg->GetSelectedTreatAsBinary();
m_bIncludeSystem = m_pBookmarksDlg->GetSelectedIncludeSystem();
m_bIncludeSubfolders = m_pBookmarksDlg->GetSelectedIncludeFolder();
m_bIncludeHidden = m_pBookmarksDlg->GetSelectedIncludeHidden();
m_bIncludeBinary = m_pBookmarksDlg->GetSelectedIncludeBinary();
m_excludeDirsPatternRegex = m_pBookmarksDlg->GetSelectedExcludeDirs();
m_patternRegex = m_pBookmarksDlg->GetSelectedFileMatch();
m_bUseRegexForPaths = m_pBookmarksDlg->GetSelectedFileMatchRegex();
if (!m_pBookmarksDlg->GetPath().empty())
m_bCaseSensitive = m_bookmarksDlg->GetSelectedSearchCase();
m_bDotMatchesNewline = m_bookmarksDlg->GetSelectedDotMatchNewline();
m_bCreateBackup = m_bookmarksDlg->GetSelectedBackup();
m_bWholeWords = m_bookmarksDlg->GetSelectedWholeWords();
m_bUTF8 = m_bookmarksDlg->GetSelectedTreatAsUtf8();
m_bForceBinary = m_bookmarksDlg->GetSelectedTreatAsBinary();
m_bIncludeSystem = m_bookmarksDlg->GetSelectedIncludeSystem();
m_bIncludeSubfolders = m_bookmarksDlg->GetSelectedIncludeFolder();
m_bIncludeHidden = m_bookmarksDlg->GetSelectedIncludeHidden();
m_bIncludeBinary = m_bookmarksDlg->GetSelectedIncludeBinary();
m_excludeDirsPatternRegex = m_bookmarksDlg->GetSelectedExcludeDirs();
m_patternRegex = m_bookmarksDlg->GetSelectedFileMatch();
m_bUseRegexForPaths = m_bookmarksDlg->GetSelectedFileMatchRegex();
if (!m_bookmarksDlg->GetPath().empty())
{
m_searchPath = m_pBookmarksDlg->GetPath();
m_searchPath = m_bookmarksDlg->GetPath();
SetDlgItemText(*this, IDC_SEARCHPATH, m_searchPath.c_str());
}
@ -966,10 +985,12 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(*this, IDC_INCLUDEBINARY, BM_SETCHECK, m_bIncludeBinary ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_CASE_SENSITIVE, BM_SETCHECK, m_bCaseSensitive ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_DOTMATCHNEWLINE, BM_SETCHECK, m_bDotMatchesNewline ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_WHOLEWORDS, BM_SETCHECK, m_bWholeWords ? BST_CHECKED : BST_UNCHECKED, 0);
CheckRadioButton(*this, IDC_FILEPATTERNREGEX, IDC_FILEPATTERNTEXT, m_bUseRegexForPaths ? IDC_FILEPATTERNREGEX : IDC_FILEPATTERNTEXT);
SetDlgItemText(*this, IDC_EXCLUDEDIRSPATTERN, m_excludeDirsPatternRegex.c_str());
SetDlgItemText(*this, IDC_PATTERN, m_patternRegex.c_str());
DialogEnableWindow(IDC_WHOLEWORDS, IsDlgButtonChecked(hwndDlg, IDC_TEXTRADIO));
}
}
break;
@ -1168,7 +1189,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
DWORD const nMax = std::thread::hardware_concurrency() << 2;
DWORD const nOfWorker = bPortable ? g_iniFile.GetLongValue(L"global", L"MaxNumOfWorker", nMax) :
DWORD(CRegStdDWORD(L"Software\\grepWinNP3\\MaxNumOfWorker", nMax));
static_cast<DWORD>(CRegStdDWORD(L"Software\\grepWinNP3\\MaxNumOfWorker", nMax));
if (nOfWorker > 1)
{
@ -1207,7 +1228,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
m_updateCheckThread.join();
#endif
bool const escClose = bPortable ? g_iniFile.GetBoolValue(L"settings", L"escclose", false) :
!!DWORD(CRegStdDWORD(L"Software\\grepWinNP3\\escclose", FALSE));
!!static_cast<DWORD>(CRegStdDWORD(L"Software\\grepWinNP3\\escclose", FALSE));
if (escClose)
{
@ -1379,6 +1400,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
{
CheckRegex();
DialogEnableWindow(IDC_TESTREGEX, !IsDlgButtonChecked(*this, IDC_TEXTRADIO));
DialogEnableWindow(IDC_WHOLEWORDS, IsDlgButtonChecked(*this, IDC_TEXTRADIO));
}
break;
case IDC_FILEPATTERNTEXT:
@ -1429,11 +1451,11 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
break;
case IDC_BOOKMARKS:
{
if (m_pBookmarksDlg == nullptr)
m_pBookmarksDlg = new CBookmarksDlg(*this);
if (!m_bookmarksDlg)
m_bookmarksDlg = std::make_unique<CBookmarksDlg>(*this);
else
m_pBookmarksDlg->InitBookmarks();
m_pBookmarksDlg->ShowModeless(hResource, IDD_BOOKMARKS, *this);
m_bookmarksDlg->InitBookmarks();
m_bookmarksDlg->ShowModeless(hResource, IDD_BOOKMARKS, *this);
}
break;
case IDC_RESULTFILES:
@ -1451,7 +1473,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
m_bCreateBackupInFolders = g_iniFile.GetBoolValue(L"settings", L"backupinfolder", false);
else {
m_regBackupInFolder.read();
m_bCreateBackupInFolders = !!DWORD(m_regBackupInFolder);
m_bCreateBackupInFolders = !!static_cast<DWORD>(m_regBackupInFolder);
}
CTheme::Instance().SetFontForDialog(*this, CTheme::Instance().GetDlgFontFaceName(), CTheme::Instance().GetDlgFontSize());
CLanguage::Instance().TranslateWindow(*this); // re-apply, cause update problems?
@ -1752,6 +1774,8 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
CheckDlgButton(*this, IDC_UTF8, BST_UNCHECKED);
}
break;
default:
break;
}
return 1;
}
@ -1781,8 +1805,12 @@ void CSearchDlg::UpdateInfoLabel()
{
std::wstring sText;
wchar_t buf[1024] = {0};
swprintf_s(buf, _countof(buf), TranslatedString(hResource, IDS_INFOLABEL).c_str(),
m_searchedItems, m_totalItems - m_searchedItems, m_totalMatches, m_items.size());
if (m_selectedItems)
swprintf_s(buf, _countof(buf), TranslatedString(hResource, IDS_INFOLABELSEL).c_str(),
m_searchedItems, m_totalItems - m_searchedItems, m_totalMatches, m_items.size(), m_selectedItems);
else
swprintf_s(buf, _countof(buf), TranslatedString(hResource, IDS_INFOLABEL).c_str(),
m_searchedItems, m_totalItems - m_searchedItems, m_totalMatches, m_items.size());
sText = buf;
SetDlgItemText(*this, IDC_SEARCHINFOLABEL, sText.c_str());
@ -1847,6 +1875,8 @@ bool CSearchDlg::InitResultList()
SendMessage(ListView_GetToolTips(hListControl), TTM_SETDELAYTIME, TTDT_AUTOPOP, SHRT_MAX);
m_selectedItems = 0;
return true;
}
@ -2085,6 +2115,8 @@ bool CSearchDlg::PreTranslateMessage(MSG* pMsg)
}
}
break;
default:
break;
}
}
return false;
@ -2099,6 +2131,15 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
OpenFileAtListIndex(lpNMItemActivate->iItem);
}
}
if (lpNMItemActivate->hdr.code == LVN_ITEMCHANGED)
{
if ((lpNMItemActivate->uOldState & LVIS_SELECTED) || (lpNMItemActivate->uNewState & LVIS_SELECTED))
{
HWND hListControl = GetDlgItem(*this, IDC_RESULTLIST);
m_selectedItems = ListView_GetSelectedCount(hListControl);
UpdateInfoLabel();
}
}
if (lpNMItemActivate->hdr.code == LVN_BEGINDRAG)
{
CDropFiles dropFiles; // class for creating DROPFILES struct
@ -2181,6 +2222,8 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
std::ranges::sort(m_items, ModifiedTimeCompareDesc);
bDidSort = true;
break;
default:
break;
}
if (bDidSort)
{
@ -2529,11 +2572,9 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
EscCtrlCharacters(searchfor);
SearchReplace(cmd, L"%pattern%", searchfor.c_str());
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
SecureZeroMemory(&startupInfo, sizeof(startupInfo));
STARTUPINFO startupInfo{};
PROCESS_INFORMATION processInfo{};
startupInfo.cb = sizeof(STARTUPINFO);
SecureZeroMemory(&processInfo, sizeof(processInfo));
CreateProcess(nullptr, const_cast<wchar_t*>(cmd.c_str()), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startupInfo, &processInfo);
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
@ -2686,12 +2727,9 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
application += lineNumberParam;
}
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
SecureZeroMemory(&startupInfo, sizeof(startupInfo));
STARTUPINFO startupInfo{};
PROCESS_INFORMATION processInfo{};
startupInfo.cb = sizeof(STARTUPINFO);
SecureZeroMemory(&processInfo, sizeof(processInfo));
CreateProcess(nullptr, const_cast<wchar_t*>(application.c_str()), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startupInfo, &processInfo);
CloseHandle(processInfo.hThread);
CloseHandle(processInfo.hProcess);
@ -2797,6 +2835,7 @@ bool CSearchDlg::SaveSettings()
m_bIncludeSubfolders = (IsDlgButtonChecked(*this, IDC_INCLUDESUBFOLDERS) == BST_CHECKED);
m_bIncludeBinary = (IsDlgButtonChecked(*this, IDC_INCLUDEBINARY) == BST_CHECKED);
m_bCreateBackup = (IsDlgButtonChecked(*this, IDC_CREATEBACKUP) == BST_CHECKED);
m_bWholeWords = (IsDlgButtonChecked(*this, IDC_WHOLEWORDS) == BST_CHECKED);
m_bUTF8 = (IsDlgButtonChecked(*this, IDC_UTF8) == BST_CHECKED);
m_bForceBinary = (IsDlgButtonChecked(*this, IDC_BINARY) == BST_CHECKED);
m_bCaseSensitive = (IsDlgButtonChecked(*this, IDC_CASE_SENSITIVE) == BST_CHECKED);
@ -2864,6 +2903,7 @@ bool CSearchDlg::SaveSettings()
g_iniFile.SetBoolValue(L"global", L"IncludeSubfolders", m_bIncludeSubfolders);
g_iniFile.SetBoolValue(L"global", L"IncludeBinary", m_bIncludeBinary);
g_iniFile.SetBoolValue(L"global", L"CreateBackup", m_bCreateBackup);
g_iniFile.SetBoolValue(L"global", L"WholeWords", m_bWholeWords);
g_iniFile.SetBoolValue(L"global", L"UTF8", m_bUTF8);
g_iniFile.SetBoolValue(L"global", L"StayOnTop", m_bStayOnTop);
g_iniFile.SetBoolValue(L"global", L"Binary", m_bForceBinary);
@ -2886,6 +2926,7 @@ bool CSearchDlg::SaveSettings()
m_regIncludeSubfolders = static_cast<DWORD>(m_bIncludeSubfolders);
m_regIncludeBinary = static_cast<DWORD>(m_bIncludeBinary);
m_regCreateBackup = static_cast<DWORD>(m_bCreateBackup);
m_regWholeWords = static_cast<DWORD>(m_bWholeWords);
m_regUTF8 = static_cast<DWORD>(m_bUTF8);
m_regStayOnTop = static_cast<DWORD>(m_bStayOnTop);
m_regBinary = static_cast<DWORD>(m_bForceBinary);
@ -3028,7 +3069,7 @@ DWORD CSearchDlg::SearchThread()
DWORD const nMaxNumOfWorker = std::thread::hardware_concurrency() << 2;
DWORD const nOfWorker = max(min(bPortable ? g_iniFile.GetLongValue(L"global", L"MaxNumOfWorker", nMaxNumOfWorker >> 1) :
DWORD(CRegStdDWORD(L"Software\\grepWinNP3\\MaxNumOfWorker", nMaxNumOfWorker >> 1)), nMaxNumOfWorker), 1);
static_cast<DWORD>(CRegStdDWORD(L"Software\\grepWinNP3\\MaxNumOfWorker", nMaxNumOfWorker >> 1)), nMaxNumOfWorker), 1);
s_SearchThreadMap.clear();
s_SearchThreadMap.set_max_worker(nOfWorker);
@ -3167,6 +3208,8 @@ DWORD CSearchDlg::SearchThread()
case 2: // greater than
bSearch = bSearch && (fullFileSize > m_lSize);
break;
default:
break;
}
}
}
@ -3205,6 +3248,7 @@ DWORD CSearchDlg::SearchThread()
m_bUseRegex,
m_bCaseSensitive,
m_bDotMatchesNewline,
m_bWholeWords,
m_bCreateBackup,
m_bCreateBackupInFolders,
m_bReplace,
@ -3283,6 +3327,24 @@ DWORD CSearchDlg::SearchThread()
break;
}
}
if (!m_bAllSize && bSearch)
{
// assume a 'file'-size of zero for dirs
switch (m_sizeCmp)
{
case 0: // less than
bSearch = bSearch && (0 < m_lSize);
break;
case 1: // equal
bSearch = bSearch && (0 == m_lSize);
break;
case 2: // greater than
bSearch = bSearch && (0 > m_lSize);
break;
default:
break;
}
}
if (bSearch)
{
auto sInfoPtr = std::make_shared<CSearchInfo>(pathBuf.get());
@ -3360,7 +3422,6 @@ DWORD WINAPI EvaluationThreadEntry(LPVOID lpParam)
return 0L;
}
#if 0
void CSearchDlg::SetSearchPath(const std::wstring& path)
{
m_searchPath = path;
@ -3372,7 +3433,6 @@ void CSearchDlg::SetFileMask(const std::wstring& mask, bool reg)
m_patternRegex = mask;
m_bUseRegexForPaths = reg;
}
#endif
void CSearchDlg::SetPreset(const std::wstring& preset)
{
@ -3399,6 +3459,7 @@ void CSearchDlg::SetPreset(const std::wstring& preset)
m_bCaseSensitive = bk.CaseSensitive;
m_bDotMatchesNewline = bk.DotMatchesNewline;
m_bCreateBackup = bk.Backup;
m_bWholeWords = bk.WholeWords;
m_bUTF8 = bk.Utf8;
m_bForceBinary = bk.Binary;
m_bIncludeSystem = bk.IncludeSystem;
@ -3417,6 +3478,7 @@ void CSearchDlg::SetPreset(const std::wstring& preset)
m_bIncludeBinaryC = true;
m_bCreateBackupC = true;
m_bCreateBackupInFoldersC = true;
m_bWholeWordsC = true;
m_bUTF8C = true;
m_bCaseSensitiveC = true;
m_bDotMatchesNewlineC = true;
@ -3455,6 +3517,12 @@ void CSearchDlg::SetCreateBackupsInFolders(bool bSet)
SetCreateBackups(bSet);
}
void CSearchDlg::SetWholeWords(bool bSet)
{
m_bWholeWordsC = true;
m_bWholeWords = bSet;
}
void CSearchDlg::SetUTF8(bool bSet)
{
m_bUTF8C = true;
@ -3573,6 +3641,8 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
{
SearchReplace(localSearchString, L"\\E", L"\\\\E");
localSearchString = L"\\Q" + localSearchString + L"\\E";
if (searchFlags.bWholeWords)
localSearchString = L"\\b" + localSearchString + L"\\b";
}
SearchReplace(localSearchString, L"${filepath}", sinfoPtr->filePath);
@ -3600,7 +3670,7 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
{
ProfileTimer profile((L"file load and parse: " + sinfoPtr->filePath).c_str());
auto nNullCount = bPortable ? int(g_iniFile.GetLongValue(L"settings", L"nullbytes", 0)) :
int(DWORD(CRegStdDWORD(L"Software\\grepWinNP3\\nullbytes", 0)));
int(static_cast<DWORD>(CRegStdDWORD(L"Software\\grepWinNP3\\nullbytes", 0)));
if (nNullCount > 0)
{
constexpr __int64 oneMB = 1024 * 1024;
@ -3837,7 +3907,7 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
nFound++;
if (IsNOTSearch())
break;
matchLinesNumbers.push_back(DWORD(whatC[0].first - fbeg));
matchLinesNumbers.push_back(static_cast<DWORD>(whatC[0].first - fbeg));
++sinfoPtr->matchCount;
// update search position:
start = whatC[0].second;
@ -3859,7 +3929,7 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
nFound++;
if (IsNOTSearch())
break;
matchLinesNumbers.push_back(DWORD(whatC[0].first - fbeg));
matchLinesNumbers.push_back(static_cast<DWORD>(whatC[0].first - fbeg));
++sinfoPtr->matchCount;
// update search position:
start = whatC[0].second;
@ -4100,10 +4170,11 @@ int CSearchDlg::CheckRegex()
void CSearchDlg::AutoSizeAllColumns()
{
HWND hListControl = GetDlgItem(*this, IDC_RESULTLIST);
auto headerCtrl = ListView_GetHeader(hListControl);
int nItemCount = ListView_GetItemCount(hListControl);
wchar_t textBuf[MAX_PATH * 4] = {0};
HWND hListControl = GetDlgItem(*this, IDC_RESULTLIST);
auto headerCtrl = ListView_GetHeader(hListControl);
int nItemCount = ListView_GetItemCount(hListControl);
wchar_t textBuf[MAX_PATH * 4] = {0};
std::vector<int> colWidths;
if (headerCtrl)
{
int maxCol = Header_GetItemCount(headerCtrl) - 1;
@ -4136,9 +4207,40 @@ void CSearchDlg::AutoSizeAllColumns()
if (cx < lineWidth)
cx = lineWidth;
}
ListView_SetColumnWidth(hListControl, col, cx);
colWidths.push_back(cx);
}
}
bool fileList = (IsDlgButtonChecked(*this, IDC_RESULTFILES) == BST_CHECKED);
if (!fileList)
{
RECT rc{};
ListView_GetItemRect(hListControl, 0, &rc, LVIR_BOUNDS);
auto itemWidth = rc.right - rc.left;
ListView_GetItemRect(hListControl, 0, &rc, LVIR_ICON);
auto iconWidth = rc.right - rc.left;
itemWidth -= iconWidth;
itemWidth -= 2 * GetSystemMetrics(SM_CXBORDER);
auto totalWidth = std::accumulate(colWidths.begin(), colWidths.end(), 0);
totalWidth -= colWidths[colWidths.size() - 2];
auto textWidth = itemWidth - totalWidth;
if (textWidth > 0)
colWidths[colWidths.size() - 2] = textWidth;
else
{
colWidths[colWidths.size() - 1] = 100;
totalWidth = std::accumulate(colWidths.begin(), colWidths.end(), 0);
totalWidth -= colWidths[colWidths.size() - 2];
textWidth = itemWidth - totalWidth;
if (textWidth > 0)
colWidths[colWidths.size() - 2] = textWidth;
}
}
int col = 0;
for (const auto& colWidth : colWidths)
{
ListView_SetColumnWidth(hListControl, col, colWidth);
++col;
}
}
int CSearchDlg::GetSelectedListIndex(int index)

View File

@ -66,6 +66,7 @@ typedef struct _SearchFlags_t
bool bUseRegex;
bool bCaseSensitive;
bool bDotMatchesNewline;
bool bWholeWords;
bool bCreateBackup;
bool bBackupInFolder;
bool bReplace;
@ -91,33 +92,37 @@ public:
CSearchDlg(HWND hParent);
~CSearchDlg() override;
DWORD SearchThread();
DWORD EvaluationThread();
inline void SetSearchPath(const std::wstring& path) {m_searchPath = path; SearchReplace(m_searchPath, L"/", L"\\"); }
inline void SetSearchString(const std::wstring& search) { m_searchString = search; }
inline void SetFileMask(const std::wstring& mask, bool reg) {m_patternRegex = mask; m_bUseRegexForPaths = reg;}
inline void SetDirExcludeRegexMask(const std::wstring& mask) { m_excludeDirsPatternRegex = mask; }
inline void SetReplaceWith(const std::wstring& replace) { m_replaceString = replace; }
inline void SetUseRegex(bool reg) { m_bUseRegex = reg; }
void SetPreset(const std::wstring& preset);
DWORD SearchThread();
DWORD EvaluationThread();
inline void SetCaseSensitive(bool bSet) {m_bCaseSensitiveC = true; m_bCaseSensitive = bSet;}
inline void SetMatchesNewline(bool bSet) {m_bDotMatchesNewlineC = true; m_bDotMatchesNewline = bSet;}
inline void SetCreateBackups(bool bSet) { m_bCreateBackupC = true; m_bCreateBackup = bSet; m_bConfirmationOnReplace = false; }
inline void SetCreateBackupsInFolders(bool bSet) { m_bCreateBackupInFoldersC = true; m_bCreateBackupInFolders = bSet; SetCreateBackups(bSet); }
inline void SetUTF8(bool bSet) { m_bUTF8C = true; m_bUTF8 = bSet; m_bForceBinary = false; }
inline void SetBinary(bool bSet) { m_bUTF8C = true; m_bForceBinary = bSet; m_bUTF8 = false; }
inline void SetSize(uint64_t size, int cmp) {m_bSizeC = true; m_lSize = size; m_sizeCmp = cmp; m_bAllSize = (size == (uint64_t)-1);}
inline void SetIncludeSystem(bool bSet) {m_bIncludeSystemC = true; m_bIncludeSystem = bSet;}
inline void SetIncludeHidden(bool bSet) {m_bIncludeHiddenC = true; m_bIncludeHidden = bSet;}
inline void SetIncludeSubfolders(bool bSet) {m_bIncludeSubfoldersC = true; m_bIncludeSubfolders = bSet;}
inline void SetIncludeBinary(bool bSet) {m_bIncludeBinaryC = true; m_bIncludeBinary = bSet;}
inline void SetDateLimit(int datelimit, FILETIME t1, FILETIME t2) { m_bDateLimitC = true; m_dateLimit = datelimit; m_date1 = t1; m_date2 = t2; }
inline void SetNoSaveSettings(bool nosave) { m_bNoSaveSettings = nosave; }
void SetSearchPath(const std::wstring& path);
void SetFileMask(const std::wstring& mask, bool reg);
void SetPreset(const std::wstring& preset);
inline void SetSearchString(const std::wstring& search) { m_searchString = search; }
inline void SetDirExcludeRegexMask(const std::wstring& mask) { m_excludeDirsPatternRegex = mask; }
inline void SetReplaceWith(const std::wstring& replace) { m_replaceString = replace; }
inline void SetUseRegex(bool reg) { m_bUseRegex = reg; }
inline void SetCaseSensitive(bool bSet) { m_bCaseSensitiveC = true; m_bCaseSensitive = bSet; }
inline void SetMatchesNewline(bool bSet) { m_bDotMatchesNewlineC = true; m_bDotMatchesNewline = bSet; }
inline void SetCreateBackups(bool bSet) { m_bCreateBackupC = true; m_bCreateBackup = bSet; m_bConfirmationOnReplace = false; }
inline void SetCreateBackupsInFolders(bool bSet) { m_bCreateBackupInFoldersC = true; m_bCreateBackupInFolders = bSet; SetCreateBackups(bSet); }
inline void SetWholeWords(bool bSet) { m_bWholeWordsC = true; m_bWholeWords = bSet; }
inline void SetUTF8(bool bSet) { m_bUTF8C = true; m_bUTF8 = bSet; m_bForceBinary = false; }
inline void SetBinary(bool bSet) { m_bUTF8C = true; m_bForceBinary = bSet; m_bUTF8 = false; }
inline void SetSize(uint64_t size, int cmp) { m_bSizeC = true; m_lSize = size; m_sizeCmp = cmp; m_bAllSize = (size == (uint64_t)-1); }
inline void SetIncludeSystem(bool bSet) { m_bIncludeSystemC = true; m_bIncludeSystem = bSet; }
inline void SetIncludeHidden(bool bSet) { m_bIncludeHiddenC = true; m_bIncludeHidden = bSet; }
inline void SetIncludeSubfolders(bool bSet) { m_bIncludeSubfoldersC = true; m_bIncludeSubfolders = bSet; }
inline void SetIncludeBinary(bool bSet) { m_bIncludeBinaryC = true; m_bIncludeBinary = bSet; }
inline void SetDateLimit(int datelimit, FILETIME t1, FILETIME t2) { m_bDateLimitC = true; m_dateLimit = datelimit; m_date1 = t1; m_date2 = t2; }
inline void SetNoSaveSettings(bool nosave) { m_bNoSaveSettings = nosave; }
inline void SetExecute(ExecuteAction execute) { m_executeImmediately = execute; }
inline void SetEndDialog() { m_endDialog = true; }
inline void SetShowContent() { m_showContent = true; m_showContentSet = true; }
inline void SetExecute(ExecuteAction execute) { m_executeImmediately = execute; }
inline void SetEndDialog() { m_endDialog = true; }
inline void SetShowContent() { m_showContent = true; m_showContentSet = true; }
protected:
LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) override;
LRESULT DoCommand(int id, int msg);
@ -167,116 +172,123 @@ private:
static bool ExtCompareDesc(const CSearchInfo& entry1, const CSearchInfo& entry2);
private:
HWND m_hParent;
CBookmarksDlg * m_pBookmarksDlg;
ComPtr<ITaskbarList3> m_pTaskbarList;
HWND m_hParent;
//volatile LONG m_dwThreadRunning;
//volatile LONG m_cancelled;
std::wstring m_searchPath;
std::wstring m_searchString;
std::wstring m_replaceString;
std::vector<std::wstring> m_patterns;
std::wstring m_patternRegex;
std::wstring m_excludeDirsPatternRegex;
bool m_bUseRegex;
bool m_bUseRegexForPaths;
bool m_bAllSize;
uint64_t m_lSize;
int m_sizeCmp;
bool m_bIncludeSystem;
bool m_bIncludeSystemC;
bool m_bIncludeHidden;
bool m_bIncludeHiddenC;
bool m_bIncludeSubfolders;
bool m_bIncludeSubfoldersC;
bool m_bIncludeBinary;
bool m_bIncludeBinaryC;
bool m_bCreateBackup;
bool m_bCreateBackupC;
bool m_bCreateBackupInFolders;
bool m_bCreateBackupInFoldersC;
bool m_bUTF8;
bool m_bUTF8C;
bool m_bForceBinary;
bool m_bCaseSensitive;
bool m_bCaseSensitiveC;
bool m_bDotMatchesNewline;
bool m_bDotMatchesNewlineC;
bool m_bNotSearch;
bool m_bCaptureSearch;
bool m_bSizeC;
bool m_endDialog;
ExecuteAction m_executeImmediately;
int m_dateLimit;
bool m_bDateLimitC;
FILETIME m_date1;
FILETIME m_date2;
bool m_bNoSaveSettings;
std::unique_ptr<CBookmarksDlg> m_bookmarksDlg;
ComPtr<ITaskbarList3> m_pTaskbarList;
bool m_bReplace;
bool m_bConfirmationOnReplace;
bool m_showContent;
bool m_showContentSet;
bool m_bStayOnTop;
BYTE m_OpacityNoFocus;
std::vector<CSearchInfo> m_items;
std::wstring m_searchPath;
std::wstring m_searchString;
std::wstring m_replaceString;
std::vector<std::wstring> m_patterns;
std::wstring m_patternRegex;
std::wstring m_excludeDirsPatternRegex;
bool m_bUseRegex;
bool m_bUseRegexForPaths;
bool m_bAllSize;
uint64_t m_lSize;
int m_sizeCmp;
bool m_bIncludeSystem;
bool m_bIncludeSystemC;
bool m_bIncludeHidden;
bool m_bIncludeHiddenC;
bool m_bIncludeSubfolders;
bool m_bIncludeSubfoldersC;
bool m_bIncludeBinary;
bool m_bIncludeBinaryC;
bool m_bCreateBackup;
bool m_bCreateBackupC;
bool m_bCreateBackupInFolders;
bool m_bCreateBackupInFoldersC;
bool m_bWholeWords;
bool m_bWholeWordsC;
bool m_bUTF8;
bool m_bUTF8C;
bool m_bForceBinary;
bool m_bCaseSensitive;
bool m_bCaseSensitiveC;
bool m_bDotMatchesNewline;
bool m_bDotMatchesNewlineC;
bool m_bNotSearch;
bool m_bCaptureSearch;
bool m_bSizeC;
bool m_endDialog;
ExecuteAction m_executeImmediately;
int m_dateLimit;
bool m_bDateLimitC;
FILETIME m_date1;
FILETIME m_date2;
bool m_bNoSaveSettings;
bool m_bReplace;
bool m_bConfirmationOnReplace;
bool m_showContent;
bool m_showContentSet;
std::vector<CSearchInfo> m_items;
std::vector<std::tuple<int, int>> m_listItems;
std::set<std::wstring> m_backupAndTempFiles;
int m_totalItems;
int m_searchedItems;
int m_totalMatches;
int m_selectedItems;
bool m_bAscending;
std::wstring m_resultString;
std::wstring m_toolTipReplaceString;
int m_totalItems;
int m_searchedItems;
int m_totalMatches;
bool m_bAscending;
std::wstring m_resultString;
std::wstring m_toolTipReplaceString;
CDlgResizer m_resizer;
int m_themeCallbackId;
bool m_bStayOnTop;
BYTE m_OpacityNoFocus;
CFileDropTarget * m_pDropTarget;
CDlgResizer m_resizer;
int m_themeCallbackId;
static UINT m_grepwinStartupmsg;
CFileDropTarget* m_pDropTarget;
static UINT m_grepwinStartupmsg;
#ifdef NP3_ALLOW_UPDATE
std::thread m_updateCheckThread;
std::thread m_updateCheckThread;
#endif
CAutoComplete m_autoCompleteFilePatterns;
CAutoComplete m_autoCompleteExcludeDirsPatterns;
CAutoComplete m_autoCompleteSearchPatterns;
CAutoComplete m_autoCompleteReplacePatterns;
CAutoComplete m_autoCompleteSearchPaths;
CAutoComplete m_autoCompleteFilePatterns;
CAutoComplete m_autoCompleteExcludeDirsPatterns;
CAutoComplete m_autoCompleteSearchPatterns;
CAutoComplete m_autoCompleteReplacePatterns;
CAutoComplete m_autoCompleteSearchPaths;
CEditDoubleClick m_editFilePatterns;
CEditDoubleClick m_editExcludeDirsPatterns;
CEditDoubleClick m_editSearchPatterns;
CEditDoubleClick m_editReplacePatterns;
CEditDoubleClick m_editSearchPaths;
CEditDoubleClick m_editFilePatterns;
CEditDoubleClick m_editExcludeDirsPatterns;
CEditDoubleClick m_editSearchPatterns;
CEditDoubleClick m_editReplacePatterns;
CEditDoubleClick m_editSearchPaths;
CRegStdDWORD m_regUseRegex;
CRegStdDWORD m_regAllSize;
CRegStdString m_regSize;
CRegStdDWORD m_regSizeCombo;
CRegStdDWORD m_regIncludeSystem;
CRegStdDWORD m_regIncludeHidden;
CRegStdDWORD m_regIncludeSubfolders;
CRegStdDWORD m_regIncludeBinary;
CRegStdDWORD m_regCreateBackup;
CRegStdDWORD m_regUTF8;
CRegStdDWORD m_regBinary;
CRegStdDWORD m_regCaseSensitive;
CRegStdDWORD m_regDotMatchesNewline;
CRegStdDWORD m_regUseRegexForPaths;
CRegStdString m_regPattern;
CRegStdString m_regExcludeDirsPattern;
CRegStdString m_regSearchPath;
CRegStdString m_regEditorCmd;
CRegStdDWORD m_regBackupInFolder;
CRegStdDWORD m_regDateLimit;
CRegStdDWORD m_regDate1Low;
CRegStdDWORD m_regDate1High;
CRegStdDWORD m_regDate2Low;
CRegStdDWORD m_regDate2High;
CRegStdDWORD m_regShowContent;
CRegStdDWORD m_regOpacityNoFocus;
CRegStdDWORD m_regStayOnTop;
CRegStdDWORD m_regUseRegex;
CRegStdDWORD m_regAllSize;
CRegStdString m_regSize;
CRegStdDWORD m_regSizeCombo;
CRegStdDWORD m_regIncludeSystem;
CRegStdDWORD m_regIncludeHidden;
CRegStdDWORD m_regIncludeSubfolders;
CRegStdDWORD m_regIncludeBinary;
CRegStdDWORD m_regCreateBackup;
CRegStdDWORD m_regWholeWords;
CRegStdDWORD m_regUTF8;
CRegStdDWORD m_regBinary;
CRegStdDWORD m_regCaseSensitive;
CRegStdDWORD m_regDotMatchesNewline;
CRegStdDWORD m_regUseRegexForPaths;
CRegStdString m_regPattern;
CRegStdString m_regExcludeDirsPattern;
CRegStdString m_regSearchPath;
CRegStdString m_regEditorCmd;
CRegStdDWORD m_regBackupInFolder;
CRegStdDWORD m_regDateLimit;
CRegStdDWORD m_regDate1Low;
CRegStdDWORD m_regDate1High;
CRegStdDWORD m_regDate2Low;
CRegStdDWORD m_regDate2High;
CRegStdDWORD m_regShowContent;
CRegStdDWORD m_regStayOnTop;
CRegStdDWORD m_regOpacityNoFocus;
};

View File

@ -73,7 +73,7 @@ static void RegisterContextMenu(bool bAdd)
{
std::wstring sIconPath = CStringUtils::Format(L"%s,-%d", CPathUtils::GetLongPathname(CPathUtils::GetModulePath()).c_str(), IDI_GREPWIN);
std::wstring sExePath = CStringUtils::Format(L"%s /searchpath:\"%%1\"", CPathUtils::GetLongPathname(CPathUtils::GetModulePath()).c_str());
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\shell\\grepWinNP3", nullptr, REG_SZ, L"search with grepWinNP3", sizeof(L"search with grepWinNP3") + 2);
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\shell\\grepWinNP3", nullptr, REG_SZ, L"search with grepWinNP3\0", sizeof(L"search with grepWinNP3\0"));
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\shell\\grepWinNP3", L"Icon", REG_SZ, sIconPath.c_str(), static_cast<DWORD>((sIconPath.size() + 1) * sizeof(WCHAR)));
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\shell\\grepWinNP3\\Command", nullptr, REG_SZ, sExePath.c_str(), static_cast<DWORD>((sExePath.size() + 1) * sizeof(WCHAR)));
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\Background\\shell\\grepWinNP3", nullptr, REG_SZ, L"search with grepWinNP3", sizeof(L"search with grepWinNP3") + 2);
@ -88,7 +88,7 @@ static void RegisterContextMenu(bool bAdd)
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\*\\shell\\grepWinNP3", nullptr, REG_SZ, L"search with grepWinNP3", sizeof(L"search with grepWinNP3") + 2);
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\*\\shell\\grepWinNP3", L"Icon", REG_SZ, sIconPath.c_str(), static_cast<DWORD>((sIconPath.size() + 1) * sizeof(WCHAR)));
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\*\\shell\\grepWinNP3\\Command", nullptr, REG_SZ, sExePath.c_str(), static_cast<DWORD>((sExePath.size() + 1) * sizeof(WCHAR)));
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\*\\shell\\grepWinNP3", L"MultiSelectModel", REG_SZ, L"Player", sizeof(L"Player") + 2);
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\*\\shell\\grepWinNP3", L"MultiSelectModel", REG_SZ, L"Player\0", sizeof(L"Player\0") + 2);
sExePath = CStringUtils::Format(L"%s /searchpath:\"%%V\"", CPathUtils::GetLongPathname(CPathUtils::GetModulePath()).c_str());
SHSetValue(HKEY_CURRENT_USER, L"Software\\Classes\\Directory\\Background\\shell\\grepWinNP3\\Command", nullptr, REG_SZ, sExePath.c_str(), static_cast<DWORD>((sExePath.size() + 1) * sizeof(WCHAR)));
@ -103,9 +103,7 @@ static void RegisterContextMenu(bool bAdd)
}
}
BOOL CALLBACK windowenumerator(__in HWND hwnd,__in LPARAM lParam)
BOOL CALLBACK windowEnumerator(__in HWND hwnd, __in LPARAM lParam)
{
HWND* pWnd = reinterpret_cast<HWND*>(lParam);
WCHAR buf[MAX_PATH] = {0};
@ -201,7 +199,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
{
do
{
if (EnumWindows(windowenumerator, reinterpret_cast<LPARAM>(&hWnd)) != FALSE)
if (EnumWindows(windowEnumerator, reinterpret_cast<LPARAM>(&hWnd)) != FALSE)
{
// long running grepWin Window found:
// if a grepWin process is currently initializing,
@ -219,7 +217,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
}
}
hWnd = nullptr;
EnumWindows(windowenumerator, reinterpret_cast<LPARAM>(&hWnd));
EnumWindows(windowEnumerator, reinterpret_cast<LPARAM>(&hWnd));
}
if (alreadyRunning && (hWnd == nullptr))
Sleep(100);
@ -368,6 +366,8 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
searchDlg.SetMatchesNewline(_wcsicmp(searchIni.GetValue(section.c_str(), L"n"), L"yes") == 0);
if (searchIni.GetValue(section.c_str(), L"k"))
searchDlg.SetCreateBackups(_wcsicmp(searchIni.GetValue(section.c_str(), L"k"), L"yes") == 0);
if (searchIni.GetValue(section.c_str(), L"wholewords"))
searchDlg.SetWholeWords(_wcsicmp(searchIni.GetValue(section.c_str(), L"wholewords"), L"yes") == 0);
if (searchIni.GetValue(section.c_str(), L"utf8"))
searchDlg.SetUTF8(_wcsicmp(searchIni.GetValue(section.c_str(), L"utf8"), L"yes") == 0);
if (searchIni.GetValue(section.c_str(), L"binary"))
@ -458,7 +458,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
if (parser.HasVal(L"n"))
searchDlg.SetMatchesNewline(_wcsicmp(parser.GetVal(L"n"), L"yes")==0);
if (parser.HasVal(L"k"))
searchDlg.SetCreateBackups(_wcsicmp(parser.GetVal(L"k"), L"yes")==0);
searchDlg.SetCreateBackups(_wcsicmp(parser.GetVal(L"k"), L"yes") == 0);
if (parser.HasVal(L"wholewords"))
searchDlg.SetWholeWords(_wcsicmp(parser.GetVal(L"wholewords"), L"yes") == 0);
else if (parser.HasKey(L"wholewords"))
searchDlg.SetWholeWords(true);
if (parser.HasVal(L"utf8"))
searchDlg.SetUTF8(_wcsicmp(parser.GetVal(L"utf8"), L"yes")==0);
if (parser.HasVal(L"binary"))

View File

@ -6,13 +6,13 @@
//#pragma message(__LOC__"Run the NAnt script to get proper version info")
#define FILEVER 2, 1, 7, 37
#define PRODUCTVER 2, 1, 7, 37
#define STRFILEVER "2.1.7.37\0"
#define STRPRODUCTVER "2.1.7.37\0"
#define FILEVER 2, 1, 8, 38
#define PRODUCTVER 2, 1, 8, 38
#define STRFILEVER "2.1.8.38\0"
#define STRPRODUCTVER "2.1.8.38\0"
#define GREPWIN_VERMAJOR 2
#define GREPWIN_VERMINOR 1
#define GREPWIN_VERMICRO 7
#define GREPWIN_VERBUILD 37
#define GREPWIN_VERDATE "2021-05-14"
#define GREPWIN_VERMICRO 8
#define GREPWIN_VERBUILD 38
#define GREPWIN_VERDATE "2021-07-02"

View File

@ -83,11 +83,11 @@
#define IDS_CLONE 170
#define IDS_NEWINSTANCE_TT 171
#define IDS_REPLACEUTF8 172
//#define IDS_INFOLABELSEL 173
#define IDS_INFOLABELSEL 173
#define IDC_SEARCHTEXT 1000
#define IDC_REGEXRADIO 1001
#define IDC_TEXTRADIO 1002
//#define IDC_WHOLEWORDS 1003
#define IDC_WHOLEWORDS 1003
#define IDC_REGEXOKLABEL 1004
#define IDC_ALLSIZERADIO 1005
#define IDC_SIZERADIO 1006

View File

@ -4,7 +4,7 @@
<setenv>
<variable name="MajorVersion" value="2" />
<variable name="MinorVersion" value="0" />
<variable name="MicroVersion" value="7" />
<variable name="MicroVersion" value="8" />
<variable name="WCREV" value="$WCLOGCOUNT$" />
<variable name="WCDATE" value="$WCDATE$" />
</setenv>

View File

@ -1,2 +1,2 @@
2.0.7.1040
2.0.8.1054
https://tools.stefankueng.com/grepWin.html