mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ fix: transform backslashes while pasting into search/replace box
This commit is contained in:
parent
8df8f4cf6a
commit
ac1ba2496f
@ -1 +1 @@
|
||||
2715
|
||||
2716
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<assemblyIdentity
|
||||
name="Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.20.127.2715"
|
||||
version="5.20.128.2716"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 BETA</description>
|
||||
|
||||
@ -280,7 +280,7 @@ void EditInitWordDelimiter(HWND hwnd)
|
||||
if (StrIsNotEmpty(Settings2.AutoCompleteFillUpChars))
|
||||
{
|
||||
WideCharToMultiByte(Encoding_SciCP, 0, Settings2.AutoCompleteFillUpChars, -1, AutoCompleteFillUpChars, (int)COUNTOF(AutoCompleteFillUpChars), NULL, NULL);
|
||||
UnSlash(AutoCompleteFillUpChars, Encoding_SciCP);
|
||||
UnSlashA(AutoCompleteFillUpChars, Encoding_SciCP);
|
||||
|
||||
s_ACFillUpCharsHaveNewLn = false;
|
||||
int i = 0;
|
||||
@ -5356,6 +5356,7 @@ static LRESULT CALLBACK EditBoxForPasteFixes(HWND hwnd, UINT uMsg, WPARAM wParam
|
||||
SendMessage(hwnd, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)tchBuf2);
|
||||
}
|
||||
else {
|
||||
UnSlashW(s_tchBuf);
|
||||
SendMessage(hwnd, EM_REPLACESEL, (WPARAM)TRUE, (LPARAM)s_tchBuf);
|
||||
}
|
||||
}
|
||||
@ -5773,6 +5774,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
|
||||
}
|
||||
else {
|
||||
StringCchCopyA(lpszSelection, len + 1, pClip);
|
||||
UnSlashA(lpszSelection, Encoding_SciCP);
|
||||
}
|
||||
}
|
||||
FreeMem(pClip);
|
||||
@ -5980,10 +5982,10 @@ static INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wPara
|
||||
}
|
||||
}
|
||||
else {
|
||||
UnSlash(sg_pefrData->szFind, Encoding_SciCP);
|
||||
UnSlashA(sg_pefrData->szFind, Encoding_SciCP);
|
||||
SetDlgItemTextMB2W(hwnd, IDC_FINDTEXT, sg_pefrData->szFind);
|
||||
if (GetDlgItem(hwnd, IDC_REPLACE)) {
|
||||
UnSlash(sg_pefrData->szReplace, Encoding_SciCP);
|
||||
UnSlashA(sg_pefrData->szReplace, Encoding_SciCP);
|
||||
SetDlgItemTextMB2W(hwnd, IDC_REPLACETEXT, sg_pefrData->szReplace);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1888,11 +1888,11 @@ size_t SlashW(LPWSTR pchOutput, size_t cchOutLen, LPCWSTR pchInput)
|
||||
*
|
||||
* Convert C style \a, \b, \f, \n, \r, \t, \v, \xhh, \uhhhh and \\ into their indicated characters.
|
||||
*/
|
||||
size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
|
||||
size_t UnSlashA(LPSTR pchInOut, UINT cpEdit)
|
||||
{
|
||||
LPSTR s = pchInOut;
|
||||
LPSTR o = pchInOut;
|
||||
LPSTR const sStart = pchInOut;
|
||||
LPCSTR const sStart = pchInOut;
|
||||
|
||||
while (*s) {
|
||||
if (*s == '\\') {
|
||||
@ -1922,22 +1922,22 @@ size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
|
||||
WCHAR val[2] = L"";
|
||||
int hex;
|
||||
val[0] = 0;
|
||||
hex = GetHexDigit(*(s + 1));
|
||||
hex = GetHexDigitA(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val[0] = (WCHAR)hex;
|
||||
hex = GetHexDigit(*(s + 1));
|
||||
hex = GetHexDigitA(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val[0] *= 16;
|
||||
val[0] += (WCHAR)hex;
|
||||
if (!bShort) {
|
||||
hex = GetHexDigit(*(s + 1));
|
||||
hex = GetHexDigitA(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val[0] *= 16;
|
||||
val[0] += (WCHAR)hex;
|
||||
hex = GetHexDigit(*(s + 1));
|
||||
hex = GetHexDigitA(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val[0] *= 16;
|
||||
@ -1978,6 +1978,85 @@ size_t UnSlash(LPSTR pchInOut, UINT cpEdit)
|
||||
return (size_t)((ptrdiff_t)(o - sStart));
|
||||
}
|
||||
|
||||
size_t UnSlashW(LPWSTR pchInOut)
|
||||
{
|
||||
LPWSTR s = pchInOut;
|
||||
LPWSTR o = pchInOut;
|
||||
LPCWSTR const sStart = pchInOut;
|
||||
|
||||
while (*s) {
|
||||
if (*s == '\\') {
|
||||
++s;
|
||||
if (*s == L'a')
|
||||
*o = L'\a';
|
||||
else if (*s == L'b')
|
||||
*o = L'\b';
|
||||
else if (*s == L'e')
|
||||
*o = L'\x1B';
|
||||
else if (*s == L'f')
|
||||
*o = L'\f';
|
||||
else if (*s == L'n')
|
||||
*o = L'\n';
|
||||
else if (*s == L'r')
|
||||
*o = L'\r';
|
||||
else if (*s == L't')
|
||||
*o = L'\t';
|
||||
else if (*s == L'v')
|
||||
*o = L'\v';
|
||||
else if (*s == L'\\')
|
||||
*o = L'\\';
|
||||
else if (*s == L'x' || *s == L'u') {
|
||||
bool bShort = (*s == L'x');
|
||||
WCHAR val = L'\0';
|
||||
int hex = GetHexDigitW(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
val = (WCHAR)hex;
|
||||
hex = GetHexDigitW(*(++s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val *= 16;
|
||||
val += (WCHAR)hex;
|
||||
if (!bShort) {
|
||||
hex = GetHexDigitW(*(s + 1));
|
||||
if (hex >= 0) {
|
||||
val *= 16;
|
||||
val += (WCHAR)hex;
|
||||
hex = GetHexDigitW(*(++s + 1));
|
||||
if (hex >= 0) {
|
||||
++s;
|
||||
val *= 16;
|
||||
val += (WCHAR)hex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (val) {
|
||||
*o = val;
|
||||
}
|
||||
else
|
||||
--o;
|
||||
}
|
||||
else
|
||||
--o;
|
||||
}
|
||||
else {
|
||||
*o = '\\'; // revert
|
||||
*++o = *s;
|
||||
}
|
||||
}
|
||||
else
|
||||
*o = *s;
|
||||
|
||||
++o;
|
||||
if (*s) {
|
||||
++s;
|
||||
}
|
||||
}
|
||||
*o = '\0';
|
||||
return (size_t)((ptrdiff_t)(o - sStart));
|
||||
}
|
||||
|
||||
/**
|
||||
* check, if we have regex sub-group referencing
|
||||
*/
|
||||
@ -2015,7 +2094,7 @@ void TransformBackslashes(char* pszInput, bool bRegEx, UINT cpEdit, int* iReplac
|
||||
// regex handles backslashes itself
|
||||
// except: replacement is not delegated to regex engine
|
||||
if (!bRegEx || (iReplaceMsg && (SCI_REPLACETARGET == *iReplaceMsg))) {
|
||||
UnSlash(pszInput, cpEdit);
|
||||
UnSlashA(pszInput, cpEdit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -355,7 +355,9 @@ UINT CharSetFromCodePage(const UINT uCodePage);
|
||||
size_t SlashA(LPSTR pchOutput, size_t cchOutLen, LPCSTR pchInput);
|
||||
size_t SlashW(LPWSTR pchOutput, size_t cchOutLen, LPCWSTR pchInput);
|
||||
|
||||
size_t UnSlash(LPSTR pchInOut, UINT cpEdit);
|
||||
size_t UnSlashA(LPSTR pchInOut, UINT cpEdit);
|
||||
size_t UnSlashW(LPWSTR pchInOut);
|
||||
|
||||
void TransformBackslashes(char* pszInput, bool, UINT cpEdit, int* iReplaceMsg);
|
||||
void TransformMetaChars(char* pszInput, bool, int iEOLMode);
|
||||
|
||||
@ -541,14 +543,20 @@ __inline bool IsAlphaNumeric(WCHAR ch) {
|
||||
((ch >= L'A') && (ch <= L'Z'));
|
||||
}
|
||||
|
||||
// If the character is an hexa digit, get its value.
|
||||
__inline int GetHexDigit(char ch) {
|
||||
// If the character is an hexadecimal digit, get its value.
|
||||
__inline int GetHexDigitA(char ch) {
|
||||
if (ch >= '0' && ch <= '9') { return ch - '0'; }
|
||||
if (ch >= 'A' && ch <= 'F') { return ch - 'A' + 10; }
|
||||
if (ch >= 'a' && ch <= 'f') { return ch - 'a' + 10; }
|
||||
return -1;
|
||||
}
|
||||
|
||||
__inline int GetHexDigitW(WCHAR ch) {
|
||||
if (ch >= L'0' && ch <= L'9') { return ch - L'0'; }
|
||||
if (ch >= L'A' && ch <= L'F') { return ch - L'A' + 10; }
|
||||
if (ch >= L'a' && ch <= L'f') { return ch - L'a' + 10; }
|
||||
return -1;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void UrlEscapeEx(LPCWSTR lpURL, LPWSTR lpEscaped, DWORD* pcchEscaped, bool bEscReserved);
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
#define SAPPNAME "Notepad3"
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 20
|
||||
#define VERSION_REV 127
|
||||
#define VERSION_BUILD 2715
|
||||
#define VERSION_REV 128
|
||||
#define VERSION_BUILD 2716
|
||||
#define SCINTILLA_VER 430
|
||||
#define ONIGURUMA_REGEX_VER 6.9.4
|
||||
#define UCHARDET_VER 2018.09.27
|
||||
|
||||
Loading…
Reference in New Issue
Block a user