Merge pull request #2505 from RaiKoHoff/grepWin_Integration

grepWin update current (2020-07-12) version
This commit is contained in:
Rainer Kottenhoff 2020-07-12 16:01:05 +02:00 committed by GitHub
commit 8201471eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 498 additions and 322 deletions

View File

@ -1,6 +1,6 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2017 - Stefan Kueng
// Copyright (C) 2017, 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -21,6 +21,8 @@
#include "AnimationManager.h"
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
/// Object to handle the timer callback.
class CTimerEventHandler : public IUIAnimationTimerEventHandler

View File

@ -1,6 +1,6 @@
// sktoolslib - common files for SK tools
// Copyright (C) 2017 - Stefan Kueng
// Copyright (C) 2017, 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -60,6 +60,7 @@
#include <UIAnimation.h>
#include <functional>
#include <vector>
#include <memory>
#include <comip.h>
#include <comdefsp.h>

View File

@ -38,6 +38,7 @@ CTextFile::CTextFile(void)
, filelen(0)
, hasBOM(false)
, encoding(AUTOTYPE)
, m_NullByteCount(2)
{
}
@ -430,7 +431,7 @@ CTextFile::UnicodeType CTextFile::CheckUnicodeType(BYTE *pBuffer, int cb)
if (0x00 == *pVal8++)
++nNull;
}
if (nDblNull > 2) // arbitrary value: allow two double null chars to account for 'broken' text files
if (nDblNull > m_NullByteCount) // configured value: allow double null chars to account for 'broken' text files
return BINARY;
pVal16 = (UINT16 *)pBuffer;
pVal8 = (UINT8 *)(pVal16 + 1);
@ -438,7 +439,7 @@ CTextFile::UnicodeType CTextFile::CheckUnicodeType(BYTE *pBuffer, int cb)
return UNICODE_LE;
if (*pVal16 == 0xFFFE)
return UNICODE_BE;
if ((nNull > 3) && ((cb % 2) == 0)) // arbitrary value: allow three null chars to account for 'broken' text files
if ((nNull > 3) && ((cb % 2) == 0)) // arbitrary value: allow three null chars to account for 'broken' ANSI/UTF8 text files, otherwise consider the file UTF16-LE
return UNICODE_LE;
if (cb < 3)
return ANSI;

View File

@ -115,6 +115,13 @@ public:
bool HasBOM() const { return hasBOM; }
/**
* Sets the number of null bytes that are allowed for
* a file to still be considered text instead of binary
* in the encoding detection. Default is 2.
*/
void SetNullbyteCountForBinary(int count) { m_NullByteCount = count; }
protected:
/**
* Tries to find out the encoding of the file (utf8, utf16, ansi)
@ -134,4 +141,5 @@ private:
UnicodeType encoding;
std::wstring filename;
bool hasBOM;
int m_NullByteCount;
};

View File

@ -44,14 +44,14 @@ LRESULT CAboutDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
[this]() {
CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
});
m_link.ConvertStaticToHyperlink(hwndDlg, IDC_WEBLINK, L"http://tools.stefankueng.com");
CTheme::Instance().SetThemeForDialog(*this, CTheme::Instance().IsDarkTheme());
InitDialog(hwndDlg, IDI_GREPWIN);
CLanguage::Instance().TranslateWindow(*this);
TCHAR buf[MAX_PATH] = {0};
_stprintf_s(buf, _countof(buf), _T("grepWinNP3 version %ld.%ld.%ld.%ld"), GREPWIN_VERMAJOR, GREPWIN_VERMINOR, GREPWIN_VERMICRO, GREPWIN_VERBUILD);
_stprintf_s(buf, _countof(buf), L"grepWinNP3 version %ld.%ld.%ld.%ld", GREPWIN_VERMAJOR, GREPWIN_VERMINOR, GREPWIN_VERMICRO, GREPWIN_VERBUILD);
SetDlgItemText(*this, IDC_VERSIONINFO, buf);
SetDlgItemText(*this, IDC_DATE, _T(GREPWIN_VERDATE));
m_link.ConvertStaticToHyperlink(hwndDlg, IDC_WEBLINK, _T("http://tools.stefankueng.com"));
SetDlgItemText(*this, IDC_DATE, TEXT(GREPWIN_VERDATE));
}
return TRUE;
case WM_COMMAND:

View File

@ -47,10 +47,10 @@ void CBookmarks::Load()
{
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path.get());
m_iniPath = path.get();
m_iniPath += _T("\\grepWinNP3");
m_iniPath += L"\\grepWinNP3";
}
CreateDirectory(m_iniPath.c_str(), NULL);
m_iniPath += _T("\\bookmarks");
m_iniPath += L"\\bookmarks";
SetUnicode();
SetMultiLine();
SetSpaces(false);
@ -70,62 +70,63 @@ void CBookmarks::Save()
{
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path.get());
m_iniPath = path.get();
m_iniPath += _T("\\grepWinNP3");
m_iniPath += L"\\grepWinNP3";
}
CreateDirectory(m_iniPath.c_str(), NULL);
m_iniPath += _T("\\bookmarks");
m_iniPath += L"\\bookmarks";
SaveFile(m_iniPath.c_str(), true);
}
void CBookmarks::AddBookmark(const Bookmark& bm)
{
std::wstring val = _T("\"");
std::wstring val = L"\"";
val += bm.Search;
val += _T("\"");
SetValue(bm.Name.c_str(), _T("searchString"), val.c_str());
val += L"\"";
SetValue(bm.Name.c_str(), L"searchString", val.c_str());
val = _T("\"");
val = L"\"";
val += bm.Replace;
val += _T("\"");
SetValue(bm.Name.c_str(), _T("replaceString"), val.c_str());
SetValue(bm.Name.c_str(), _T("useregex"), bm.UseRegex ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("casesensitive"), bm.CaseSensitive ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("dotmatchesnewline"), bm.DotMatchesNewline ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("backup"), bm.Backup ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("utf8"), bm.Utf8 ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("includesystem"), bm.IncludeSystem ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("includefolder"), bm.IncludeFolder ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("includehidden"), bm.IncludeHidden ? _T("true") : _T("false"));
SetValue(bm.Name.c_str(), _T("includebinary"), bm.IncludeBinary ? _T("true") : _T("false"));
val = _T("\"");
val += L"\"";
SetValue(bm.Name.c_str(), L"replaceString", val.c_str());
SetValue(bm.Name.c_str(), L"useregex", bm.UseRegex ? L"true" : L"false");
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"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");
SetValue(bm.Name.c_str(), L"includehidden", bm.IncludeHidden ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"includebinary", bm.IncludeBinary ? L"true" : L"false");
val = L"\"";
val += bm.ExcludeDirs;
val += _T("\"");
SetValue(bm.Name.c_str(), _T("excludedirs"), val.c_str());
val = _T("\"");
val += L"\"";
SetValue(bm.Name.c_str(), L"excludedirs", val.c_str());
val = L"\"";
val += bm.FileMatch;
val += _T("\"");
SetValue(bm.Name.c_str(), _T("filematch"), val.c_str());
SetValue(bm.Name.c_str(), _T("filematchregex"), bm.FileMatchRegex ? _T("true") : _T("false"));
val += L"\"";
SetValue(bm.Name.c_str(), L"filematch", val.c_str());
SetValue(bm.Name.c_str(), L"filematchregex", bm.FileMatchRegex ? L"true" : L"false");
SetValue(bm.Name.c_str(), L"searchpath", bm.Path.c_str());
}
void CBookmarks::RemoveBookmark(const std::wstring& name)
{
Delete(name.c_str(), _T("searchString"), true);
Delete(name.c_str(), _T("replaceString"), true);
Delete(name.c_str(), _T("useregex"), true);
Delete(name.c_str(), _T("casesensitive"), true);
Delete(name.c_str(), _T("dotmatchesnewline"), true);
Delete(name.c_str(), _T("backup"), true);
Delete(name.c_str(), _T("utf8"), true);
Delete(name.c_str(), _T("includesystem"), true);
Delete(name.c_str(), _T("includefolder"), true);
Delete(name.c_str(), _T("includehidden"), true);
Delete(name.c_str(), _T("includebinary"), true);
Delete(name.c_str(), _T("excludedirs"), true);
Delete(name.c_str(), _T("filematch"), true);
Delete(name.c_str(), _T("filematchregex"), true);
Delete(name.c_str(), L"searchString", true);
Delete(name.c_str(), L"replaceString", true);
Delete(name.c_str(), L"useregex", true);
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"utf8", true);
Delete(name.c_str(), L"includesystem", true);
Delete(name.c_str(), L"includefolder", true);
Delete(name.c_str(), L"includehidden", true);
Delete(name.c_str(), L"includebinary", true);
Delete(name.c_str(), L"excludedirs", true);
Delete(name.c_str(), L"filematch", true);
Delete(name.c_str(), L"filematchregex", true);
Delete(name.c_str(), L"searchpath", true);
}
Bookmark CBookmarks::GetBookmark( const std::wstring& name )
@ -148,6 +149,7 @@ Bookmark CBookmarks::GetBookmark( const std::wstring& name )
bk.ExcludeDirs = GetValue(name.c_str(), L"excludedirs", L"");
bk.FileMatch = GetValue(name.c_str(), L"filematch", L"");
bk.FileMatchRegex = wcscmp(GetValue(name.c_str(), L"filematchregex", L"false"), L"true") == 0;
bk.Path = GetValue(name.c_str(), L"searchpath", L"");
}
return bk;

View File

@ -1,6 +1,6 @@
// grepWin - regex search and replace for Windows
// Copyright (C) 2007-2008, 2012-2013 - Stefan Kueng
// Copyright (C) 2007-2008, 2012-2013, 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -42,11 +42,13 @@ public:
std::wstring Name;
std::wstring Search;
std::wstring Replace;
std::wstring Path;
bool UseRegex;
bool CaseSensitive;
bool DotMatchesNewline;
bool Backup;
bool Utf8;
bool Binary;
bool IncludeSystem;
bool IncludeFolder;
bool IncludeHidden;

View File

@ -37,6 +37,7 @@ CBookmarksDlg::CBookmarksDlg(HWND hParent)
, m_bDotMatchesNewline(false)
, m_bBackup(false)
, m_bUtf8(false)
, m_bForceBinary(false)
, m_bIncludeSystem(false)
, m_bIncludeFolder(false)
, m_bIncludeHidden(false)
@ -98,7 +99,7 @@ LRESULT CBookmarksDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
}
else
{
if (SHGetValue(HKEY_CURRENT_USER, _T("Software\\grepWinNP3"), _T("windowposBookmarks"), REG_NONE, &wpl, &size) == ERROR_SUCCESS)
if (SHGetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowposBookmarks", REG_NONE, &wpl, &size) == ERROR_SUCCESS)
SetWindowPlacement(*this, &wpl);
else
ShowWindow(*this, SW_SHOW);
@ -197,7 +198,7 @@ LRESULT CBookmarksDlg::DoCommand(int id, int /*msg*/)
}
else
{
SHSetValue(HKEY_CURRENT_USER, _T("Software\\grepWinNP3"), _T("windowposBookmarks"), REG_NONE, &wpl, sizeof(wpl));
SHSetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowposBookmarks", REG_NONE, &wpl, sizeof(wpl));
}
if ((id == IDOK) && (ListView_GetNextItem(GetDlgItem(*this, IDC_BOOKMARKS), -1, LVNI_SELECTED) >= 0))
SendMessage(m_hParent, WM_BOOKMARK, 0, 0);
@ -288,8 +289,8 @@ void CBookmarksDlg::InitBookmarks()
m_bookmarks.GetAllSections(sections);
for (const auto & section : sections)
{
std::wstring searchString = m_bookmarks.GetValue(section.pItem, _T("searchString"), _T(""));
std::wstring replaceString = m_bookmarks.GetValue(section.pItem, _T("replaceString"), _T(""));
std::wstring searchString = m_bookmarks.GetValue(section.pItem, L"searchString", _T(""));
std::wstring replaceString = m_bookmarks.GetValue(section.pItem, L"replaceString", _T(""));
RemoveQuotes(searchString);
RemoveQuotes(replaceString);
@ -351,23 +352,25 @@ void CBookmarksDlg::PrepareSelected()
lv.pszText = buf.get();
lv.cchTextMax = MAX_PATH_NEW;
ListView_GetItem(GetDlgItem(*this, IDC_BOOKMARKS), &lv);
m_searchString = m_bookmarks.GetValue(buf.get(), _T("searchString"), _T(""));
m_replaceString = m_bookmarks.GetValue(buf.get(), _T("replaceString"), _T(""));
m_sExcludeDirs = m_bookmarks.GetValue(buf.get(), _T("excludedirs"), _T(""));
m_sFileMatch = m_bookmarks.GetValue(buf.get(), _T("filematch"), _T(""));
m_searchString = m_bookmarks.GetValue(buf.get(), L"searchString", _T(""));
m_path = m_bookmarks.GetValue(buf.get(), L"searchpath", L"");
m_replaceString = m_bookmarks.GetValue(buf.get(), L"replaceString", _T(""));
m_sExcludeDirs = m_bookmarks.GetValue(buf.get(), L"excludedirs", _T(""));
m_sFileMatch = m_bookmarks.GetValue(buf.get(), L"filematch", _T(""));
RemoveQuotes(m_searchString);
RemoveQuotes(m_replaceString);
RemoveQuotes(m_sExcludeDirs);
RemoveQuotes(m_sFileMatch);
m_bUseRegex = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("useregex"), _T("false")), _T("true")) == 0;
m_bCaseSensitive = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("casesensitive"), _T("false")), _T("true")) == 0;
m_bDotMatchesNewline = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("dotmatchesnewline"), _T("false")), _T("true")) == 0;
m_bBackup = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("backup"), _T("false")), _T("true")) == 0;
m_bUtf8 = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("utf8"), _T("false")), _T("true")) == 0;
m_bIncludeSystem = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("includesystem"), _T("false")), _T("true")) == 0;
m_bIncludeFolder = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("includefolder"), _T("false")), _T("true")) == 0;
m_bIncludeHidden = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("includehidden"), _T("false")), _T("true")) == 0;
m_bIncludeBinary = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("includebinary"), _T("false")), _T("true")) == 0;
m_bFileMatchRegex = _tcscmp(m_bookmarks.GetValue(buf.get(), _T("filematchregex"), _T("false")), _T("true")) == 0;
m_bUseRegex = _tcscmp(m_bookmarks.GetValue(buf.get(), L"useregex", L"false"), L"true") == 0;
m_bCaseSensitive = _tcscmp(m_bookmarks.GetValue(buf.get(), L"casesensitive", L"false"), L"true") == 0;
m_bDotMatchesNewline = _tcscmp(m_bookmarks.GetValue(buf.get(), L"dotmatchesnewline", L"false"), L"true") == 0;
m_bBackup = _tcscmp(m_bookmarks.GetValue(buf.get(), L"backup", L"false"), L"true") == 0;
m_bUtf8 = _tcscmp(m_bookmarks.GetValue(buf.get(), L"utf8", L"false"), L"true") == 0;
m_bForceBinary = _tcscmp(m_bookmarks.GetValue(buf.get(), L"binary", L"false"), L"true") == 0;
m_bIncludeSystem = _tcscmp(m_bookmarks.GetValue(buf.get(), L"includesystem", L"false"), L"true") == 0;
m_bIncludeFolder = _tcscmp(m_bookmarks.GetValue(buf.get(), L"includefolder", L"false"), L"true") == 0;
m_bIncludeHidden = _tcscmp(m_bookmarks.GetValue(buf.get(), L"includehidden", L"false"), L"true") == 0;
m_bIncludeBinary = _tcscmp(m_bookmarks.GetValue(buf.get(), L"includebinary", L"false"), L"true") == 0;
m_bFileMatchRegex = _tcscmp(m_bookmarks.GetValue(buf.get(), L"filematchregex", L"false"), L"true") == 0;
}
}

