diff --git a/Versions/build.txt b/Versions/build.txt
index d00491fd7..0cfbf0888 100644
--- a/Versions/build.txt
+++ b/Versions/build.txt
@@ -1 +1 @@
-1
+2
diff --git a/grepWinNP3/grepWinNP3.exe b/grepWinNP3/grepWinNP3.exe
index 0334c06f8..8cef50e11 100644
Binary files a/grepWinNP3/grepWinNP3.exe and b/grepWinNP3/grepWinNP3.exe differ
diff --git a/grepWinNP3/grepWinNP3_x64.exe b/grepWinNP3/grepWinNP3_x64.exe
index 716083e3a..b815c565e 100644
Binary files a/grepWinNP3/grepWinNP3_x64.exe and b/grepWinNP3/grepWinNP3_x64.exe differ
diff --git a/language/common_res.h b/language/common_res.h
index 9754318ad..0d2d01219 100644
--- a/language/common_res.h
+++ b/language/common_res.h
@@ -80,6 +80,7 @@
#define IDS_MUI_WARN_LOAD_BIG_FILE 13015
#define IDS_MUI_ERR_FILE_TOO_LARGE 13016
#define IDS_MUI_WARN_UNKNOWN_EXT 13017
+#define IDS_MUI_ERR_DLG_FORMAT 13018
// keep order (CRLF(0), CR(1), LF(2))
#define IDS_MUI_EOLMODENAME_CRLF 13020
#define IDS_MUI_EOLMODENAME_CR 13021
diff --git a/language/np3_en_us/strings_en_us.rc b/language/np3_en_us/strings_en_us.rc
index 54b58bf7b..644e73823 100644
--- a/language/np3_en_us/strings_en_us.rc
+++ b/language/np3_en_us/strings_en_us.rc
@@ -126,6 +126,7 @@ STRINGTABLE
BEGIN
IDS_MUI_ERR_LOADFILE "Error loading ""%s""."
IDS_MUI_ERR_SAVEFILE "Error saving ""%s""."
+ IDS_MUI_ERR_DLG_FORMAT "Error '%s', cause:\n%s(ID:%d)\n"
IDS_MUI_ERR_BROWSE "No file browser plugin was found.\nThe MiniPath file browser plugin can be downloaded from https://rizonesoft.com."
IDS_MUI_ERR_GREPWIN "No file search plugin was found.\nThe grepWinNP3 file search plugin can be downloaded from https://rizonesoft.com."
IDS_MUI_ERR_MRUDLG "No access to the selected file!\nWould you like to remove it from the list?"
diff --git a/language/np3_pt_br/strings_pt_br.rc b/language/np3_pt_br/strings_pt_br.rc
index 8e403fadc..2edc06297 100644
--- a/language/np3_pt_br/strings_pt_br.rc
+++ b/language/np3_pt_br/strings_pt_br.rc
@@ -144,7 +144,7 @@ BEGIN
IDS_MUI_ERR_UNICODE2 "Certain characters in the current text are not supported by the selected encoding, and may be replaced by default placeholders when saving. It's recommended to choose another file encoding. Continue?"
IDS_MUI_ERR_DROP "Only one file can be dropped at the same time!"
IDS_MUI_ERR_ACCESSDENIED
- "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application??"
+ "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application?"
IDS_MUI_ERR_ADMINEXE "No administration executable found.\nCheck website https://rizonesoft.com?"
IDS_MUI_WARN_LOAD_BIG_FILE
"Are you sure you want to open this large file?\n\t(size: %s >= %s)!\n(Styling and Syntax Highlighting will not be applied!)"
diff --git a/language/np3_sk_sk/strings_sk_sk.rc b/language/np3_sk_sk/strings_sk_sk.rc
index ab495b3a5..6c18eb6d6 100644
--- a/language/np3_sk_sk/strings_sk_sk.rc
+++ b/language/np3_sk_sk/strings_sk_sk.rc
@@ -144,7 +144,7 @@ BEGIN
IDS_MUI_ERR_UNICODE2 "Certain characters in the current text are not supported by the selected encoding, and may be replaced by default placeholders when saving. It's recommended to choose another file encoding. Continue?"
IDS_MUI_ERR_DROP "Only one file can be dropped at the same time!"
IDS_MUI_ERR_ACCESSDENIED
- "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application??"
+ "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application?"
IDS_MUI_ERR_ADMINEXE "No administration executable found.\nCheck website https://rizonesoft.com?"
IDS_MUI_WARN_LOAD_BIG_FILE
"Are you sure you want to open this large file?\n\t(size: %s >= %s)!\n(Styling and Syntax Highlighting will not be applied!)"
diff --git a/language/np3_tr_tr/strings_tr_tr.rc b/language/np3_tr_tr/strings_tr_tr.rc
index 580a148fb..250036772 100644
--- a/language/np3_tr_tr/strings_tr_tr.rc
+++ b/language/np3_tr_tr/strings_tr_tr.rc
@@ -144,7 +144,7 @@ BEGIN
IDS_MUI_ERR_UNICODE2 "Certain characters in the current text are not supported by the selected encoding, and may be replaced by default placeholders when saving. It's recommended to choose another file encoding. Continue?"
IDS_MUI_ERR_DROP "Only one file can be dropped at the same time!"
IDS_MUI_ERR_ACCESSDENIED
- "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application??"
+ "The file ""%s"" cannot be saved and may be protected.\n\nDo you want to launch %s as 'Elevated' application?"
IDS_MUI_ERR_ADMINEXE "No administration executable found.\nCheck website https://rizonesoft.com?"
IDS_MUI_WARN_LOAD_BIG_FILE
"Are you sure you want to open this large file?\n\t(size: %s >= %s)!\n(Styling and Syntax Highlighting will not be applied!)"
diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf
index cde71a767..29b43b10d 100644
--- a/res/Notepad3.exe.manifest.conf
+++ b/res/Notepad3.exe.manifest.conf
@@ -3,7 +3,7 @@
Notepad3 NF
diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp
index 08faf867b..7bd2cc9f7 100644
--- a/src/Config/Config.cpp
+++ b/src/Config/Config.cpp
@@ -102,11 +102,17 @@ HANDLE AcquireWriteFileLock(LPCWSTR lpIniFilePath, OVERLAPPED& rOvrLpd)
{
bLocked = LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, 0, &rOvrLpd); // wait for exclusive lock
if (!bLocked) {
- MsgBoxLastError(L"AcquireWriteFileLock(): NO EXCLUSIVE LOCK ACQUIRED!", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"AcquireWriteFileLock(%s): NO EXCLUSIVE LOCK ACQUIRED!", lpIniFilePath);
+ MsgBoxLastError(msg, 0);
}
}
else {
- MsgBoxLastError(L"AcquireWriteFileLock(): INVALID FILE HANDLE!", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"AcquireWriteFileLock(%s): INVALID FILE HANDLE!", lpIniFilePath);
+ MsgBoxLastError(msg, 0);
}
return (bLocked ? hFile : INVALID_HANDLE_VALUE);
}
@@ -129,11 +135,17 @@ HANDLE AcquireReadFileLock(LPCWSTR lpIniFilePath, OVERLAPPED& rOvrLpd)
{
bLocked = LockFileEx(hFile, LOCKFILE_SHARED_LOCK, 0, MAXDWORD, 0, &rOvrLpd);
if (!bLocked) {
- MsgBoxLastError(L"AcquireReadFileLock(): NO READER LOCK ACQUIRED!", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"AcquireReadFileLock(%s): NO READER LOCK ACQUIRED!", lpIniFilePath);
+ MsgBoxLastError(msg, 0);
}
}
else {
- MsgBoxLastError(L"AcquireReadFileLock(): INVALID FILE HANDLE", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"AcquireReadFileLock(%s): INVALID FILE HANDLE!", lpIniFilePath);
+ MsgBoxLastError(msg, 0);
}
return (bLocked ? hFile : INVALID_HANDLE_VALUE);
}
@@ -915,7 +927,10 @@ extern "C" bool CreateIniFile()
CloseHandle(hFile); // done
}
else {
- MsgBoxLastError(L"CreateIniFile(): FAILD TO CREATE INITIAL INI FILE!", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"CreateIniFile(%s): FAILD TO CREATE INITIAL INI FILE!", Globals.IniFile);
+ MsgBoxLastError(msg, 0);
}
}
else {
@@ -929,7 +944,10 @@ extern "C" bool CreateIniFile()
CloseHandle(hFile);
}
else {
- MsgBoxLastError(L"CreateIniFile(): FAILED TO GET FILESIZE!", 0);
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"CreateIniFile(%s): FAILED TO GET FILESIZE!", Globals.IniFile);
+ MsgBoxLastError(msg, 0);
dwFileSize = INVALID_FILE_SIZE;
}
}
@@ -1564,7 +1582,9 @@ void LoadSettings()
Globals.pMRUfind = MRU_Create(_s_RecentFind, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
MRU_Load(Globals.pMRUfind, false);
- SetFindPattern(Globals.pMRUfind->pszItems[0]);
+ if (IsFindPatternEmpty()) {
+ SetFindPattern(Globals.pMRUfind->pszItems[0]);
+ }
Globals.pMRUreplace = MRU_Create(_s_RecentReplace, (/*IsWindowsNT()*/true) ? MRU_UTF8 : 0, MRU_ITEMSFNDRPL);
MRU_Load(Globals.pMRUreplace, false);
diff --git a/src/Config/SimpleIni.h b/src/Config/SimpleIni.h
index 839a8a516..6e00cb84b 100644
--- a/src/Config/SimpleIni.h
+++ b/src/Config/SimpleIni.h
@@ -246,6 +246,7 @@
#include
#include
#include
+#include
#ifdef SI_SUPPORT_IOSTREAMS
# include
@@ -1429,19 +1430,27 @@ CSimpleIniTempl::LoadFile(
const SI_WCHAR_T* a_pwszFile
)
{
- HANDLE hFile = CreateFile(a_pwszFile,
- GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
- nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (a_pwszFile && a_pwszFile[0])
+ {
+ HANDLE hFile = CreateFile(a_pwszFile,
+ GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hFile == INVALID_HANDLE_VALUE) {
- MsgBoxLastError(L"CSimpleIni::LoadFile(): INVALID_HANDLE_VALUE!", 0);
- return SI_Error::SI_FILE;
+ if (hFile == INVALID_HANDLE_VALUE) {
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"CSimpleIni::LoadFile(%s): INVALID_HANDLE_VALUE!", a_pwszFile);
+ MsgBoxLastError(msg, 0);
+
+ return SI_Error::SI_FILE;
+ }
+
+ SI_Error rc = LoadFile(hFile);
+
+ CloseHandle(hFile);
+ return rc;
}
-
- SI_Error rc = LoadFile(hFile);
-
- CloseHandle(hFile);
- return rc;
+ return SI_Error::SI_FILE;
}
#else
@@ -2629,19 +2638,26 @@ CSimpleIniTempl::SaveFile(
bool a_bAddSignature
) const
{
- HANDLE hFile = CreateFile(a_pwszFile,
- GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
- nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (a_pwszFile && a_pwszFile[0])
+ {
+ HANDLE hFile = CreateFile(a_pwszFile,
+ GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
+ nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
- if (hFile == INVALID_HANDLE_VALUE) {
- MsgBoxLastError(L"CSimpleIni::SaveFile(): INVALID_HANDLE_VALUE!", 0);
- return SI_Error::SI_FILE;
+ if (hFile == INVALID_HANDLE_VALUE) {
+ wchar_t msg[MAX_PATH + 128] = { 0 };
+ StringCchPrintf(msg, ARRAYSIZE(msg),
+ L"CSimpleIni::SaveFile(%s): INVALID_HANDLE_VALUE!", a_pwszFile);
+ MsgBoxLastError(msg, 0);
+ return SI_Error::SI_FILE;
+ }
+
+ SI_Error rc = SaveFile(hFile, a_bAddSignature);
+
+ CloseHandle(hFile);
+ return rc;
}
-
- SI_Error rc = SaveFile(hFile, a_bAddSignature);
-
- CloseHandle(hFile);
- return rc;
+ return SI_Error::SI_FILE;
}
#else
diff --git a/src/Dialogs.c b/src/Dialogs.c
index 0a3c00fec..b04ddde0d 100644
--- a/src/Dialogs.c
+++ b/src/Dialogs.c
@@ -158,18 +158,18 @@ DWORD MsgBoxLastError(LPCWSTR lpszMessage, DWORD dwErrID)
NULL,
dwErrID,
Globals.iPrefLANGID,
- (LPTSTR)&lpMsgBuf,
+ (LPWSTR)&lpMsgBuf,
0, NULL);
if (lpMsgBuf) {
// Display the error message and exit the process
- size_t const len = StringCchLenW((LPCWSTR)lpMsgBuf, 0) + StringCchLenW(lpszMessage, 0) + 80;
+ size_t const len = StringCchLen((LPCWSTR)lpMsgBuf, 0) + StringCchLen(lpszMessage, 0) + 160;
LPWSTR lpDisplayBuf = (LPWSTR)AllocMem(len * sizeof(WCHAR), HEAP_ZERO_MEMORY);
if (lpDisplayBuf) {
- StringCchPrintf(lpDisplayBuf, len, L"Error: '%s' failed with error id %d:\n%s.\n",
- lpszMessage, dwErrID, (LPCWSTR)lpMsgBuf);
-
+ WCHAR msgFormat[128] = { L'\0' };
+ GetLngString(IDS_MUI_ERR_DLG_FORMAT, msgFormat, COUNTOF(msgFormat));
+ StringCchPrintf(lpDisplayBuf, len, msgFormat, lpszMessage, (LPCWSTR)lpMsgBuf, dwErrID);
// center message box to main
HWND focus = GetFocus();
HWND hwnd = focus ? focus : Globals.hwndMain;
diff --git a/src/Edit.c b/src/Edit.c
index d2162d845..54b6dcdcb 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -1897,7 +1897,7 @@ void EditEscapeCChars(HWND hwnd) {
return;
}
- EDITFINDREPLACE efr = EFR_INIT_DATA;
+ EDITFINDREPLACE efr = INIT_EFR_DATA;
efr.hwnd = hwnd;
_BEGIN_UNDO_ACTION_;
@@ -1932,7 +1932,7 @@ void EditUnescapeCChars(HWND hwnd) {
return;
}
- EDITFINDREPLACE efr = EFR_INIT_DATA;
+ EDITFINDREPLACE efr = INIT_EFR_DATA;
efr.hwnd = hwnd;
_BEGIN_UNDO_ACTION_;
@@ -2378,7 +2378,7 @@ void EditUpdateTimestamps()
WCHAR wchReplaceLong[SMALL_BUFFER] = { L'\0' };
_GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), false);
- EDITFINDREPLACE efrTS_L = EFR_INIT_DATA;
+ EDITFINDREPLACE efrTS_L = INIT_EFR_DATA;
efrTS_L.hwnd = Globals.hwndEdit;
efrTS_L.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindLong, -1, efrTS_L.szFind, COUNTOF(efrTS_L.szFind), NULL, NULL);
@@ -2397,7 +2397,7 @@ void EditUpdateTimestamps()
WCHAR wchReplaceShort[SMALL_BUFFER] = { L'\0' };
_GetCurrentDateTimeString(wchReplaceLong, COUNTOF(wchReplaceLong), true);
- EDITFINDREPLACE efrTS_S = EFR_INIT_DATA;
+ EDITFINDREPLACE efrTS_S = INIT_EFR_DATA;
efrTS_S.hwnd = Globals.hwndEdit;
efrTS_S.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFindShort, -1, efrTS_S.szFind, COUNTOF(efrTS_S.szFind), NULL, NULL);
@@ -5047,6 +5047,8 @@ void EditJumpTo(DocLn iNewLine, DocPos iNewCol)
SciCall_DocumentEnd();
return;
}
+ if (iNewLine == 0) { iNewLine = 1; }
+
DocLn const iMaxLine = SciCall_GetLineCount();
// Line maximum is iMaxLine - 1 (doc line count starts with 0)
iNewLine = (min_ln(iNewLine, iMaxLine) - 1);
@@ -5169,209 +5171,214 @@ void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt)
//
static void _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr)
{
- if (lpefr) {
+ if (lpefr)
+ {
char szBuf[FNDRPL_BUFFER] = { '\0' };
- bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL);
-
- GetDlgItemTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf));
- if (StringCchCompareXA(szBuf, lpefr->szFind) != 0) {
- StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szBuf);
- lpefr->bStateChanged = true;
- }
-
- GetDlgItemTextW2MB(hwnd, IDC_REPLACETEXT, szBuf, COUNTOF(szBuf));
- if (StringCchCompareXA(szBuf, lpefr->szReplace) != 0) {
- StringCchCopyA(lpefr->szReplace, COUNTOF(lpefr->szReplace), szBuf);
- lpefr->bStateChanged = true;
- }
-
- bool bIsFlagSet = ((lpefr->fuFlags & SCFIND_MATCHCASE) != 0);
- if (IsButtonChecked(hwnd, IDC_FINDCASE)) {
- if (!bIsFlagSet) {
- lpefr->fuFlags |= SCFIND_MATCHCASE;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->fuFlags &= ~(SCFIND_MATCHCASE);
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = ((lpefr->fuFlags & SCFIND_WHOLEWORD) != 0);
- if (IsButtonChecked(hwnd, IDC_FINDWORD)) {
- if (!bIsFlagSet) {
- lpefr->fuFlags |= SCFIND_WHOLEWORD;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->fuFlags &= ~(SCFIND_WHOLEWORD);
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = ((lpefr->fuFlags & SCFIND_WORDSTART) != 0);
- if (IsButtonChecked(hwnd, IDC_FINDSTART)) {
- if (!bIsFlagSet) {
- lpefr->fuFlags |= SCFIND_WORDSTART;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->fuFlags &= ~(SCFIND_WORDSTART);
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = ((lpefr->fuFlags & SCFIND_REGEXP) != 0);
- if (IsButtonChecked(hwnd, IDC_FINDREGEXP)) {
- if (!bIsFlagSet) {
- lpefr->fuFlags |= SCFIND_REGEXP;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->fuFlags &= ~SCFIND_REGEXP;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = ((lpefr->fuFlags & SCFIND_DOT_MATCH_ALL) != 0);
- if (IsButtonChecked(hwnd, IDC_DOT_MATCH_ALL)) {
- if (!bIsFlagSet) {
- lpefr->fuFlags |= SCFIND_DOT_MATCH_ALL;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->fuFlags &= ~SCFIND_DOT_MATCH_ALL;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = lpefr->bWildcardSearch;
- if (IsButtonChecked(hwnd, IDC_WILDCARDSEARCH)) {
- if (!bIsFlagSet) {
- lpefr->bWildcardSearch = true;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bWildcardSearch = false;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = lpefr->bOverlappingFind;
- if (IsButtonChecked(hwnd, IDC_FIND_OVERLAPPING)) {
- if (!bIsFlagSet) {
- lpefr->bOverlappingFind = true;
- lpefr->bStateChanged = false; // no effect on state
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bOverlappingFind = false;
- lpefr->bStateChanged = false; // no effect on state
- }
- }
-
- bIsFlagSet = lpefr->bNoFindWrap;
- if (IsButtonChecked(hwnd, IDC_NOWRAP)) {
- if (!bIsFlagSet) {
- lpefr->bNoFindWrap = true;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bNoFindWrap = false;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = lpefr->bMarkOccurences;
- if (IsButtonChecked(hwnd, IDC_ALL_OCCURRENCES)) {
- if (!bIsFlagSet) {
- lpefr->bMarkOccurences = true;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bMarkOccurences = false;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = lpefr->bTransformBS;
- if (IsButtonChecked(hwnd, IDC_FINDTRANSFORMBS)) {
- if (!bIsFlagSet) {
- lpefr->bTransformBS = true;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bTransformBS = false;
- lpefr->bStateChanged = true;
- }
- }
-
- bIsFlagSet = lpefr->bAutoEscCtrlChars;
- if (IsButtonChecked(hwnd, IDC_FINDAUTOESCCTRLCHR)) {
- if (!bIsFlagSet) {
- lpefr->bAutoEscCtrlChars = true;
- lpefr->bStateChanged = true;
- }
- }
- else {
- if (bIsFlagSet) {
- lpefr->bAutoEscCtrlChars = false;
- lpefr->bStateChanged = true;
- }
- }
-
- if (bIsFindDlg)
+ if (hwnd)
{
- bIsFlagSet = lpefr->bFindClose;
- if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
+ bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL);
+
+ GetDlgItemTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf));
+ if (StringCchCompareXA(szBuf, lpefr->szFind) != 0) {
+ StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szBuf);
+ lpefr->bStateChanged = true;
+ }
+
+ GetDlgItemTextW2MB(hwnd, IDC_REPLACETEXT, szBuf, COUNTOF(szBuf));
+ if (StringCchCompareXA(szBuf, lpefr->szReplace) != 0) {
+ StringCchCopyA(lpefr->szReplace, COUNTOF(lpefr->szReplace), szBuf);
+ lpefr->bStateChanged = true;
+ }
+
+
+ bool bIsFlagSet = ((lpefr->fuFlags & SCFIND_MATCHCASE) != 0);
+ if (IsButtonChecked(hwnd, IDC_FINDCASE)) {
if (!bIsFlagSet) {
- lpefr->bFindClose = true;
+ lpefr->fuFlags |= SCFIND_MATCHCASE;
lpefr->bStateChanged = true;
}
}
else {
if (bIsFlagSet) {
- lpefr->bFindClose = false;
+ lpefr->fuFlags &= ~(SCFIND_MATCHCASE);
lpefr->bStateChanged = true;
}
}
- }
- else // replace close
- {
- bIsFlagSet = lpefr->bReplaceClose;
- if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
+
+ bIsFlagSet = ((lpefr->fuFlags & SCFIND_WHOLEWORD) != 0);
+ if (IsButtonChecked(hwnd, IDC_FINDWORD)) {
if (!bIsFlagSet) {
- lpefr->bReplaceClose = true;
+ lpefr->fuFlags |= SCFIND_WHOLEWORD;
lpefr->bStateChanged = true;
}
}
else {
if (bIsFlagSet) {
- lpefr->bReplaceClose = false;
+ lpefr->fuFlags &= ~(SCFIND_WHOLEWORD);
lpefr->bStateChanged = true;
}
}
- }
+
+ bIsFlagSet = ((lpefr->fuFlags & SCFIND_WORDSTART) != 0);
+ if (IsButtonChecked(hwnd, IDC_FINDSTART)) {
+ if (!bIsFlagSet) {
+ lpefr->fuFlags |= SCFIND_WORDSTART;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->fuFlags &= ~(SCFIND_WORDSTART);
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = ((lpefr->fuFlags & SCFIND_REGEXP) != 0);
+ if (IsButtonChecked(hwnd, IDC_FINDREGEXP)) {
+ if (!bIsFlagSet) {
+ lpefr->fuFlags |= SCFIND_REGEXP;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->fuFlags &= ~SCFIND_REGEXP;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = ((lpefr->fuFlags & SCFIND_DOT_MATCH_ALL) != 0);
+ if (IsButtonChecked(hwnd, IDC_DOT_MATCH_ALL)) {
+ if (!bIsFlagSet) {
+ lpefr->fuFlags |= SCFIND_DOT_MATCH_ALL;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->fuFlags &= ~SCFIND_DOT_MATCH_ALL;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = lpefr->bWildcardSearch;
+ if (IsButtonChecked(hwnd, IDC_WILDCARDSEARCH)) {
+ if (!bIsFlagSet) {
+ lpefr->bWildcardSearch = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bWildcardSearch = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = lpefr->bOverlappingFind;
+ if (IsButtonChecked(hwnd, IDC_FIND_OVERLAPPING)) {
+ if (!bIsFlagSet) {
+ lpefr->bOverlappingFind = true;
+ lpefr->bStateChanged = false; // no effect on state
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bOverlappingFind = false;
+ lpefr->bStateChanged = false; // no effect on state
+ }
+ }
+
+ bIsFlagSet = lpefr->bNoFindWrap;
+ if (IsButtonChecked(hwnd, IDC_NOWRAP)) {
+ if (!bIsFlagSet) {
+ lpefr->bNoFindWrap = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bNoFindWrap = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = lpefr->bMarkOccurences;
+ if (IsButtonChecked(hwnd, IDC_ALL_OCCURRENCES)) {
+ if (!bIsFlagSet) {
+ lpefr->bMarkOccurences = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bMarkOccurences = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = lpefr->bTransformBS;
+ if (IsButtonChecked(hwnd, IDC_FINDTRANSFORMBS)) {
+ if (!bIsFlagSet) {
+ lpefr->bTransformBS = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bTransformBS = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ bIsFlagSet = lpefr->bAutoEscCtrlChars;
+ if (IsButtonChecked(hwnd, IDC_FINDAUTOESCCTRLCHR)) {
+ if (!bIsFlagSet) {
+ lpefr->bAutoEscCtrlChars = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bAutoEscCtrlChars = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+
+ if (bIsFindDlg)
+ {
+ bIsFlagSet = lpefr->bFindClose;
+ if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
+ if (!bIsFlagSet) {
+ lpefr->bFindClose = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bFindClose = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+ }
+ else // replace close
+ {
+ bIsFlagSet = lpefr->bReplaceClose;
+ if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
+ if (!bIsFlagSet) {
+ lpefr->bReplaceClose = true;
+ lpefr->bStateChanged = true;
+ }
+ }
+ else {
+ if (bIsFlagSet) {
+ lpefr->bReplaceClose = false;
+ lpefr->bStateChanged = true;
+ }
+ }
+ }
+ } // if hwnd
}
}
@@ -5437,7 +5444,7 @@ static int _EditGetFindStrg(HWND hwnd, LPCEDITFINDREPLACE lpefr, LPSTR szFind,
StringCchCopyA(szFind, cchCnt, lpefr->szFind);
}
else {
- GetFindPatternMB(szFind, cchCnt);
+ CopyFindPatternMB(szFind, cchCnt);
StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szFind);
}
if (!StringCchLenA(szFind, cchCnt)) { return 0; }
@@ -5631,6 +5638,7 @@ static LRESULT CALLBACK EditBoxForPasteFixes(HWND hwnd, UINT uMsg, WPARAM wParam
//
// EditFindReplaceDlgProcW()
//
+extern int s_flagMatchText;
static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lParam)
{
@@ -5652,6 +5660,8 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
{
case WM_INITDIALOG:
{
+ // clear cmd line stuff
+ s_flagMatchText = 0;
sg_pefrData = NULL;
// the global static Find/Replace data structure
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 7068e206f..2be48b835 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -92,6 +92,8 @@ WCHAR s_tchToolbarBitmap[MAX_PATH] = { L'\0' };
WCHAR s_tchToolbarBitmapHot[MAX_PATH] = { L'\0' };
WCHAR s_tchToolbarBitmapDisabled[MAX_PATH] = { L'\0' };
+int s_flagMatchText = 0;
+
// ------------------------------------
static bool s_bIsProcessElevated = false;
static bool s_bIsUserInAdminGroup = false;
@@ -530,7 +532,6 @@ static void CALLBACK MQ_ExecuteNext(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWOR
//
static LPWSTR s_lpSchemeArg = NULL;
static LPWSTR s_lpOrigFileArg = NULL;
-static LPWSTR s_lpMatchArg = NULL;
static WCHAR s_lpFileArg[MAX_PATH + 1] = { L'\0' };
static cpi_enc_t s_flagSetEncoding = CPI_NONE;
@@ -541,7 +542,6 @@ static bool s_flagKeepTitleExcerpt = false;
static bool s_flagNewFromClipboard = false;
static bool s_flagPasteBoard = false;
static bool s_flagJumpTo = false;
-static int s_flagMatchText = 0;
static FILE_WATCHING_MODE s_flagChangeNotify = FWM_DONT_CARE;
static bool s_flagQuietCreate = false;
static bool s_flagLexerSpecified = false;
@@ -773,11 +773,6 @@ static void _CleanUpResources(const HWND hwnd, bool bIsInitialized)
OleUninitialize();
- if (s_lpMatchArg) {
- LocalFree(s_lpMatchArg); // StrDup()
- s_lpMatchArg = NULL;
- }
-
if (s_lpOrigFileArg) {
FreeMem(s_lpOrigFileArg);
s_lpOrigFileArg = NULL;
@@ -1108,6 +1103,111 @@ WININFO GetWinInfoByFlag(const int flagsPos)
}
+
+//=============================================================================
+//
+// Set/Get FindPattern()
+//
+static WCHAR sCurrentFindPattern[FNDRPL_BUFFER] = { L'\0' };
+
+bool IsFindPatternEmpty()
+{
+ return StrIsEmpty(sCurrentFindPattern);
+}
+
+//=============================================================================
+//
+// SetFindPattern()
+//
+void SetFindPattern(LPCWSTR wchFindPattern)
+{
+ StringCchCopy(sCurrentFindPattern, COUNTOF(sCurrentFindPattern), (wchFindPattern ? wchFindPattern : L""));
+}
+
+//=============================================================================
+//
+// SetFindPatternMB()
+//
+void SetFindPatternMB(LPCSTR chFindPattern)
+{
+ MultiByteToWideCharEx(Encoding_SciCP, 0, chFindPattern, -1, sCurrentFindPattern, COUNTOF(sCurrentFindPattern));
+}
+
+
+//=============================================================================
+//
+// LengthOfFindPattern()
+//
+size_t LengthOfFindPattern()
+{
+ return StringCchLen(sCurrentFindPattern, 0);
+}
+
+
+//=============================================================================
+//
+// GetFindPattern()
+//
+LPCWSTR GetFindPattern()
+{
+ return sCurrentFindPattern;
+}
+
+
+//=============================================================================
+//
+// CopyFindPattern()
+//
+void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount)
+{
+ StringCchCopy(wchFindPattern, bufferCount, sCurrentFindPattern);
+}
+
+//=============================================================================
+//
+// CopyFindPatternMB()
+//
+void CopyFindPatternMB(LPSTR chFindPattern, size_t bufferCount)
+{
+ WideCharToMultiByte(Encoding_SciCP, 0, sCurrentFindPattern, -1, chFindPattern, (int)bufferCount, NULL, NULL);
+}
+
+
+
+static EDITFINDREPLACE s_FindReplaceData = INIT_EFR_DATA;
+
+//=============================================================================
+//
+// SetFindReplaceData()
+//
+static void SetFindReplaceData()
+{
+ s_FindReplaceData = Settings.EFR_Data; // reset
+
+ if (s_flagMatchText) // cmd line
+ {
+ if (!IsFindPatternEmpty()) {
+ CopyFindPatternMB(s_FindReplaceData.szFind, COUNTOF(s_FindReplaceData.szFind));
+ }
+ if (s_flagMatchText & 4) {
+ s_FindReplaceData.fuFlags = (SCFIND_REGEXP | SCFIND_POSIX);
+ }
+ if (s_flagMatchText & 8) {
+ s_FindReplaceData.fuFlags |= SCFIND_MATCHCASE;
+ }
+ if (s_flagMatchText & 16) {
+ s_FindReplaceData.fuFlags |= SCFIND_DOT_MATCH_ALL;
+ }
+ if (s_flagMatchText & 32) {
+ s_FindReplaceData.bTransformBS = true;
+ }
+ s_FindReplaceData.bOverlappingFind = false;
+ s_FindReplaceData.bWildcardSearch = false;
+ s_FindReplaceData.bReplaceClose = false;
+ }
+}
+
+
//=============================================================================
//
// InitApplication()
@@ -1335,24 +1435,19 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow)
}
// Match Text
- if (s_flagMatchText && StrIsNotEmpty(s_lpMatchArg))
+ if (s_flagMatchText && !IsFindPatternEmpty())
{
if (!Sci_IsDocEmpty()) {
- WideCharToMultiByteEx(Encoding_SciCP,0,s_lpMatchArg,-1,Settings.EFR_Data.szFind,COUNTOF(Settings.EFR_Data.szFind),NULL,NULL);
-
- if (s_flagMatchText & 4)
- Settings.EFR_Data.fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX);
- else if (s_flagMatchText & 8)
- Settings.EFR_Data.bTransformBS = true;
+ SetFindReplaceData(); // s_FindReplaceData
if (s_flagMatchText & 2) {
if (!s_flagJumpTo) { SciCall_DocumentEnd(); }
- EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,false,false);
+ EditFindPrev(Globals.hwndEdit,&s_FindReplaceData,false,false);
}
else {
if (!s_flagJumpTo) { SciCall_DocumentStart(); }
- EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,false,false);
+ EditFindNext(Globals.hwndEdit,&s_FindReplaceData,false,false);
}
}
}
@@ -2791,30 +2886,23 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
if (params->flagJumpTo) {
- if (params->iInitialLine == 0)
- params->iInitialLine = 1;
+ s_flagJumpTo = true;
EditJumpTo(params->iInitialLine, params->iInitialColumn);
}
- if (params->flagMatchText) {
+ if (params->flagMatchText)
+ {
s_flagMatchText = params->flagMatchText;
- if (s_lpMatchArg) { LocalFree(s_lpMatchArg); } // StrDup()
- s_lpMatchArg = StrDup(StrEnd(¶ms->wchData, 0) + 1);
-
- WideCharToMultiByteEx(Encoding_SciCP, 0, s_lpMatchArg, -1, Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind), NULL, NULL);
-
- if (s_flagMatchText & 4)
- Settings.EFR_Data.fuFlags |= (SCFIND_REGEXP | SCFIND_POSIX);
- else if (s_flagMatchText & 8)
- Settings.EFR_Data.bTransformBS = true;
+ SetFindPattern(StrEnd(¶ms->wchData, 0) + 1);
+ SetFindReplaceData(); // s_FindReplaceData
if (s_flagMatchText & 2) {
if (!s_flagJumpTo) { SciCall_DocumentEnd(); }
- EditFindPrev(Globals.hwndEdit, &Settings.EFR_Data, false, false);
+ EditFindPrev(Globals.hwndEdit, &s_FindReplaceData, false, false);
}
else {
if (!s_flagJumpTo) { SciCall_DocumentStart(); }
- EditFindNext(Globals.hwndEdit, &Settings.EFR_Data, false, false);
+ EditFindNext(Globals.hwndEdit, &s_FindReplaceData, false, false);
}
}
@@ -4729,16 +4817,17 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_EDIT_FIND:
+ SetFindReplaceData(); // s_FindReplaceData
if (!IsWindow(Globals.hwndDlgFindReplace)) {
Globals.bFindReplCopySelOrClip = true;
- Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, false);
+ Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &s_FindReplaceData, false);
}
else {
Globals.bFindReplCopySelOrClip = (GetForegroundWindow() != Globals.hwndDlgFindReplace);
if (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE)) {
SendWMCommand(Globals.hwndDlgFindReplace, IDMSG_SWITCHTOFIND);
DestroyWindow(Globals.hwndDlgFindReplace);
- Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, false);
+ Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &s_FindReplaceData, false);
}
else {
SetForegroundWindow(Globals.hwndDlgFindReplace);
@@ -4749,16 +4838,17 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_EDIT_REPLACE:
+ SetFindReplaceData(); // s_FindReplaceData
if (!IsWindow(Globals.hwndDlgFindReplace)) {
Globals.bFindReplCopySelOrClip = true;
- Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, true);
+ Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &s_FindReplaceData, true);
}
else {
Globals.bFindReplCopySelOrClip = (GetForegroundWindow() != Globals.hwndDlgFindReplace);
if (!GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE)) {
SendWMCommand(Globals.hwndDlgFindReplace, IDMSG_SWITCHTOREPLACE);
DestroyWindow(Globals.hwndDlgFindReplace);
- Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &Settings.EFR_Data, true);
+ Globals.hwndDlgFindReplace = EditFindReplaceDlg(Globals.hwndEdit, &s_FindReplaceData, true);
}
else {
SetForegroundWindow(Globals.hwndDlgFindReplace);
@@ -4803,7 +4893,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break; // done
}
- if (IsFindPatternEmpty() && !StringCchLenA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind)))
+ SetFindReplaceData(); // s_FindReplaceData
+
+ if (IsFindPatternEmpty() && !StrIsEmptyA(s_FindReplaceData.szFind))
{
if (iLoWParam != IDM_EDIT_REPLACENEXT) {
SendWMCommand(hwnd, IDM_EDIT_FIND);
@@ -4817,16 +4909,16 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
switch (iLoWParam) {
case IDM_EDIT_FINDNEXT:
- EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,false,false);
+ EditFindNext(Globals.hwndEdit,&s_FindReplaceData,false,false);
break;
case IDM_EDIT_FINDPREV:
- EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,false,false);
+ EditFindPrev(Globals.hwndEdit,&s_FindReplaceData,false,false);
break;
case IDM_EDIT_REPLACENEXT:
if (Globals.bReplaceInitialized) {
- EditReplace(Globals.hwndEdit, &Settings.EFR_Data);
+ EditReplace(Globals.hwndEdit, &s_FindReplaceData);
}
else {
SendWMCommand(hwnd, IDM_EDIT_REPLACE);
@@ -4834,11 +4926,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_EDIT_SELTONEXT:
- EditFindNext(Globals.hwndEdit,&Settings.EFR_Data,true,false);
+ EditFindNext(Globals.hwndEdit,&s_FindReplaceData,true,false);
break;
case IDM_EDIT_SELTOPREV:
- EditFindPrev(Globals.hwndEdit,&Settings.EFR_Data,true,false);
+ EditFindPrev(Globals.hwndEdit,&s_FindReplaceData,true,false);
break;
}
}
@@ -4863,18 +4955,14 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
}
SciCall_GetSelText(szSelection);
- StringCchCopyA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind), szSelection);
- Settings.EFR_Data.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX));
- Settings.EFR_Data.bTransformBS = false;
+ SetFindReplaceData(); // s_FindReplaceData
- LPWSTR pszTextW = AllocMem(cchSelection * sizeof(WCHAR), HEAP_ZERO_MEMORY);
- if (pszTextW == NULL) {
- FreeMem(szSelection);
- break;
- }
- MultiByteToWideCharEx(Encoding_SciCP, 0, szSelection, -1, pszTextW, cchSelection);
- MRU_Add(Globals.pMRUfind, pszTextW, 0, -1, -1, NULL);
- SetFindPattern(pszTextW);
+ SetFindPatternMB(szSelection);
+ MRU_Add(Globals.pMRUfind, GetFindPattern(), 0, -1, -1, NULL);
+
+ StringCchCopyA(s_FindReplaceData.szFind, COUNTOF(s_FindReplaceData.szFind), szSelection);
+ s_FindReplaceData.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX));
+ s_FindReplaceData.bTransformBS = false;
switch (iLoWParam) {
@@ -4882,16 +4970,15 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case CMD_FINDNEXTSEL:
- EditFindNext(Globals.hwndEdit, &Settings.EFR_Data, false, false);
+ EditFindNext(Globals.hwndEdit, &s_FindReplaceData, false, false);
break;
case CMD_FINDPREVSEL:
- EditFindPrev(Globals.hwndEdit, &Settings.EFR_Data, false, false);
+ EditFindPrev(Globals.hwndEdit, &s_FindReplaceData, false, false);
break;
}
FreeMem(szSelection);
- FreeMem(pszTextW);
}
}
break;
@@ -7366,55 +7453,6 @@ LRESULT MsgNotify(HWND hwnd, WPARAM wParam, LPARAM lParam)
}
-
-//=============================================================================
-//
-// Set/Get FindPattern()
-//
-static WCHAR sCurrentFindPattern[FNDRPL_BUFFER] = { L'\0' };
-
-bool IsFindPatternEmpty()
-{
- return (StringCchLenW(sCurrentFindPattern, COUNTOF(sCurrentFindPattern)) == 0);
-}
-
-//=============================================================================
-//
-// SetFindPattern()
-//
-void SetFindPattern(LPCWSTR wchFindPattern)
-{
- StringCchCopyW(sCurrentFindPattern, COUNTOF(sCurrentFindPattern), (wchFindPattern ? wchFindPattern : L""));
-}
-
-//=============================================================================
-//
-// SetFindPatternMB()
-//
-void SetFindPatternMB(LPCSTR chFindPattern)
-{
- MultiByteToWideCharEx(Encoding_SciCP, 0, chFindPattern, -1, sCurrentFindPattern, COUNTOF(sCurrentFindPattern));
-}
-
-//=============================================================================
-//
-// GetFindPattern()
-//
-void GetFindPattern(LPWSTR wchFindPattern, size_t bufferCount)
-{
- StringCchCopyW(wchFindPattern, bufferCount, sCurrentFindPattern);
-}
-
-//=============================================================================
-//
-// GetFindPatternMB()
-//
-void GetFindPatternMB(LPSTR chFindPattern, size_t bufferCount)
-{
- WideCharToMultiByte(Encoding_SciCP, 0, sCurrentFindPattern, -1, chFindPattern, (int)bufferCount, NULL, NULL);
-}
-
-
//=============================================================================
//
// ParseCommandLine()
@@ -7674,38 +7712,52 @@ void ParseCommandLine()
break;
case L'M':
- {
- bool bFindUp = false;
- bool bRegex = false;
- bool bTransBS = false;
+ {
+ bool bFindUp = false;
+ bool bMatchCase = false;
+ bool bRegex = false;
+ bool bDotMatchAll = false;
+ bool bTransBS = false;
- if (StrChr(lp1, L'-'))
- bFindUp = true;
- if (StrChr(lp1, L'R'))
- bRegex = true;
- if (StrChr(lp1, L'B'))
- bTransBS = true;
-
- if (ExtractFirstArgument(lp2, lp1, lp2, (int)len)) {
- if (s_lpMatchArg) { LocalFree(s_lpMatchArg); } // StrDup()
- s_lpMatchArg = StrDup(lp1);
- s_flagMatchText = 1;
-
- if (bFindUp)
- s_flagMatchText |= 2;
-
- if (bRegex) {
- s_flagMatchText &= ~8;
- s_flagMatchText |= 4;
+ if (StrChr(lp1, L'-')) {
+ bFindUp = true;
}
-
- if (bTransBS) {
- s_flagMatchText &= ~4;
- s_flagMatchText |= 8;
+ if (StrChr(lp1, L'C')) {
+ bMatchCase = true;
+ }
+ if (StrChr(lp1, L'R')) {
+ bRegex = true;
+ bTransBS = true;
+ }
+ if (StrChr(lp1, L'A')) {
+ bDotMatchAll = true;
+ }
+ if (StrChr(lp1, L'B')) {
+ bTransBS = true;
+ }
+ if (ExtractFirstArgument(lp2, lp1, lp2, (int)len))
+ {
+ SetFindPattern(lp1);
+
+ s_flagMatchText = 1;
+ if (bFindUp) {
+ s_flagMatchText |= 2;
+ }
+ if (bRegex) {
+ s_flagMatchText |= 4;
+ }
+ if (bMatchCase) {
+ s_flagMatchText |= 8;
+ }
+ if (bDotMatchAll) {
+ s_flagMatchText |= 16;
+ }
+ if (bTransBS) {
+ s_flagMatchText |= 32;
+ }
}
}
- }
- break;
+ break;
case L'L':
if (*(lp1 + 1) == L'0' || *(lp1 + 1) == L'-' || *CharUpper(lp1 + 1) == L'O')
@@ -7959,7 +8011,7 @@ static void _UpdateToolbarDelayed()
EnableTool(Globals.hwndToolbar, IDT_EDIT_FIND, b2);
//EnableTool(Globals.hwndToolbar, ,b2);
- //EnableTool(Globals.hwndToolbar, IDT_EDIT_FINDPREV,b2 && StringCchLenA(Settings.EFR_Data.szFind,0));
+ //EnableTool(Globals.hwndToolbar, IDT_EDIT_FINDPREV,b2 && !StrIsEmptyA(s_FindReplaceData.szFind));
EnableTool(Globals.hwndToolbar, IDT_EDIT_REPLACE, b2 && !ro);
EnableTool(Globals.hwndToolbar, IDT_EDIT_CUT, !b1 && !ro);
@@ -9433,7 +9485,9 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload,
}
EditSetBookmarkList(Globals.hwndEdit, pszBookMarks);
- SetFindPattern((Globals.pMRUfind ? Globals.pMRUfind->pszItems[0] : L""));
+ if (IsFindPatternEmpty()) {
+ SetFindPattern((Globals.pMRUfind ? Globals.pMRUfind->pszItems[0] : L""));
+ }
// Install watching of the current file
if (!bReload && FileWatching.ResetFileWatching) {
@@ -10119,8 +10173,9 @@ bool ActivatePrevInst()
if (s_lpSchemeArg) {
cb += ((StringCchLen(s_lpSchemeArg, 0) + 1) * sizeof(WCHAR));
}
- if (s_lpMatchArg) {
- cb += ((StringCchLen(s_lpMatchArg, 0) + 1) * sizeof(WCHAR));
+
+ if (!IsFindPatternEmpty()) {
+ cb += ((LengthOfFindPattern() + 1) * sizeof(WCHAR));
}
LPnp3params params = AllocMem(cb, HEAP_ZERO_MEMORY);
params->flagFileSpecified = false;
@@ -10143,8 +10198,8 @@ bool ActivatePrevInst()
params->flagTitleExcerpt = 0;
params->flagMatchText = s_flagMatchText;
- if (s_lpMatchArg) {
- StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (StringCchLen(s_lpMatchArg, 0) + 1), s_lpMatchArg);
+ if (!IsFindPatternEmpty()) {
+ StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1), GetFindPattern());
}
cds.dwData = DATA_NOTEPAD3_PARAMS;
@@ -10203,8 +10258,8 @@ bool ActivatePrevInst()
if (cchTitleExcerpt) {
cb += (cchTitleExcerpt + 1) * sizeof(WCHAR);
}
- if (s_lpMatchArg) {
- cb += ((StringCchLen(s_lpMatchArg, 0) + 1) * sizeof(WCHAR));
+ if (!IsFindPatternEmpty()) {
+ cb += ((LengthOfFindPattern() + 1) * sizeof(WCHAR));
}
LPnp3params params = AllocMem(cb, HEAP_ZERO_MEMORY);
@@ -10236,8 +10291,8 @@ bool ActivatePrevInst()
}
params->flagMatchText = s_flagMatchText;
- if (s_lpMatchArg) {
- StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (StringCchLen(s_lpMatchArg, 0) + 1), s_lpMatchArg);
+ if (!IsFindPatternEmpty()) {
+ StringCchCopy(StrEnd(¶ms->wchData, 0) + 1, (LengthOfFindPattern() + 1), GetFindPattern());
}
cds.dwData = DATA_NOTEPAD3_PARAMS;
diff --git a/src/Notepad3.h b/src/Notepad3.h
index 83ea89917..2f39c9487 100644
--- a/src/Notepad3.h
+++ b/src/Notepad3.h
@@ -158,8 +158,10 @@ void HandleColorDefClicked(HWND hwnd, const DocPos position);
bool IsFindPatternEmpty();
void SetFindPattern(LPCWSTR wchFindPattern);
void SetFindPatternMB(LPCSTR chFindPattern);
-void GetFindPattern(LPWSTR wchFindPattern, size_t bufferCount);
-void GetFindPatternMB(LPSTR chFindPattern, size_t bufferCount);
+size_t LengthOfFindPattern();
+LPCWSTR GetFindPattern();
+void CopyFindPattern(LPWSTR wchFindPattern, size_t bufferCount);
+void CopyFindPatternMB(LPSTR chFindPattern, size_t bufferCount);
bool ConsistentIndentationCheck(EditFileIOStatus* fioStatus);
diff --git a/src/TypeDefs.h b/src/TypeDefs.h
index 8c8b27699..8f7574327 100644
--- a/src/TypeDefs.h
+++ b/src/TypeDefs.h
@@ -199,7 +199,7 @@ typedef struct _editfindreplace
} EDITFINDREPLACE, *LPEDITFINDREPLACE, *LPCEDITFINDREPLACE;
-#define EFR_INIT_DATA { "", "", 0, false, false, false, false, false, false, false, false, false, true, NULL }
+#define INIT_EFR_DATA { "", "", 0, false, false, false, false, false, false, false, false, false, true, NULL }
#define IDMSG_SWITCHTOFIND 300
#define IDMSG_SWITCHTOREPLACE 301
diff --git a/src/VersionEx.h b/src/VersionEx.h
index 26516bbed..2c27f1e21 100644
--- a/src/VersionEx.h
+++ b/src/VersionEx.h
@@ -9,11 +9,11 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_REV 330
-#define VERSION_BUILD 1
+#define VERSION_BUILD 2
#define SCINTILLA_VER 432
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27
#define TINYEXPR_VER 2018.05.11
#define UTHASH_VER 2.1.0
#define VERSION_PATCH NF
-#define VERSION_COMMIT_ID dkt1-amr
+#define VERSION_COMMIT_ID t7820-rk