From 632621cebb502e0a8059df6c7580d03593ea49b7 Mon Sep 17 00:00:00 2001 From: Pairi Daiza Date: Fri, 26 Feb 2021 09:31:39 +0100 Subject: [PATCH 1/2] + Upd: Version files and Changes.txt --- Build/Changes.txt | 15 +++------------ Build/Docs/KeyboardShortcuts.txt | 8 ++++---- Versions/day.txt | 2 +- res/Notepad3.exe.manifest.conf | 2 +- src/VersionEx.h | 2 +- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/Build/Changes.txt b/Build/Changes.txt index d503587c7..9d5764f17 100644 --- a/Build/Changes.txt +++ b/Build/Changes.txt @@ -32,7 +32,7 @@ UCD - (UCD)ARDET is an Encoding Detector Library ======================================================== -Current BETA/RC Version 5.21.223.(build_#) (2021-02-23) +Current BETA/RC Version 5.21.226.(build_#) (2021-02-26) ======================================================== -------------------------------------------------------- @@ -60,7 +60,7 @@ NEW: [.915.2]- Configurable Dark Mode colors (non Explorer-Theme, Owner-Drawn). [.915.2]- Menu item to switch between Default and Dark-Mode. [.915.2]- DarkMode: Toolbar, static checkbox/listbox control. -[.915.2]- Win10 DarkMode Awareness (initial development) +[.915.2]- Win10 DarkMode Awareness (initial development). -------------------------------------------------------- CHANGES: @@ -105,6 +105,7 @@ CHANGES: -------------------------------------------------------- FIXES: -------------------------------------------------------- +[.226.1]- Wrap-Around tooltip use correct encoding. [.222.2]- Multi-Line movement: proceed to document end correctly. [.222.2]- Toggle comment on empty selection at insertion point: keep position of selection end. [.222.2]- MiniPath: Enable Mouse XButton usage ("browse back and forth"). @@ -181,10 +182,6 @@ REMOVED: TRANSLATIONS (MUI): -------------------------------------------------------- [1028.1]- Hindi (hi-IN). -[.915.2]- Chinese Traditional (zh-TW) in waiting... -[.915.2]- Indonesian (id-ID) in waiting... -[.915.2]- Turkish (tr-TR) in waiting... -[.915.2]- Vietnamese (vi-VN) in waiting... ======================================================== @@ -313,12 +310,6 @@ REMOVED: -------------------------------------------------------- TRANSLATIONS (MUI): -------------------------------------------------------- -[.802.1]- Portuguese Brazilian (pt-BR). -[.722.2]- Turkish (tr-TR) in processing... -[.722.2]- Chinese Traditional (zh-TW) in waiting... -[.722.2]- Hindi (hi-IN) in waiting... -[.722.2]- Indonesian (id-ID) in waiting... -[.722.2]- Vietnamese (vi-VN) in waiting... ======================================================== diff --git a/Build/Docs/KeyboardShortcuts.txt b/Build/Docs/KeyboardShortcuts.txt index 9d4bbdec7..6567a1871 100644 --- a/Build/Docs/KeyboardShortcuts.txt +++ b/Build/Docs/KeyboardShortcuts.txt @@ -111,8 +111,8 @@ Selection --------- - Ctrl+, Jump to Selection Start. - Ctrl+. Jump to Selection End. + Ctrl+Q Block Comment (Toggle). + Ctrl+Shift+Q Stream Comment. Ctrl+D Duplicate Selection or Line. Alt+B Pad with Blanks. Alt+Z Strip First Character. @@ -122,6 +122,8 @@ Alt+M Modify Lines... Alt+J Align Lines... Alt+O Sort Lines... + Ctrl+, Jump to Selection Start. + Ctrl+. Jump to Selection End. Tab Indent Selected Block. Shift+Tab Unindent Selected Block. Ctrl+Tab Insert Tabulator. @@ -161,8 +163,6 @@ Ctrl+F5 Time/Date (Short Form). Ctrl+Shift+F5 Time/Date (Long Form). Shift+F5 Update Timestamps. - Ctrl+Q Block Comment (Toggle). - Ctrl+Shift+Q Stream Comment. Miscellaneous ------------- diff --git a/Versions/day.txt b/Versions/day.txt index 5f277ae78..f4146713e 100644 --- a/Versions/day.txt +++ b/Versions/day.txt @@ -1 +1 @@ -223 +226 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index c5e7ea02c..ad688e444 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 rc diff --git a/src/VersionEx.h b/src/VersionEx.h index ce2afc0b6..ad78acc53 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -8,7 +8,7 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 21 -#define VERSION_REV 223 +#define VERSION_REV 226 #define VERSION_BUILD 1 #define SCINTILLA_VER 446 #define ONIGURUMA_REGEX_VER 6.9.6 From 8ae995029213b1dcb1dcc4380c0972c9d27c2b62 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Fri, 26 Feb 2021 14:48:52 +0100 Subject: [PATCH 2/2] + fix: URL-Decoding of file Hyperlinks ("file://...") --- src/Helpers.h | 34 +++++++++++++++++++ src/Notepad3.c | 91 +++++++++++++++++++++++++++++++------------------- 2 files changed, 91 insertions(+), 34 deletions(-) diff --git a/src/Helpers.h b/src/Helpers.h index 991944b1a..527570351 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -642,6 +642,40 @@ inline WCHAR* StrEndW(const WCHAR* pStart, size_t siz) #define StrEnd(s,n) StrEndA((s),(n)) #endif +// ---------------------------------------------------------------------------- + +#if 0 + +inline void StrReplChrA(CHAR* pStrg, const CHAR chSearch, const CHAR chReplace) +{ + while (pStrg && *pStrg) { + if (*pStrg == chSearch) { + *pStrg = chReplace; + } + ++pStrg; + } +} + +inline void StrReplChrW(WCHAR* pStrg, const WCHAR chSearch, const WCHAR chReplace) +{ + while (pStrg && *pStrg) { + if (*pStrg == chSearch) { + *pStrg = chReplace; + } + ++pStrg; + } +} + +#if defined(UNICODE) || defined(_UNICODE) +#define StrReplChr(str, cs, cr) StrReplChrW((str), (cs), (cr)) +#else +#define StrReplChr(str, cs, cr) StrReplChrA((str), (cs), (cr)) +#endif + +#endif + +// ---------------------------------------------------------------------------- + //==== StrSafe lstrcmp(),lstrcmpi() ============================================= // NOTE: !!! differences in AutoCompleteList depending compare functions (CRT vs. Shlwapi)) !!! diff --git a/src/Notepad3.c b/src/Notepad3.c index 9efec6e32..4c9990711 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -7064,6 +7064,7 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio bool bHandled = false; if (SciCall_IndicatorValueAt(INDIC_NP3_HYPERLINK, position)) { + DocPos const firstPos = SciCall_IndicatorStart(INDIC_NP3_HYPERLINK, position); DocPos const lastPos = SciCall_IndicatorEnd(INDIC_NP3_HYPERLINK, position); DocPos const length = min_p(lastPos - firstPos, INTERNET_MAX_URL_LENGTH); @@ -7072,14 +7073,15 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio return false; } - const char* pszText = (const char*)SciCall_GetRangePointer(firstPos, length); + const char *pszText = (const char *)SciCall_GetRangePointer(firstPos, length); WCHAR szTextW[INTERNET_MAX_URL_LENGTH + 1]; ptrdiff_t const cchTextW = MultiByteToWideChar(Encoding_SciCP, 0, pszText, (int)length, szTextW, COUNTOF(szTextW)); szTextW[cchTextW] = L'\0'; StrTrim(szTextW, L" \r\n\t"); - const WCHAR* chkPreFix = L"file://"; + const WCHAR *chkPreFix = L"file://"; + size_t const lenPfx = StringCchLenW(chkPreFix, 0); if (operation & SELECT_HYPERLINK) { SciCall_SetSelection(firstPos, lastPos); @@ -7096,42 +7098,63 @@ bool HandleHotSpotURLClicked(const DocPos position, const HYPERLINK_OPS operatio bHandled = true; } } - } else if ((operation & OPEN_WITH_NOTEPAD3) && (StrStrI(szTextW, chkPreFix) == szTextW)) { - size_t const lenPfx = StringCchLenW(chkPreFix, 0); - WCHAR* szFileName = &(szTextW[lenPfx]); - szTextW[lenPfx + MAX_PATH] = L'\0'; // limit length - StrTrim(szFileName, L"/"); - PathCanonicalizeEx(szFileName, (DWORD)(COUNTOF(szTextW) - lenPfx)); - if (PathIsDirectory(szFileName)) { - WCHAR tchFile[MAX_PATH] = { L'\0' }; - if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szFileName)) { - FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, tchFile); + } else { + + bool const isFileUrl = (StrStrI(szTextW, chkPreFix) == szTextW); + + WCHAR szUnEscW[INTERNET_MAX_URL_LENGTH + 1]; + DWORD dCchUnEsc = COUNTOF(szUnEscW); + UrlUnescapeEx(szTextW, szUnEscW, &dCchUnEsc); + + if ((operation & OPEN_WITH_NOTEPAD3) && isFileUrl) { + + WCHAR *const szFileName = &(szUnEscW[lenPfx]); + szUnEscW[min_i(MAX_PATH, INTERNET_MAX_URL_LENGTH)] = L'\0'; // limit length + StrTrim(szFileName, L"/"); + + PathCanonicalizeEx(szFileName, (DWORD)(COUNTOF(szUnEscW) - lenPfx)); + if (PathIsDirectory(szFileName)) { + WCHAR tchFile[MAX_PATH] = { L'\0' }; + if (OpenFileDlg(Globals.hwndMain, tchFile, COUNTOF(tchFile), szFileName)) { + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, tchFile); + } + } else { + FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, szFileName); } - } else { - FileLoad(false, false, false, Settings.SkipUnicodeDetection, Settings.SkipANSICodePageDetection, false, szFileName); - } - bHandled = true; - } else if (operation & OPEN_WITH_BROWSER) { // open in web browser - WCHAR wchDirectory[MAX_PATH] = { L'\0' }; - if (StrIsNotEmpty(Globals.CurrentFile)) { - StringCchCopy(wchDirectory, COUNTOF(wchDirectory), Globals.CurrentFile); - PathCchRemoveFileSpec(wchDirectory, COUNTOF(wchDirectory)); - } + bHandled = true; - SHELLEXECUTEINFO sei; - ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); - sei.cbSize = sizeof(SHELLEXECUTEINFO); - sei.fMask = SEE_MASK_NOZONECHECKS; - sei.hwnd = NULL; - sei.lpVerb = NULL; - sei.lpFile = szTextW; - sei.lpParameters = NULL; - sei.lpDirectory = wchDirectory; - sei.nShow = SW_SHOWNORMAL; - ShellExecuteEx(&sei); + } else if (operation & OPEN_WITH_BROWSER) { // open in web browser - bHandled = true; + if (isFileUrl) { + WCHAR *const szFileName = &(szUnEscW[lenPfx]); + dCchUnEsc = COUNTOF(szTextW); + UrlCreateFromPath(szFileName, szTextW, &dCchUnEsc, 0); + //~StringCchCopy(szUnEscW, COUNTOF(szUnEscW), L"http://"); + //~StringCchCat(szUnEscW, COUNTOF(szUnEscW), &(szTextW[lenPfx])); + StringCchCopy(szUnEscW, COUNTOF(szUnEscW), szTextW); + } + + WCHAR wchDirectory[MAX_PATH] = { L'\0' }; + if (StrIsNotEmpty(Globals.CurrentFile)) { + StringCchCopy(wchDirectory, COUNTOF(wchDirectory), Globals.CurrentFile); + PathCchRemoveFileSpec(wchDirectory, COUNTOF(wchDirectory)); + } + + SHELLEXECUTEINFO sei; + ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); + sei.cbSize = sizeof(SHELLEXECUTEINFO); + sei.fMask = SEE_MASK_NOZONECHECKS; + sei.hwnd = NULL; + sei.lpVerb = NULL; + sei.lpFile = szUnEscW; + sei.lpParameters = NULL; + sei.lpDirectory = wchDirectory; + sei.nShow = SW_SHOWNORMAL; + ShellExecuteEx(&sei); + + bHandled = true; + } } }