View File

@ -37,11 +37,13 @@ public:
std::wstring GetName() { return m_name; }
std::wstring GetSelectedSearchString() const { return m_searchString; }
std::wstring GetSelectedReplaceString() const { return m_replaceString; }
std::wstring GetPath() const { return m_path; }
bool GetSelectedUseRegex() const { return m_bUseRegex; }
bool GetSelectedSearchCase() const { return m_bCaseSensitive; }
bool GetSelectedDotMatchNewline() const { return m_bDotMatchesNewline; }
bool GetSelectedBackup() const { return m_bBackup; }
bool GetSelectedTreatAsUtf8() const { return m_bUtf8; }
bool GetSelectedTreatAsBinary() const { return m_bForceBinary; }
bool GetSelectedIncludeSystem() const { return m_bIncludeSystem; }
bool GetSelectedIncludeFolder() const { return m_bIncludeFolder; }
bool GetSelectedIncludeHidden() const { return m_bIncludeHidden; }
@ -63,11 +65,13 @@ private:
std::wstring m_searchString;
std::wstring m_replaceString;
std::wstring m_path;
bool m_bUseRegex;
bool m_bCaseSensitive;
bool m_bDotMatchesNewline;
bool m_bBackup;
bool m_bUtf8;
bool m_bForceBinary;
bool m_bIncludeSystem;
bool m_bIncludeFolder;
bool m_bIncludeHidden;

View File

@ -1,6 +1,6 @@
// grepWin - regex search and replace for Windows
// Copyright (C) 2007-2009, 2011-2014 - Stefan Kueng
// Copyright (C) 2007-2009, 2011-2014, 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -55,7 +55,7 @@ BOOL CInfoDlg::ShowDialog(UINT idAboutHTMLID, HINSTANCE hInstance)
{
//Add the IE Res protocol
std::unique_ptr<TCHAR[]> strResourceURL(new TCHAR[MAX_PATH_NEW]);
_stprintf_s(strResourceURL.get(), MAX_PATH_NEW, _T("res://%s/%u"), lpszModule.get(), idAboutHTMLID);
_stprintf_s(strResourceURL.get(), MAX_PATH_NEW, L"res://%s/%u", lpszModule.get(), idAboutHTMLID);
int iLength = (int)_tcslen(strResourceURL.get());
std::unique_ptr<wchar_t[]> lpWideCharStr(new wchar_t[iLength+1]);
//Attempt to Create the URL Moniker to the specified in the URL String

View File

@ -30,6 +30,7 @@
CNameDlg::CNameDlg(HWND hParent)
: m_hParent(hParent)
, m_themeCallbackId(0)
, m_bIncludePath(false)
{
}
@ -91,8 +92,9 @@ LRESULT CNameDlg::DoCommand(int id, int /*msg*/)
{
case IDOK:
{
auto buf = GetDlgItemText(IDC_NAME);
m_name = buf.get();
auto buf = GetDlgItemText(IDC_NAME);
m_name = buf.get();
m_bIncludePath = IsDlgButtonChecked(*this, IDC_INCLUDEPATH);
}
// fall through
case IDCANCEL:

View File

@ -32,6 +32,7 @@ public:
std::wstring GetName() const { return m_name; }
void SetName(const std::wstring& n) { m_name = n; }
bool IncludePath() const { return m_bIncludePath; }
protected:
LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -40,6 +41,7 @@ protected:
private:
HWND m_hParent;
std::wstring m_name;
bool m_bIncludePath;
int m_themeCallbackId;
CDlgResizer m_resizer;
};

View File

@ -222,7 +222,7 @@ void CRegexTestDlg::DoRegex()
while (boost::regex_search(start, end, whatc, expression, flags))
{
if (!searchresult.empty())
searchresult = searchresult + _T("\r\n----------------------------\r\n");
searchresult = searchresult + L"\r\n----------------------------\r\n";
std::wstring c(whatc[0].first, whatc[0].second);
searchresult = searchresult + c;
// update search position:

View File

@ -58,10 +58,11 @@ BEGIN
LTEXT "Replace with:",IDC_REPLACEWITHLABEL,14,83,64,8
EDITTEXT IDC_REPLACETEXT,83,81,484,12,ES_AUTOHSCROLL
PUSHBUTTON "/",IDC_EDITMULTILINE2,572,81,13,12
CONTROL "Search case-sensitive",IDC_CASE_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,97,89,10
CONTROL "Dot matches newline",IDC_DOTMATCHNEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,97,131,10
CONTROL "Create backup files",IDC_CREATEBACKUP,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,285,97,109,10
CONTROL "Treat files as UTF-8",IDC_UTF8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,458,97,118,10
CONTROL "Search case-sensitive",IDC_CASE_SENSITIVE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,97,90,10
CONTROL "Dot matches newline",IDC_DOTMATCHNEWLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,118,97,100,10
CONTROL "Create backup files",IDC_CREATEBACKUP,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,225,97,100,10
CONTROL "Treat files as UTF-8",IDC_UTF8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,340,97,100,10
CONTROL "Treat files as binary",IDC_BINARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,450,97,82,10
PUSHBUTTON "Test regex",IDC_TESTREGEX,14,109,69,14
PUSHBUTTON "Add to Presets",IDC_ADDTOBOOKMARKS,117,109,76,14
PUSHBUTTON "Presets",IDC_BOOKMARKS,195,109,50,14
@ -122,15 +123,16 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,317,295,77,14
END
IDD_NAME DIALOGEX 0, 0, 186, 65
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
IDD_NAME DIALOGEX 0, 0, 186, 85
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Preset name"
FONT 9, "Segoe UI", 400, 0, 0x1
BEGIN
LTEXT "Enter a name for the regex:",IDC_INFOLABEL,7,7,172,8
EDITTEXT IDC_NAME,7,20,172,14,ES_AUTOHSCROLL
DEFPUSHBUTTON "OK",IDOK,37,44,68,14
PUSHBUTTON "Cancel",IDCANCEL,111,44,68,14
CONTROL "Include search path",IDC_INCLUDEPATH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,38,172,10
DEFPUSHBUTTON "OK",IDOK,37,64,68,14
PUSHBUTTON "Cancel",IDCANCEL,111,64,68,14
END
IDD_BOOKMARKS DIALOGEX 0, 0, 240, 129
@ -167,7 +169,7 @@ BEGIN
CONTROL "",IDC_TEXTCONTENT,"RichEdit20W",WS_VSCROLL | WS_TABSTOP | 0x1084,7,7,303,96
END
IDD_SETTINGS DIALOGEX 0, 0, 317, 209
IDD_SETTINGS DIALOGEX 0, 0, 317, 239
STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "grepWinNP3 Settings"
FONT 9, "Segoe UI", 400, 0, 0x1
@ -181,20 +183,22 @@ BEGIN
LTEXT "This adds a new entry to the context menu named 'Open with Editor'",IDC_STATIC3,13,66,288,16
LTEXT "Language:",IDC_STATIC4,16,92,119,8
COMBOBOX IDC_LANGUAGE,151,90,159,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
CONTROL "Escape key closes grepWinNP3",IDC_ESCKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,106,252,10
LTEXT "Number of NULL bytes per MB allowed for a file to still be considered text instead of binary",IDC_STATIC5,16,108,221,17
EDITTEXT IDC_NUMNULL,261,108,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Escape key closes grepWinNP3",IDC_ESCKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,128,252,10
CONTROL "Create backup files in a separate folder",IDC_BACKUPINFOLDER,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,119,249,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,141,249,10
CONTROL "Don't warn when replacing without creating backups",IDC_NOWARNINGIFNOBACKUP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,131,250,10
DEFPUSHBUTTON "OK",IDOK,204,180,50,13
PUSHBUTTON "Cancel",IDCANCEL,260,180,50,13
CONTROL "Only one instance",IDC_ONLYONE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,143,150,10
CONTROL "Check for updates",IDC_DOUPDATECHECKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED,7,155,150,10
CONTROL "Dark mode",IDC_DARKMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,167,157,10
LTEXT "",IDC_DARKMODEINFO,17,182,180,23,WS_DISABLED
RTEXT "Max # of concurrent worker",IDC_TEXT_NUMOFWORKER,156,156,107,9,0,WS_EX_RIGHT
EDITTEXT IDC_MAXNUMWORKER,271,154,31,13,ES_RIGHT | ES_NUMBER | WS_GROUP,WS_EX_RIGHT
CONTROL "",IDC_SPIN_MAXWORKER,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNLEFT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,271,154,10,13
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,153,250,10
CONTROL "Only one instance",IDC_ONLYONE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,165,150,10
CONTROL "Check for updates",IDC_DOUPDATECHECKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP | WS_DISABLED,7,177,150,10
CONTROL "Dark mode",IDC_DARKMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,189,157,10
LTEXT "",IDC_DARKMODEINFO,17,204,180,23,WS_DISABLED
RTEXT "Max # of concurrent worker",IDC_TEXT_NUMOFWORKER,156,182,107,9,0,WS_EX_RIGHT
EDITTEXT IDC_MAXNUMWORKER,271,180,31,13,ES_RIGHT | ES_NUMBER | WS_GROUP,WS_EX_RIGHT
CONTROL "",IDC_SPIN_MAXWORKER,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNLEFT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_GROUP,271,180,10,13
DEFPUSHBUTTON "OK",IDOK,204,220,50,13
PUSHBUTTON "Cancel",IDCANCEL,260,220,50,13
END
@ -238,7 +242,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 58
BOTTOMMARGIN, 78
END
IDD_BOOKMARKS, DIALOG
@ -273,7 +277,7 @@ BEGIN
VERTGUIDE, 13
VERTGUIDE, 301
TOPMARGIN, 7
BOTTOMMARGIN, 201
BOTTOMMARGIN, 231
END
END
#endif // APSTUDIO_INVOKED
@ -432,6 +436,7 @@ BEGIN
IDS_EXPORTMATCHLINENUMBER "include match line numbers"
IDS_EXPORTMATCHLINECONTENT "include match line text"
IDS_UPDATEAVAILABLE "grepWinNP3 %s is available"
IDS_CAPTURESEARCH "Capture search"
END
#endif // Neutral resources

View File

@ -117,7 +117,11 @@
</tr>
<tr>
<td class="style3">\x{FFFF}</td>
<td class="style4 td-left">Matches the unicode character FFFF</td>
<td class="style4 td-left">Matches the unicode character 0xFFFF. Note: this only works for text files!</td>
</tr>
<tr>
<td class="style3">\xFF</td>
<td class="style4 td-left">Matches the character 0xFF</td>
</tr>
<tr>
<td class="style3">$1..$9</td>

View File

@ -78,7 +78,7 @@
DWORD WINAPI SearchThreadEntry(LPVOID lpParam);
DWORD WINAPI EvaluationThreadEntry(LPVOID lpParam);
UINT CSearchDlg::GREPWIN_STARTUPMSG = RegisterWindowMessage(_T("grepWinNP3_StartupMessage"));
UINT CSearchDlg::GREPWIN_STARTUPMSG = RegisterWindowMessage(L"grepWinNP3_StartupMessage");
std::map<size_t, DWORD> linepositions;
extern ULONGLONG g_startTime;
@ -127,10 +127,13 @@ CSearchDlg::CSearchDlg(HWND hParent)
, m_bConfirmationOnReplace(true)
, m_bUTF8(false)
, m_bUTF8C(false)
, m_bForceBinary(false)
, m_bCaseSensitive(false)
, m_bCaseSensitiveC(false)
, m_bDotMatchesNewline(false)
, m_bDotMatchesNewlineC(false)
, m_bNOTSearch(false)
, m_bCaptureSearch(false)
, m_bSizeC(false)
, m_bAllSize(false)
, m_bReplace(false)
@ -141,23 +144,23 @@ CSearchDlg::CSearchDlg(HWND hParent)
, m_Date1({0})
, m_Date2({0})
, m_bDateLimitC(false)
, m_regUseRegex(_T("Software\\grepWinNP3\\UseRegex"), 1)
, m_regAllSize(_T("Software\\grepWinNP3\\AllSize"))
, m_regSize(_T("Software\\grepWinNP3\\Size"), L"2000")
, m_regSizeCombo(_T("Software\\grepWinNP3\\SizeCombo"), 0)
, m_regIncludeSystem(_T("Software\\grepWinNP3\\IncludeSystem"))
, m_regIncludeHidden(_T("Software\\grepWinNP3\\IncludeHidden"))
, m_regIncludeSubfolders(_T("Software\\grepWinNP3\\IncludeSubfolders"), 1)
, m_regIncludeBinary(_T("Software\\grepWinNP3\\IncludeBinary"), 1)
, m_regCreateBackup(_T("Software\\grepWinNP3\\CreateBackup"))
, m_regUTF8(_T("Software\\grepWinNP3\\UTF8"))
, m_regCaseSensitive(_T("Software\\grepWinNP3\\CaseSensitive"))
, m_regDotMatchesNewline(_T("Software\\grepWinNP3\\DotMatchesNewline"))
, m_regUseRegexForPaths(_T("Software\\grepWinNP3\\UseFileMatchRegex"))
, m_regPattern(_T("Software\\grepWinNP3\\pattern"))
, m_regExcludeDirsPattern(_T("Software\\grepWinNP3\\ExcludeDirsPattern"))
, m_regSearchPath(_T("Software\\grepWinNP3\\searchpath"))
, m_regEditorCmd(_T("Software\\grepWinNP3\\editorcmd"))
, m_regUseRegex(L"Software\\grepWinNP3\\UseRegex", 1)
, m_regAllSize(L"Software\\grepWinNP3\\AllSize")
, m_regSize(L"Software\\grepWinNP3\\Size", L"2000")
, m_regSizeCombo(L"Software\\grepWinNP3\\SizeCombo", 0)
, m_regIncludeSystem(L"Software\\grepWinNP3\\IncludeSystem")
, m_regIncludeHidden(L"Software\\grepWinNP3\\IncludeHidden")
, m_regIncludeSubfolders(L"Software\\grepWinNP3\\IncludeSubfolders", 1)
, m_regIncludeBinary(L"Software\\grepWinNP3\\IncludeBinary", 1)
, m_regCreateBackup(L"Software\\grepWinNP3\\CreateBackup")
, m_regUTF8(L"Software\\grepWinNP3\\UTF8")
, m_regCaseSensitive(L"Software\\grepWinNP3\\CaseSensitive")
, m_regDotMatchesNewline(L"Software\\grepWinNP3\\DotMatchesNewline")
, m_regUseRegexForPaths(L"Software\\grepWinNP3\\UseFileMatchRegex")
, m_regPattern(L"Software\\grepWinNP3\\pattern")
, m_regExcludeDirsPattern(L"Software\\grepWinNP3\\ExcludeDirsPattern")
, m_regSearchPath(L"Software\\grepWinNP3\\searchpath")
, m_regEditorCmd(L"Software\\grepWinNP3\\editorcmd")
, m_regBackupInFolder(L"Software\\grepWinNP3\\backupinfolder", FALSE)
, m_regDateLimit(L"Software\\grepWinNP3\\DateLimit", 0)
, m_regDate1Low(L"Software\\grepWinNP3\\Date1Low", 0)
@ -206,17 +209,19 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
{
SHAutoComplete(GetDlgItem(*this, IDC_SEARCHPATH), SHACF_FILESYSTEM|SHACF_AUTOSUGGEST_FORCE_ON);
m_AutoCompleteFilePatterns.Load(_T("Software\\grepWinNP3\\History"), _T("FilePattern"));
m_AutoCompleteFilePatterns.Load(L"Software\\grepWinNP3\\History", L"FilePattern");
m_AutoCompleteFilePatterns.Init(GetDlgItem(hwndDlg, IDC_PATTERN));
m_AutoCompleteExcludeDirsPatterns.Load(_T("Software\\grepWinNP3\\History"), _T("ExcludeDirsPattern"));
m_AutoCompleteExcludeDirsPatterns.Load(L"Software\\grepWinNP3\\History", L"ExcludeDirsPattern");
m_AutoCompleteExcludeDirsPatterns.Init(GetDlgItem(hwndDlg, IDC_EXCLUDEDIRSPATTERN));
m_AutoCompleteSearchPatterns.Load(_T("Software\\grepWinNP3\\History"), _T("SearchPattern"));
m_AutoCompleteSearchPatterns.Load(L"Software\\grepWinNP3\\History", L"SearchPattern");
m_AutoCompleteSearchPatterns.Init(GetDlgItem(hwndDlg, IDC_SEARCHTEXT));
m_AutoCompleteReplacePatterns.Load(_T("Software\\grepWinNP3\\History"), _T("ReplacePattern"));
m_AutoCompleteReplacePatterns.Load(L"Software\\grepWinNP3\\History", L"ReplacePattern");
m_AutoCompleteReplacePatterns.Init(GetDlgItem(hwndDlg, IDC_REPLACETEXT));
m_AutoCompleteSearchPaths.Load(_T("Software\\grepWinNP3\\History"), _T("SearchPaths"));
m_AutoCompleteSearchPaths.Load(L"Software\\grepWinNP3\\History", L"SearchPaths");
m_AutoCompleteSearchPaths.Init(GetDlgItem(hwndDlg, IDC_SEARCHPATH));
m_link.ConvertStaticToHyperlink(hwndDlg, IDC_ABOUTLINK, L"");
m_themeCallbackId = CTheme::Instance().RegisterThemeChangeCallback(
[this]() {
auto bDark = CTheme::Instance().IsDarkTheme();
@ -363,8 +368,10 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
m_bCreateBackup = bPortable ? g_iniFile.GetBoolValue(L"global", L"CreateBackup", false) : !!DWORD(m_regCreateBackup);
if (!m_bCreateBackupInFoldersC)
m_bCreateBackupInFolders = bPortable ? g_iniFile.GetBoolValue(L"settings", L"backupinfolder", false) : !!DWORD(m_regBackupInFolder);
if (!m_bUTF8C)
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);
}
if (!m_bDotMatchesNewlineC)
m_bDotMatchesNewline = bPortable ? g_iniFile.GetBoolValue(L"global", L"DotMatchesNewline", false) : !!DWORD(m_regDotMatchesNewline);
if (!m_bSizeC)
@ -388,6 +395,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SendDlgItemMessage(hwndDlg, IDC_INCLUDESUBFOLDERS, BM_SETCHECK, m_bIncludeSubfolders ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_CREATEBACKUP, BM_SETCHECK, m_bCreateBackup ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_UTF8, BM_SETCHECK, m_bUTF8 ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_BINARY, BM_SETCHECK, m_bForceBinary ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_INCLUDESYSTEM, BM_SETCHECK, m_bIncludeSystem ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_INCLUDEHIDDEN, BM_SETCHECK, m_bIncludeHidden ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(hwndDlg, IDC_INCLUDEBINARY, BM_SETCHECK, m_bIncludeBinary ? BST_CHECKED : BST_UNCHECKED, 0);
@ -432,8 +440,6 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
SetFocus(GetDlgItem(hwndDlg, IDC_SEARCHTEXT));
m_link.ConvertStaticToHyperlink(hwndDlg, IDC_ABOUTLINK, _T(""));
m_resizer.Init(hwndDlg);
m_resizer.UseSizeGrip(!CTheme::Instance().IsDarkTheme());
m_resizer.AddControl(hwndDlg, IDC_HELPLABEL, RESIZER_TOPLEFT);
@ -455,7 +461,8 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
m_resizer.AddControl(hwndDlg, IDC_DOTMATCHNEWLINE, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_REGEXOKLABEL, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDC_CREATEBACKUP, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_UTF8, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_UTF8, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_BINARY, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_TESTREGEX, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_ADDTOBOOKMARKS, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_BOOKMARKS, RESIZER_TOPLEFT);
@ -528,7 +535,7 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
else
{
if (SHGetValue(HKEY_CURRENT_USER, _T("Software\\grepWinNP3"), _T("windowpos"), REG_NONE, &wpl, &size) == ERROR_SUCCESS)
if (SHGetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowpos", REG_NONE, &wpl, &size) == ERROR_SUCCESS)
SetWindowPlacement(*this, &wpl);
else
ShowWindow(*this, SW_SHOW);
@ -628,8 +635,10 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
{
auto sInverseSearch = TranslatedString(hResource, IDS_INVERSESEARCH);
auto sSearchInFoundFiles = TranslatedString(hResource, IDS_SEARCHINFOUNDFILES);
auto sCaptureSearch = TranslatedString(hResource, IDS_CAPTURESEARCH);
AppendMenu(hSplitMenu, MF_STRING, IDC_INVERSESEARCH, sInverseSearch.c_str());
AppendMenu(hSplitMenu, MF_STRING, IDC_SEARCHINFOUNDFILES, sSearchInFoundFiles.c_str());
AppendMenu(hSplitMenu, m_items.empty() ? MF_STRING | MF_DISABLED : MF_STRING, IDC_SEARCHINFOUNDFILES, sSearchInFoundFiles.c_str());
AppendMenu(hSplitMenu, GetDlgItemTextLength(IDC_REPLACETEXT) ? MF_STRING : MF_STRING | MF_DISABLED, IDC_CAPTURESEARCH, sCaptureSearch.c_str());
}
// Display the menu.
TrackPopupMenu(hSplitMenu, TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, 0, *this, nullptr);
@ -840,44 +849,52 @@ LRESULT CSearchDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
EndDialog(m_hwnd, IDOK);
}
break;
case WM_BOOKMARK:
{
if (m_pBookmarksDlg)
case WM_BOOKMARK:
{
m_searchString = m_pBookmarksDlg->GetSelectedSearchString();
m_replaceString = m_pBookmarksDlg->GetSelectedReplaceString();
m_bUseRegex = m_pBookmarksDlg->GetSelectedUseRegex();
m_bCaseSensitive = m_pBookmarksDlg->GetSelectedSearchCase();
m_bDotMatchesNewline = m_pBookmarksDlg->GetSelectedDotMatchNewline();
m_bCreateBackup = m_pBookmarksDlg->GetSelectedBackup();
m_bUTF8 = m_pBookmarksDlg->GetSelectedTreatAsUtf8();
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)
{
m_searchString = m_pBookmarksDlg->GetSelectedSearchString();
m_replaceString = m_pBookmarksDlg->GetSelectedReplaceString();
m_bUseRegex = m_pBookmarksDlg->GetSelectedUseRegex();
SetDlgItemText(*this, IDC_SEARCHTEXT, m_searchString.c_str());
SetDlgItemText(*this, IDC_REPLACETEXT, m_replaceString.c_str());
CheckRadioButton(*this, IDC_REGEXRADIO, IDC_TEXTRADIO, m_bUseRegex ? IDC_REGEXRADIO : IDC_TEXTRADIO);
DialogEnableWindow(IDC_TESTREGEX, !IsDlgButtonChecked(*this, IDC_TEXTRADIO));
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_searchpath = m_pBookmarksDlg->GetPath();
SetDlgItemText(*this, IDC_SEARCHPATH, m_searchpath.c_str());
}
SendDlgItemMessage(*this, IDC_INCLUDESUBFOLDERS, BM_SETCHECK, m_bIncludeSubfolders ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_CREATEBACKUP, BM_SETCHECK, m_bCreateBackup ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_UTF8, BM_SETCHECK, m_bUTF8 ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_INCLUDESYSTEM, BM_SETCHECK, m_bIncludeSystem ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_INCLUDEHIDDEN, BM_SETCHECK, m_bIncludeHidden ? BST_CHECKED : BST_UNCHECKED, 0);
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);
SetDlgItemText(*this, IDC_SEARCHTEXT, m_searchString.c_str());
SetDlgItemText(*this, IDC_REPLACETEXT, m_replaceString.c_str());
CheckRadioButton(*this, IDC_REGEXRADIO, IDC_TEXTRADIO, m_bUseRegex ? IDC_REGEXRADIO : IDC_TEXTRADIO);
DialogEnableWindow(IDC_TESTREGEX, !IsDlgButtonChecked(*this, IDC_TEXTRADIO));
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());
SendDlgItemMessage(*this, IDC_INCLUDESUBFOLDERS, BM_SETCHECK, m_bIncludeSubfolders ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_CREATEBACKUP, BM_SETCHECK, m_bCreateBackup ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_UTF8, BM_SETCHECK, m_bUTF8 ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_BINARY, BM_SETCHECK, m_bForceBinary ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_INCLUDESYSTEM, BM_SETCHECK, m_bIncludeSystem ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage(*this, IDC_INCLUDEHIDDEN, BM_SETCHECK, m_bIncludeHidden ? BST_CHECKED : BST_UNCHECKED, 0);
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);
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());
}
}
}
break;
default:
return FALSE;
@ -893,6 +910,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
case IDOK:
case IDC_INVERSESEARCH:
case IDC_SEARCHINFOUNDFILES:
case IDC_CAPTURESEARCH:
{
if (IsSearchThreadRunning())
{
@ -974,7 +992,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
auto msgtext = CStringUtils::Format((LPCWSTR)TranslatedString(hResource, IDS_REPLACECONFIRM).c_str(),
m_searchString.c_str(),
m_replaceString.empty() ? (LPCWSTR)TranslatedString(hResource, IDS_ANEMPTYSTRING).c_str() : m_replaceString.c_str());
if (::MessageBox(*this, msgtext.c_str(), _T("grepWinNP3"), MB_ICONQUESTION | MB_YESNO) != IDYES)
if (::MessageBox(*this, msgtext.c_str(), L"grepWinNP3", MB_ICONQUESTION | MB_YESNO) != IDYES)
{
break;
}
@ -987,6 +1005,14 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
else
InterlockedExchange(&s_NOTSearch, ((GetKeyState(VK_SHIFT) & 0x8000) != 0) ? TRUE : FALSE);
m_bNOTSearch = true;
if (id == IDC_CAPTURESEARCH)
{
m_bCaptureSearch = true;
m_bNOTSearch = false;
m_bReplace = false;
}
SetDlgItemText(*this, IDOK, TranslatedString(hResource, IDS_STOP).c_str());
ShowWindow(GetDlgItem(*this, IDC_PROGRESS), SW_SHOW);
@ -1163,7 +1189,7 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
TCHAR compactPath[100] = {0};
PathCompactPathEx(compactPath, buf.get(), 40, 0);
TCHAR titleBuf[MAX_PATH] = {0};
_stprintf_s(titleBuf, _countof(titleBuf), _T("grepWinNP3 : %s"), compactPath);
_stprintf_s(titleBuf, _countof(titleBuf), L"grepWinNP3 : %s", compactPath);
SetWindowText(*this, titleBuf);
}
}
@ -1246,11 +1272,12 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
// add the bookmark
CBookmarks bks;
Bookmark bk;
bk.Name = nameDlg.GetName();
bk.Search = m_searchString;
bk.Replace = m_replaceString;
bk.UseRegex = m_bUseRegex;
bk.CaseSensitive = (IsDlgButtonChecked(*this, IDC_CASE_SENSITIVE) == BST_CHECKED);
bk.Path = nameDlg.IncludePath() ? m_searchpath : L"";
bk.Name = nameDlg.GetName();
bk.Search = m_searchString;
bk.Replace = m_replaceString;
bk.UseRegex = m_bUseRegex;
bk.CaseSensitive = (IsDlgButtonChecked(*this, IDC_CASE_SENSITIVE) == BST_CHECKED);
bk.DotMatchesNewline = (IsDlgButtonChecked(*this, IDC_DOTMATCHNEWLINE) == BST_CHECKED);
bk.Backup = (IsDlgButtonChecked(*this, IDC_CREATEBACKUP) == BST_CHECKED);
bk.Utf8 = (IsDlgButtonChecked(*this, IDC_UTF8) == BST_CHECKED);
@ -1542,6 +1569,18 @@ LRESULT CSearchDlg::DoCommand(int id, int msg)
}
}
break;
case IDC_UTF8:
{
if (IsDlgButtonChecked(*this, IDC_UTF8))
CheckDlgButton(*this, IDC_BINARY, BST_UNCHECKED);
}
break;
case IDC_BINARY:
{
if (IsDlgButtonChecked(*this, IDC_BINARY))
CheckDlgButton(*this, IDC_UTF8, BST_UNCHECKED);
}
break;
}
return 1;
}
@ -1562,7 +1601,7 @@ void CSearchDlg::SaveWndPosition()
}
else
{
SHSetValue(HKEY_CURRENT_USER, _T("Software\\grepWinNP3"), _T("windowpos"), REG_NONE, &wpl, sizeof(wpl));
SHSetValue(HKEY_CURRENT_USER, L"Software\\grepWinNP3", L"windowpos", REG_NONE, &wpl, sizeof(wpl));
}
}
@ -2080,7 +2119,10 @@ void CSearchDlg::DoListNotify(LPNMITEMACTIVATE lpNMItemActivate)
auto len = pInfo->filepath.size() - m_searchpath.size() - filepart.size();
if (len > 0)
--len;
wcsncpy_s(pItem->pszText, pItem->cchTextMax, pInfo->filepath.substr(m_searchpath.size() + 1, len).c_str(), pItem->cchTextMax - 1);
if (m_searchpath.size() < pInfo->filepath.size())
wcsncpy_s(pItem->pszText, pItem->cchTextMax, pInfo->filepath.substr(m_searchpath.size() + 1, len).c_str(), pItem->cchTextMax - 1);
else
wcsncpy_s(pItem->pszText, pItem->cchTextMax, pInfo->filepath.c_str(), pItem->cchTextMax - 1);
}
break;
case 4: // extension of the file
@ -2340,8 +2382,8 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
application = cmdbuf.get();
// resolve parameters
if (application.find(_T("%1")) == std::wstring::npos)
application += _T(" %1");
if (application.find(L"%1") == std::wstring::npos)
application += L" %1";
bool filelist = (IsDlgButtonChecked(*this, IDC_RESULTFILES) == BST_CHECKED);
std::wstring linenumberparam_before;
@ -2372,27 +2414,27 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
// now find out if the application which opens the file is known to us
// and if it has a 'linenumber' switch to jump directly to a specific
// line number.
if (appname.find(_T("notepad++.exe")) != std::wstring::npos)
if (appname.find(L"notepad++.exe") != std::wstring::npos)
{
// notepad++
linenumberparam = CStringUtils::Format(L"-n%s", textlinebuf);
}
else if (appname.find(_T("xemacs.exe")) != std::wstring::npos)
else if (appname.find(L"xemacs.exe") != std::wstring::npos)
{
// XEmacs
linenumberparam = CStringUtils::Format(L"+%s", textlinebuf);
}
else if (appname.find(_T("uedit32.exe")) != std::wstring::npos)
else if (appname.find(L"uedit32.exe") != std::wstring::npos)
{
// UltraEdit
linenumberparam = CStringUtils::Format(L"-l%s", textlinebuf);
}
else if (appname.find(_T("codewright.exe")) != std::wstring::npos)
else if (appname.find(L"codewright.exe") != std::wstring::npos)
{
// CodeWright
linenumberparam = CStringUtils::Format(L"-G%s", textlinebuf);
}
else if (appname.find(_T("notepad2.exe")) != std::wstring::npos)
else if (appname.find(L"notepad2.exe") != std::wstring::npos)
{
// Notepad2
auto escapedsearch = m_searchString;
@ -2420,7 +2462,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
// BowPad
linenumberparam = CStringUtils::Format(L"/line:%s", textlinebuf);
}
else if (appname.find(_T("code.exe")) != std::wstring::npos)
else if (appname.find(L"code.exe") != std::wstring::npos)
{
// Visual Studio Code
linenumberparam_before = L"--goto";
@ -2428,8 +2470,8 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
}
// replace "%1" with %1
std::wstring tag = _T("\"%1\"");
std::wstring repl = _T("%1");
std::wstring tag = L"\"%1\"";
std::wstring repl = L"%1";
std::wstring::iterator it_begin = search(application.begin(), application.end(), tag.begin(), tag.end());
if (it_begin != application.end())
{
@ -2437,9 +2479,9 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
application.replace(it_begin, it_end, repl);
}
// replace %1 with "path/of/selected/file"
tag = _T("%1");
tag = L"%1";
if (application.find(L"rundll32.exe") == std::wstring::npos)
repl = _T("\"") + inf.filepath + _T("\"");
repl = L"\"" + inf.filepath + L"\"";
else
repl = inf.filepath;
if (!linenumberparam_before.empty())
@ -2456,7 +2498,7 @@ void CSearchDlg::OpenFileAtListIndex(int listIndex)
{
if (!linenumberparam.starts_with(L":"))
{
application += _T(" ");
application += L" ";
}
application += linenumberparam;
}
@ -2512,7 +2554,7 @@ bool CSearchDlg::SaveSettings()
m_patterns.clear();
do
{
pos = _tcscspn(pBuf, _T("|"));
pos = _tcscspn(pBuf, L"|");
std::wstring s = std::wstring(pBuf, pos);
if (!s.empty())
{
@ -2596,10 +2638,11 @@ bool CSearchDlg::SaveSettings()
m_bIncludeSystem = (IsDlgButtonChecked(*this, IDC_INCLUDESYSTEM) == BST_CHECKED);
m_bIncludeHidden = (IsDlgButtonChecked(*this, IDC_INCLUDEHIDDEN) == BST_CHECKED);
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_bUTF8 = (IsDlgButtonChecked(*this, IDC_UTF8) == BST_CHECKED);
m_bCaseSensitive = (IsDlgButtonChecked(*this, IDC_CASE_SENSITIVE) == BST_CHECKED);
m_bIncludeBinary = (IsDlgButtonChecked(*this, IDC_INCLUDEBINARY) == BST_CHECKED);
m_bCreateBackup = (IsDlgButtonChecked(*this, IDC_CREATEBACKUP) == 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);
m_bDotMatchesNewline = (IsDlgButtonChecked(*this, IDC_DOTMATCHNEWLINE) == BST_CHECKED);
m_DateLimit = 0;
@ -2628,6 +2671,7 @@ bool CSearchDlg::SaveSettings()
g_iniFile.SetBoolValue(L"global", L"IncludeBinary", m_bIncludeBinary);
g_iniFile.SetBoolValue(L"global", L"CreateBackup", m_bCreateBackup);
g_iniFile.SetBoolValue(L"global", L"UTF8", m_bUTF8);
g_iniFile.SetBoolValue(L"global", L"Binary", m_bForceBinary);
g_iniFile.SetBoolValue(L"global", L"CaseSensitive", m_bCaseSensitive);
g_iniFile.SetBoolValue(L"global", L"DotMatchesNewline", m_bDotMatchesNewline);
g_iniFile.SetValue(L"global", L"pattern", m_patternregex.c_str());
@ -2648,6 +2692,7 @@ bool CSearchDlg::SaveSettings()
m_regIncludeBinary = (DWORD)m_bIncludeBinary;
m_regCreateBackup = (DWORD)m_bCreateBackup;
m_regUTF8 = (DWORD)m_bUTF8;
m_regBinary = (DWORD)m_bForceBinary;
m_regCaseSensitive = (DWORD)m_bCaseSensitive;
m_regDotMatchesNewline = (DWORD)m_bDotMatchesNewline;
m_regPattern = m_patternregex;
@ -2799,7 +2844,7 @@ DWORD CSearchDlg::SearchThread()
std::vector<std::wstring> pathvector;
do
{
pos = _tcscspn(pBufSearchPath, _T("|"));
pos = _tcscspn(pBufSearchPath, L"|");
std::wstring s = std::wstring(pBufSearchPath, pos);
if (!s.empty())
{
@ -2960,13 +3005,15 @@ DWORD CSearchDlg::SearchThread()
SearchFlags_t searchFlags = {
bAlwaysSearch,
m_bUTF8,
m_bForceBinary,
m_bIncludeBinary,
m_bUseRegex,
m_bCaseSensitive,
m_bDotMatchesNewline,
m_bCreateBackup,
m_bCreateBackupInFolders,
m_bReplace
m_bReplace,
m_bCaptureSearch
};
if (nOfWorker > 1)
@ -3144,6 +3191,7 @@ void CSearchDlg::SetPreset(const std::wstring& preset)
m_bDotMatchesNewline = bk.DotMatchesNewline;
m_bCreateBackup = bk.Backup;
m_bUTF8 = bk.Utf8;
m_bForceBinary = bk.Binary;
m_bIncludeSystem = bk.IncludeSystem;
m_bIncludeSubfolders = bk.IncludeFolder;
m_bIncludeHidden = bk.IncludeHidden;
@ -3151,6 +3199,8 @@ void CSearchDlg::SetPreset(const std::wstring& preset)
m_excludedirspatternregex = bk.ExcludeDirs;
m_patternregex = bk.FileMatch;
m_bUseRegexForPaths = bk.FileMatchRegex;
if (!bk.Path.empty())
m_searchpath = bk.Path;
m_bIncludeSystemC = true;
m_bIncludeHiddenC = true;
@ -3231,7 +3281,7 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
if (!searchFlags.bUseRegex)
{
SearchReplace(localSearchString, L"\\E", L"\\\\E");
localSearchString = _T("\\Q") + localSearchString + _T("\\E");
localSearchString = L"\\Q" + localSearchString + L"\\E";
}
SearchReplace(localSearchString, L"${filepath}", sinfoPtr->filepath);
@ -3249,11 +3299,23 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
}
CTextFile textfile;
CTextFile::UnicodeType type = CTextFile::AUTOTYPE;
bool bLoadResult = false;
CTextFile::UnicodeType type = CTextFile::AUTOTYPE;
bool bLoadResult = false;
if (searchFlags.bForceBinary)
{
type = CTextFile::BINARY;
}
else
{
ProfileTimer profile((L"file load and parse: " + sinfoPtr->filepath).c_str());
bLoadResult = textfile.Load(sinfoPtr->filepath.c_str(), type, searchFlags.bUTF8, &s_Cancelled);
auto nNullCount = bPortable ? _wtoi(g_iniFile.GetValue(L"settings", L"nullbytes", L"0")) : int(DWORD(CRegStdDWORD(L"Software\\grepWin\\nullbytes", 0)));
if (nNullCount > 0)
{
constexpr __int64 oneMB = 1024 * 1024;
auto megs = sinfoPtr->filesize / oneMB;
textfile.SetNullbyteCountForBinary(nNullCount * ((int)megs + 1));
}
bLoadResult = textfile.Load(sinfoPtr->filepath.c_str(), type, searchFlags.bUTF8, nullptr);
}
sinfoPtr->encoding = type;
if ((bLoadResult) && ((type != CTextFile::BINARY) || (searchFlags.bIncludeBinary) || searchFlags.bSearchAlways))
@ -3289,7 +3351,13 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
for (long l = linestart; l <= lineend; ++l)
{
auto sLine = textfile.GetLineString(l);
sinfoPtr->matchlines.push_back(sLine.substr(0, 1024));
if (searchFlags.bCaptureSearch)
{
auto out = whatc.format(replaceString, flags);
sinfoPtr->matchlines.push_back(out);
}
else
sinfoPtr->matchlines.push_back(sLine.substr(0, 1024));
sinfoPtr->matchlinesnumbers.push_back(l);
}
}
@ -3322,13 +3390,22 @@ int CSearchDlg::SearchFile(std::shared_ptr<CSearchInfo> sinfoPtr, const std::wst
if (IsNOTSearch())
break;
long linestart = textfile.LineFromPosition(long(whatc[0].first - textfile.GetFileString().begin()));
long lineend = textfile.LineFromPosition(long(whatc[0].second - textfile.GetFileString().begin()));
if ((linestart != prevlinestart) || (lineend != prevlineend))
long lineend = textfile.LineFromPosition(long(whatc[0].second - textfile.GetFileString().begin()));
if (searchFlags.bCaptureSearch)
{
for (long l = linestart; l <= lineend; ++l)
auto out = whatc.format(replaceString, flags);
sinfoPtr->matchlines.push_back(out);
sinfoPtr->matchlinesnumbers.push_back(linestart);
}
else
{
if ((linestart != prevlinestart) || (lineend != prevlineend))
{
sinfoPtr->matchlines.push_back(textfile.GetLineString(l));
sinfoPtr->matchlinesnumbers.push_back(l);
for (long l = linestart; l <= lineend; ++l)
{
sinfoPtr->matchlines.push_back(textfile.GetLineString(l));
sinfoPtr->matchlinesnumbers.push_back(l);
}
}
}
++sinfoPtr->matchcount;
@ -3658,7 +3735,7 @@ void CSearchDlg::formatDate(TCHAR date_native[], const FILETIME& filetime, bool
GetDateFormat(locale, flags, &localsystime, nullptr, datebuf, GREPWIN_DATEBUFFER);
GetTimeFormat(locale, 0, &localsystime, nullptr, timebuf, GREPWIN_DATEBUFFER);
_tcsncat_s(date_native, GREPWIN_DATEBUFFER, datebuf, GREPWIN_DATEBUFFER);
_tcsncat_s(date_native, GREPWIN_DATEBUFFER, _T(" "), GREPWIN_DATEBUFFER);
_tcsncat_s(date_native, GREPWIN_DATEBUFFER, L" ", GREPWIN_DATEBUFFER);
_tcsncat_s(date_native, GREPWIN_DATEBUFFER, timebuf, GREPWIN_DATEBUFFER);
}
@ -3707,7 +3784,7 @@ int CSearchDlg::CheckRegex()
}
else
{
SetDlgItemText(*this, IDC_REGEXOKLABEL, _T(""));
SetDlgItemText(*this, IDC_REGEXOKLABEL, L"");
DialogEnableWindow(IDOK, true);
DialogEnableWindow(IDC_REPLACE, false);
DialogEnableWindow(IDC_CREATEBACKUP, false);
@ -3716,7 +3793,7 @@ int CSearchDlg::CheckRegex()
else
{
m_bUseRegex = false;
SetDlgItemText(*this, IDC_REGEXOKLABEL, _T(""));
SetDlgItemText(*this, IDC_REGEXOKLABEL, L"");
DialogEnableWindow(IDOK, true);
DialogEnableWindow(IDC_REPLACE, len>0);
DialogEnableWindow(IDC_CREATEBACKUP, len>0);

View File

@ -54,6 +54,7 @@ typedef struct _SearchFlags_t
{
bool bSearchAlways;
bool bUTF8;
bool bForceBinary;
bool bIncludeBinary;
bool bUseRegex;
bool bCaseSensitive;
@ -61,6 +62,7 @@ typedef struct _SearchFlags_t
bool bCreateBackup;
bool bBackupInFolder;
bool bReplace;
bool bCaptureSearch;
} SearchFlags_t;
@ -88,7 +90,8 @@ public:
void SetMatchesNewline(bool bSet) {m_bDotMatchesNewlineC = true; m_bDotMatchesNewline = bSet;}
void SetCreateBackups(bool bSet) { m_bCreateBackupC = true; m_bCreateBackup = bSet; m_bConfirmationOnReplace = false; }
void SetCreateBackupsInFolders(bool bSet) { m_bCreateBackupInFoldersC = true; m_bCreateBackupInFolders = bSet; SetCreateBackups(bSet); }
void SetUTF8(bool bSet) {m_bUTF8C = true;m_bUTF8 = bSet;}
void SetUTF8(bool bSet) { m_bUTF8C = true; m_bUTF8 = bSet; m_bForceBinary = false; }
void SetBinary(bool bSet) { m_bUTF8C = true; m_bForceBinary = bSet; m_bUTF8 = false; }
void SetSize(uint64_t size, int cmp) {m_bSizeC = true; m_lSize = size; m_sizeCmp = cmp; m_bAllSize = (size == (uint64_t)-1);}
void SetIncludeSystem(bool bSet) {m_bIncludeSystemC = true; m_bIncludeSystem = bSet;}
void SetIncludeHidden(bool bSet) {m_bIncludeHiddenC = true; m_bIncludeHidden = bSet;}
@ -173,10 +176,13 @@ private:
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;
@ -233,6 +239,7 @@ private:
CRegStdDWORD m_regIncludeBinary;
CRegStdDWORD m_regCreateBackup;
CRegStdDWORD m_regUTF8;
CRegStdDWORD m_regBinary;
CRegStdDWORD m_regCaseSensitive;
CRegStdDWORD m_regDotMatchesNewline;
CRegStdDWORD m_regUseRegexForPaths;

View File

@ -189,6 +189,7 @@ LRESULT CSettingsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
#endif
SendDlgItemMessage(hwndDlg, IDC_DARKMODE, BM_SETCHECK, CTheme::Instance().IsDarkTheme() ? BST_CHECKED : BST_UNCHECKED, 0);
EnableWindow(GetDlgItem(*this, IDC_DARKMODE), CTheme::Instance().IsDarkModeAllowed());
SetDlgItemText(*this, IDC_NUMNULL, bPortable ? g_iniFile.GetValue(L"settings", L"nullbytes", L"0") : std::to_wstring(DWORD(CRegStdDWORD(L"Software\\grepWin\\nullbytes", 0))).c_str());
DWORD const nMaxWorker = std::thread::hardware_concurrency() << 2;
SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXWORKER, UDM_SETRANGE, 0, MAKELPARAM(nMaxWorker, 1));
@ -210,6 +211,7 @@ LRESULT CSettingsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
m_resizer.AddControl(hwndDlg, IDC_STATIC2, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_STATIC3, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_STATIC4, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_NUMNULL, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDC_LANGUAGE, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDC_ESCKEY, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_BACKUPINFOLDER, RESIZER_TOPLEFTRIGHT);
@ -220,11 +222,11 @@ LRESULT CSettingsDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
#endif
m_resizer.AddControl(hwndDlg, IDC_DARKMODE, RESIZER_TOPLEFT);
m_resizer.AddControl(hwndDlg, IDC_DARKMODEINFO, RESIZER_TOPLEFTRIGHT);
m_resizer.AddControl(hwndDlg, IDC_TEXT_NUMOFWORKER, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDC_MAXNUMWORKER, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDC_SPIN_MAXWORKER, RESIZER_TOPRIGHT);
m_resizer.AddControl(hwndDlg, IDOK, RESIZER_BOTTOMRIGHT);
m_resizer.AddControl(hwndDlg, IDCANCEL, RESIZER_BOTTOMRIGHT);
m_resizer.AddControl(hwndDlg, IDC_TEXT_NUMOFWORKER, RESIZER_BOTTOMRIGHT);
m_resizer.AddControl(hwndDlg, IDC_MAXNUMWORKER, RESIZER_BOTTOMRIGHT);
m_resizer.AddControl(hwndDlg, IDC_SPIN_MAXWORKER, RESIZER_BOTTOMRIGHT);
}
return TRUE;
case WM_COMMAND:
@ -301,6 +303,7 @@ LRESULT CSettingsDlg::DoCommand(int id, int /*msg*/)
wchar_t worker[32];
SendDlgItemMessage(*this, IDC_MAXNUMWORKER, WM_GETTEXT, (LPARAM)32, (WPARAM)worker);
long const nWorker = _wtol((wchar_t*)worker);
std::wstring sNumNull = GetDlgItemText(IDC_NUMNULL).get();
if (bPortable)
{
@ -311,6 +314,7 @@ LRESULT CSettingsDlg::DoCommand(int id, int /*msg*/)
#ifdef NP3_ALLOW_UPDATE
g_iniFile.SetBoolValue(L"global", L"CheckForUpdates", (IsDlgButtonChecked(*this, IDC_DOUPDATECHECKS) == BST_CHECKED));
#endif
g_iniFile.SetValue(L"settings", L"nullbytes", sNumNull.c_str());
g_iniFile.SetLongValue(L"global", L"MaxNumOfWorker", nWorker);
}
else
@ -327,8 +331,10 @@ LRESULT CSettingsDlg::DoCommand(int id, int /*msg*/)
CRegStdDWORD regCheckForUpdates(L"Software\\grepWinNP3\\CheckForUpdates", FALSE);
regCheckForUpdates = (IsDlgButtonChecked(*this, IDC_DOUPDATECHECKS) == BST_CHECKED);
#endif
CRegStdDWORD nwrk(L"Software\\grepWinNP3\\MaxNumOfWorker", 1);
nwrk = nWorker;
CRegStdDWORD regNumNull(L"Software\\grepWinNP3\\nullbytes", FALSE);
regNumNull = _wtoi(sNumNull.c_str());
CRegStdDWORD regNumWorker(L"Software\\grepWinNP3\\MaxNumOfWorker", 1);
regNumWorker = nWorker;
}
CTheme::Instance().SetDarkTheme(IsDlgButtonChecked(*this, IDC_DARKMODE) == BST_CHECKED);
}

View File

@ -1,6 +1,6 @@
// grepWin - regex search and replace for Windows
// Copyright (C) 2007-2015, 2017 - Stefan Kueng
// Copyright (C) 2007-2015, 2017, 2020 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@ -272,15 +272,15 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
case 1:
{
// This is the command line for explorer which tells it to select the given file
std::wstring sFolder = _T( "/Select,\"" ) + m_strVector[0].filepath + _T("\"");
std::wstring sFolder = L"/Select,\"" + m_strVector[0].filepath + L"\"";
// Prepare shell execution params
SHELLEXECUTEINFO shExecInfo = { 0 };
shExecInfo.cbSize = sizeof(shExecInfo);
shExecInfo.lpFile = _T("explorer.exe");
shExecInfo.lpFile = L"explorer.exe";
shExecInfo.lpParameters = sFolder.c_str();
shExecInfo.nShow = SW_SHOWNORMAL;
shExecInfo.lpVerb = _T("open"); // Context menu item
shExecInfo.lpVerb = L"open"; // Context menu item
shExecInfo.fMask = SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_DDEWAIT | SEE_MASK_FLAG_NO_UI;
// Select file in explorer
@ -293,7 +293,7 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
for (auto it = m_strVector.begin(); it != m_strVector.end(); ++it)
{
if (!pathnames.empty())
pathnames += _T("\r\n");
pathnames += L"\r\n";
pathnames += it->filepath;
}
WriteAsciiStringToClipboard(pathnames.c_str(), hWnd);
@ -305,7 +305,7 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
for (auto it = m_strVector.begin(); it != m_strVector.end(); ++it)
{
if (!pathnames.empty())
pathnames += _T("\r\n");
pathnames += L"\r\n";
std::wstring p = it->filepath;
p = p.substr(p.find_last_of('\\')+1);
pathnames += p;
@ -319,7 +319,7 @@ UINT CShellContextMenu::ShowContextMenu(HWND hWnd, POINT pt)
for (auto it = m_lineVector.begin(); it != m_lineVector.end(); ++it)
{
if (!lines.empty())
lines += _T("\r\n");
lines += L"\r\n";
for (auto it2 = it->lines.cbegin(); it2 != it->lines.cend(); ++it2)
{
std::wstring l = it2->text;

View File

@ -38,7 +38,7 @@ CSimpleIni g_iniFile;
HANDLE hInitProtection = nullptr;
ULONGLONG g_startTime = GetTickCount64();
UINT GREPWIN_STARTUPMSG = RegisterWindowMessage(_T("grepWinNP3_StartupMessage"));
UINT GREPWIN_STARTUPMSG = RegisterWindowMessage(L"grepWinNP3_StartupMessage");
static std::wstring SanitizeSearchPaths(const std::wstring& searchpath)
{
@ -167,7 +167,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
icex.dwICC = ICC_LINK_CLASS | ICC_LISTVIEW_CLASSES | ICC_PAGESCROLLER_CLASS | ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES | ICC_TAB_CLASSES | ICC_TREEVIEW_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES | ICC_WIN95_CLASSES;
InitCommonControlsEx(&icex);
HMODULE hRichEdt = LoadLibrary(_T("Riched20.dll"));
HMODULE hRichEdt = LoadLibrary(L"Riched20.dll");
CCmdLineParser parser(lpCmdLine);
@ -218,9 +218,9 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
} while ((hWnd == nullptr) && alreadyRunning && timeout);
}
auto modulename = CPathUtils::GetFileName(CPathUtils::GetModulePath(nullptr));
bPortable = ((_tcsstr(modulename.c_str(), _T("portable"))) ||
(_tcsstr(modulename.c_str(), _T("NP3"))) ||
(parser.HasKey(_T("portable"))));
bPortable = ((_tcsstr(modulename.c_str(), L"portable")) ||
(_tcsstr(modulename.c_str(), L"NP3")) ||
(parser.HasKey(L"portable")));
std::wstring iniPath = CPathUtils::GetModuleDir(nullptr);
iniPath += L"\\grepWinNP3.ini";
@ -246,7 +246,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
if (hWnd)
{
bool bOnlyOne = bPortable ? g_iniFile.GetBoolValue(L"global", L"onlyone", L"false") :
!!DWORD(CRegStdDWORD(_T("Software\\grepWinNP3\\onlyone"), 0));
!!DWORD(CRegStdDWORD(L"Software\\grepWinNP3\\onlyone", 0));
if (SendMessage(hWnd, GREPWIN_STARTUPMSG, 1, 0)) // check if grepWin was started moments ago
{
@ -254,11 +254,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
// grepWin was started just moments ago:
// add the new path to the existing search path in that grepWin instance
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(_T("searchpath")) :
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(L"searchpath") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchpath", L"") : L"");
SearchReplace(spath, L"/", L"\\");
spath = SanitizeSearchPaths(spath);
std::wstring searchfor = parser.HasVal(_T("searchfor")) ? parser.GetVal(_T("searchfor")) :
std::wstring searchfor = parser.HasVal(L"searchfor") ? parser.GetVal(L"searchfor") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchfor", L"") : L"");
COPYDATASTRUCT CopyData = {0};
CopyData.lpData = (LPVOID)spath.c_str();
@ -271,11 +271,11 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
}
else if (bOnlyOne)
{
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(_T("searchpath")) :
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(L"searchpath") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchpath", L"") : L"");
SearchReplace(spath, L"/", L"\\");
spath = SanitizeSearchPaths(spath);
std::wstring searchfor = parser.HasVal(_T("searchfor")) ? parser.GetVal(_T("searchfor")) :
std::wstring searchfor = parser.HasVal(L"searchfor") ? parser.GetVal(L"searchfor") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchfor", L"") : L"");
COPYDATASTRUCT CopyData = {0};
CopyData.lpData = (LPVOID)spath.c_str();
@ -315,7 +315,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
else
CLanguage::Instance().LoadFile(std::wstring(CRegStdString(L"Software\\grepWinNP3\\languagefile")));
if (parser.HasKey(_T("about"))||parser.HasKey(_T("?"))||parser.HasKey(_T("help")))
if (parser.HasKey(L"about")||parser.HasKey(_T("?"))||parser.HasKey(L"help"))
{
if (hInitProtection)
CloseHandle(hInitProtection);
@ -326,55 +326,57 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
{
CSearchDlg searchDlg(nullptr);
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(_T("searchpath")) :
std::wstring spath = parser.HasVal(L"searchpath") ? parser.GetVal(L"searchpath") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchpath", L"") : L"");
SearchReplace(spath, L"/", L"\\");
spath = SanitizeSearchPaths(spath);
searchDlg.SetSearchPath(spath);
std::wstring searchfor = parser.HasVal(_T("searchfor")) ? parser.GetVal(_T("searchfor")) :
std::wstring searchfor = parser.HasVal(L"searchfor") ? parser.GetVal(L"searchfor") :
(bPortable ? g_iniFile.GetValue(L"global", L"searchfor", L"") : L"");
searchDlg.SetSearchString(searchfor);
if (parser.HasVal(_T("filemaskregex")))
searchDlg.SetFileMask(parser.GetVal(_T("filemaskregex")), true);
if (parser.HasVal(_T("filemask")))
searchDlg.SetFileMask(parser.GetVal(_T("filemask")), false);
if (parser.HasVal(_T("direxcluderegex")))
searchDlg.SetDirExcludeRegexMask(parser.GetVal(_T("direxcluderegex")));
else if (parser.HasVal(_T("filemaskexclude")))
searchDlg.SetDirExcludeRegexMask(parser.GetVal(_T("filemaskexclude")));
if (parser.HasVal(_T("replacewith")))
searchDlg.SetReplaceWith(parser.GetVal(_T("replacewith")));
if (parser.HasVal(_T("preset")))
searchDlg.SetPreset(parser.GetVal(_T("preset")));
if (parser.HasVal(L"filemaskregex"))
searchDlg.SetFileMask(parser.GetVal(L"filemaskregex"), true);
if (parser.HasVal(L"filemask"))
searchDlg.SetFileMask(parser.GetVal(L"filemask"), false);
if (parser.HasVal(L"direxcluderegex"))
searchDlg.SetDirExcludeRegexMask(parser.GetVal(L"direxcluderegex"));
else if (parser.HasVal(L"filemaskexclude"))
searchDlg.SetDirExcludeRegexMask(parser.GetVal(L"filemaskexclude"));
if (parser.HasVal(L"replacewith"))
searchDlg.SetReplaceWith(parser.GetVal(L"replacewith"));
if (parser.HasVal(L"preset"))
searchDlg.SetPreset(parser.GetVal(L"preset"));
if (parser.HasVal(_T("i")))
searchDlg.SetCaseSensitive(_tcsicmp(parser.GetVal(_T("i")), _T("yes"))!=0);
if (parser.HasVal(_T("n")))
searchDlg.SetMatchesNewline(_tcsicmp(parser.GetVal(_T("n")), _T("yes"))==0);
if (parser.HasVal(_T("k")))
searchDlg.SetCreateBackups(_tcsicmp(parser.GetVal(_T("k")), _T("yes"))==0);
if (parser.HasVal(_T("utf8")))
searchDlg.SetUTF8(_tcsicmp(parser.GetVal(_T("utf8")), _T("yes"))==0);
if (parser.HasVal(_T("size")))
if (parser.HasVal(L"i"))
searchDlg.SetCaseSensitive(_tcsicmp(parser.GetVal(L"i"), L"yes")!=0);
if (parser.HasVal(L"n"))
searchDlg.SetMatchesNewline(_tcsicmp(parser.GetVal(L"n"), L"yes")==0);
if (parser.HasVal(L"k"))
searchDlg.SetCreateBackups(_tcsicmp(parser.GetVal(L"k"), L"yes")==0);
if (parser.HasVal(L"utf8"))
searchDlg.SetUTF8(_tcsicmp(parser.GetVal(L"utf8"), L"yes")==0);
if (parser.HasVal(L"binary"))
searchDlg.SetBinary(_tcsicmp(parser.GetVal(L"binary"), L"yes") == 0);
if (parser.HasVal(L"size"))
{
int cmp = 0;
if (parser.HasVal(_T("sizecmp")))
cmp = parser.GetLongVal(_T("sizecmp"));
searchDlg.SetSize(parser.GetLongVal(_T("size")), cmp);
if (parser.HasVal(L"sizecmp"))
cmp = parser.GetLongVal(L"sizecmp");
searchDlg.SetSize(parser.GetLongVal(L"size"), cmp);
}
if (parser.HasVal(_T("s")))
searchDlg.SetIncludeSystem(_tcsicmp(parser.GetVal(_T("s")), _T("yes"))==0);
if (parser.HasVal(_T("h")))
searchDlg.SetIncludeHidden(_tcsicmp(parser.GetVal(_T("h")), _T("yes"))==0);
if (parser.HasVal(_T("u")))
searchDlg.SetIncludeSubfolders(_tcsicmp(parser.GetVal(_T("u")), _T("yes"))==0);
if (parser.HasVal(_T("b")))
searchDlg.SetIncludeBinary(_tcsicmp(parser.GetVal(_T("b")), _T("yes"))==0);
if (parser.HasVal(_T("regex")))
searchDlg.SetUseRegex(_tcsicmp(parser.GetVal(_T("regex")), _T("yes")) == 0);
else if(parser.HasVal(_T("searchfor")))
if (parser.HasVal(L"s"))
searchDlg.SetIncludeSystem(_tcsicmp(parser.GetVal(L"s"), L"yes")==0);
if (parser.HasVal(L"h"))
searchDlg.SetIncludeHidden(_tcsicmp(parser.GetVal(L"h"), L"yes")==0);
if (parser.HasVal(L"u"))
searchDlg.SetIncludeSubfolders(_tcsicmp(parser.GetVal(L"u"), L"yes")==0);
if (parser.HasVal(L"b"))
searchDlg.SetIncludeBinary(_tcsicmp(parser.GetVal(L"b"), L"yes")==0);
if (parser.HasVal(L"regex"))
searchDlg.SetUseRegex(_tcsicmp(parser.GetVal(L"regex"), L"yes") == 0);
else if(parser.HasVal(L"searchfor"))
searchDlg.SetUseRegex(true);
if (parser.HasKey(L"execute") || parser.HasKey(L"executesearch"))

View File

@ -6,13 +6,13 @@
//#pragma message(__LOC__"Run the NAnt script to get proper version info")
#define FILEVER 2, 1, 2, 16
#define PRODUCTVER 2, 1, 2, 16
#define STRFILEVER "2.1.2.16\0"
#define STRPRODUCTVER "2.1.2.16\0"
#define FILEVER 2, 1, 2, 17
#define PRODUCTVER 2, 1, 2, 17
#define STRFILEVER "2.1.2.17\0"
#define STRPRODUCTVER "2.1.2.17\0"
#define GREPWIN_VERMAJOR 2
#define GREPWIN_VERMINOR 1
#define GREPWIN_VERMICRO 2
#define GREPWIN_VERBUILD 16
#define GREPWIN_VERDATE "2020-07-02"
#define GREPWIN_VERBUILD 17
#define GREPWIN_VERDATE "2020-07-12"

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by D:\_projects\_github\Notepad3\grepWinNP3\src\Resources\grepWin.rc
// Used by Notepad3\grepWinNP3\src\Resources\grepWin.rc
// encoding: CP-1252
#define IDS_APP_TITLE 103
#define IDS_NAME 104
@ -79,6 +79,7 @@
#define IDS_EXPORTMATCHLINENUMBER 166
#define IDS_EXPORTMATCHLINECONTENT 167
#define IDS_UPDATEAVAILABLE 168
#define IDS_CAPTURESEARCH 169
#define IDC_SEARCHTEXT 1000
#define IDC_REGEXRADIO 1001
#define IDC_TEXTRADIO 1002
@ -125,7 +126,8 @@
#define IDC_DOTMATCHNEWLINE 1051
#define IDC_ABOUTLINK 1052
#define IDC_UTF8 1053
#define IDC_RESETDEFAULT 1054
#define IDC_UTF9 1054
#define IDC_BINARY 1054
#define IDC_INFOLABEL 1056
#define IDC_RESULTFILES 1059
#define IDC_RADIO2 1060
@ -135,6 +137,7 @@
#define IDC_EDITMULTILINE1 1061
#define IDC_CHECK1 1062
#define IDC_ESCKEY 1062
#define IDC_INCLUDEPATH 1062
#define IDC_EDITMULTILINE2 1063
#define IDC_ONLYONE 1063
#define IDC_PATHMRU 1064
@ -154,36 +157,43 @@
#define IDC_DWM 1076
#define IDC_BACKUPINFOLDER 1077
#define IDC_RADIO_DATE_ALL 1078
#define IDC_BACKUPINFOLDER2 1078
#define IDC_NOWARNINGIFNOBACKUP 1078
#define IDC_RADIO_DATE_NEWER 1079
#define IDC_RADIO_DATE_OLDER 1080
#define IDC_RADIO_DATE_BETWEEN 1081
#define IDC_DATEPICK1 1082
#define IDC_DATEPICK2 1083
#define IDC_DARKMODEINFO 1084
#define IDC_NP3_DISCLAIMER 1085
#define IDC_SPIN_MAXWORKER 1086
#define IDC_MAXNUMWORKER 1087
#define IDC_TEXT_NUMOFWORKER 1088
#define IDC_BACKUPINFOLDER2 1089
#define IDC_NOWARNINGIFNOBACKUP 1090
#define IDC_INVERSESEARCH 1091
#define IDC_SEARCHINFOUNDFILES 1092
#define IDC_EXPORT 1093
#define IDC_UPDATELINK 1094
#define IDC_DOUPDATECHECKS 1095
#define IDC_DARKMODEINFO 1083
#define IDC_INVERSESEARCH 1084
#define IDC_SEARCHINFOUNDFILES 1085
#define IDC_EXPORT 1086
#define IDC_UPDATELINK 1087
#define IDC_DOUPDATECHECKS 1088
#define IDC_CAPTURESEARCH 1089
#define IDC_STATIC5 1090
#define IDC_NUMNULL 1091
#define IDC_RESETDEFAULT 3000
#define IDC_NP3_DISCLAIMER 3001
#define IDC_SPIN_MAXWORKER 3002
#define IDC_MAXNUMWORKER 3003
#define IDC_TEXT_NUMOFWORKER 3004
#define ID_REMOVEBOOKMARK 32771
#define ID_DUMMY_RENAMEPRESET 32774
#define ID_RENAMEBOOKMARK 32775
#define IDC_STATIC -1
// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 169
#define _APS_NEXT_RESOURCE_VALUE 139
#define _APS_NEXT_COMMAND_VALUE 32776
#define _APS_NEXT_CONTROL_VALUE 1096
#define _APS_NEXT_CONTROL_VALUE 1091
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

View File

@ -110,6 +110,7 @@
#define IDS_MUI_DROP_NO_FILE 14018
#define IDS_MUI_SELMULTI 14019
#define IDS_MUI_SELRECTORMULTI 14020
#define IDS_MUI_INIFILE_READONLY 14021
#define IDS_MUI_ASK_SAVE 15000
#define IDS_MUI_ASK_REVERT 15001

View File

@ -180,6 +180,8 @@ BEGIN
IDS_MUI_SAVEDSETTINGS "Die aktuellen Notepad3 Einstellungen wurden gespeichert."
IDS_MUI_CREATEINI_FAIL "Fehler bei der Erzeugung einer Konfigurationsdatei."
IDS_MUI_WRITEINI_FAIL "Fehler beim schreiben der Einstellungen in die Konfigurationsdatei."
IDS_MUI_INIFILE_READONLY
"Die Konfigurationsdatei ist schreibgeschützt - ignorieren und Konfiguration überschreiben?"
IDS_MUI_SETTINGSNOTSAVED
"Es wurde keine Konfigurationsdatei gefunden.\nUm die Veränderungen der Stilanpassungen zu behalten, sollten die Einstellungen gespeichert werden (F7) oder über die Schematakonfiguration (Ctrl+F12) exportiert werden."
END

View File

@ -180,6 +180,8 @@ BEGIN
IDS_MUI_SAVEDSETTINGS "The current program settings have been saved."
IDS_MUI_CREATEINI_FAIL "Error creating configuration file."
IDS_MUI_WRITEINI_FAIL "Error writing settings to configuration file."
IDS_MUI_INIFILE_READONLY
"Configuration file is readonly - ignore and override settings?"
IDS_MUI_SETTINGSNOTSAVED
"No existing configuration file was found.\nTo keep your style modifications, save settings now (F7) or go back to scheme configuration (Ctrl+F12) and export your styles."
END

View File

@ -180,6 +180,8 @@ BEGIN
IDS_MUI_SAVEDSETTINGS "The current program settings have been saved."
IDS_MUI_CREATEINI_FAIL "Error creating configuration file."
IDS_MUI_WRITEINI_FAIL "Error writing settings to configuration file."
IDS_MUI_INIFILE_READONLY
"Configuration file is readonly - ignore and override settings?"
IDS_MUI_SETTINGSNOTSAVED
"No existing configuration file was found.\nTo keep your style modifications, save settings now (F7) or go back to scheme configuration (Ctrl+F12) and export your styles."
END

View File

@ -2099,6 +2099,70 @@ __try {
}
//=============================================================================
//
// CmdSaveSettingsNow()
//
void CmdSaveSettingsNow()
{
bool bCreateFailure = false;
if (StrIsEmpty(Globals.IniFile)) {
if (StrIsNotEmpty(Globals.IniFileDefault)) {
StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), Globals.IniFileDefault);
DWORD dwFileSize = 0UL;
Globals.bCanSaveIniFile = CreateIniFile(Globals.IniFile, &dwFileSize);
if (Globals.bCanSaveIniFile) {
Globals.bIniFileFromScratch = (dwFileSize == 0UL);
StringCchCopy(Globals.IniFileDefault, COUNTOF(Globals.IniFileDefault), L"");
}
else {
StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), L"");
Globals.bCanSaveIniFile = false;
bCreateFailure = true;
}
}
else {
return;
}
}
if (bCreateFailure) {
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_CREATEINI_FAIL);
return;
}
DWORD dwFileAttributes = 0;
if (!Globals.bCanSaveIniFile) {
dwFileAttributes = GetFileAttributes(Globals.IniFile);
if (dwFileAttributes == INVALID_FILE_ATTRIBUTES) {
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_CREATEINI_FAIL);
return;
}
if (dwFileAttributes & FILE_ATTRIBUTE_READONLY) {
INT_PTR const answer = InfoBoxLng(MB_YESNO | MB_ICONWARNING, NULL, IDS_MUI_INIFILE_READONLY);
if ((IDOK == answer) || (IDYES == answer)) {
SetFileAttributes(Globals.IniFile, FILE_ATTRIBUTE_NORMAL); // override read-only attrib
Globals.bCanSaveIniFile = CanAccessPath(Globals.IniFile, GENERIC_WRITE);
}
}
else {
dwFileAttributes = 0; // no need to change the file attributes
}
}
if (Globals.bCanSaveIniFile && SaveAllSettings(true)) {
InfoBoxLng(MB_ICONINFORMATION, L"MsgSaveSettingsInfo", IDS_MUI_SAVEDSETTINGS);
if (dwFileAttributes != 0) {
SetFileAttributes(Globals.IniFile, dwFileAttributes); // reset
Globals.bCanSaveIniFile = CanAccessPath(Globals.IniFile, GENERIC_WRITE);
}
}
else {
Globals.dwLastError = GetLastError();
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_WRITEINI_FAIL);
return;
}
}
//=============================================================================
//=============================================================================

View File

@ -33,8 +33,9 @@ bool CreateIniFile(LPCWSTR pszIniFilePath, DWORD* pdwFileSize_out);
void LoadSettings();
bool SaveWindowPositionSettings(bool bClearSettings);
bool SaveAllSettings(bool bForceSaveSettings);
void CmdSaveSettingsNow();
bool OpenSettingsFile(bool* keepCached);
bool OpenSettingsFile(bool* keepCached);
bool CloseSettingsFile(bool bSaveChanges, bool keepCached);
// ----------------------------------------------------------------------------

View File

@ -5542,43 +5542,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_VIEW_SAVESETTINGSNOW:
if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGSNOW)) {
bool bCreateFailure = false;
if (StrIsEmpty(Globals.IniFile)) {
if (StrIsNotEmpty(Globals.IniFileDefault)) {
StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), Globals.IniFileDefault);
DWORD dwFileSize = 0UL;
Globals.bCanSaveIniFile = CreateIniFile(Globals.IniFile, &dwFileSize);
if (Globals.bCanSaveIniFile) {
Globals.bIniFileFromScratch = (dwFileSize == 0UL);
StringCchCopy(Globals.IniFileDefault, COUNTOF(Globals.IniFileDefault), L"");
}
else {
StringCchCopy(Globals.IniFile, COUNTOF(Globals.IniFile), L"");
Globals.bCanSaveIniFile = false;
bCreateFailure = true;
}
}
else
break;
}
if (!bCreateFailure)
{
SetFileAttributes(Globals.IniFile, FILE_ATTRIBUTE_NORMAL); // override read-only attrib
if (SaveAllSettings(true)) {
InfoBoxLng(MB_ICONINFORMATION, L"MsgSaveSettingsInfo", IDS_MUI_SAVEDSETTINGS);
}
else {
Globals.dwLastError = GetLastError();
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_WRITEINI_FAIL);
}
}
else {
InfoBoxLng(MB_ICONWARNING, NULL, IDS_MUI_CREATEINI_FAIL);
}
if (IsCmdEnabled(hwnd, IDM_VIEW_SAVESETTINGSNOW))
{
CmdSaveSettingsNow();
}
break;