From 9a724707d4819f0e372d2ebbeef578b4fd9a5742 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 9 Jul 2018 13:08:14 +0200 Subject: [PATCH 1/3] + minor fixes --- src/Edit.c | 8 +++++++- src/Notepad3.c | 22 ++++++++++++---------- src/SciCall.h | 3 ++- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index 830fa3818..5181fb16d 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -1261,7 +1261,7 @@ bool EditSaveFile( // get text cbData = (DWORD)SciCall_GetTextLength(); lpData = AllocMem(cbData + 4, HEAP_ZERO_MEMORY); //fix: +bom - SendMessage(hwnd,SCI_GETTEXT,SizeOfMem(lpData),(LPARAM)lpData); + SciCall_GetText((DocPos)SizeOfMem(lpData), lpData); if (cbData == 0) { bWriteSuccess = SetEndOfFile(hFile); @@ -4371,6 +4371,7 @@ void EditSelectEx(HWND hwnd, DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcA void EditEnsureSelectionVisible(HWND hwnd) { UNUSED(hwnd); + DocPos iAnchorPos = 0; DocPos iCurrentPos = 0; DocPos iAnchorPosVS = -1; @@ -4386,6 +4387,11 @@ void EditEnsureSelectionVisible(HWND hwnd) else { iAnchorPos = SciCall_GetAnchor(); iCurrentPos = SciCall_GetCurrentPos(); + if (SciCall_IsSelectionEmpty()) { + SciCall_ScrollCaret(); + SciCall_ChooseCaretX(); + return; + } } EditSelectEx(hwnd, iAnchorPos, iCurrentPos, iAnchorPosVS, iCurPosVS); } diff --git a/src/Notepad3.c b/src/Notepad3.c index 9297c4567..a54b88a4e 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -1645,13 +1645,14 @@ static void __fastcall _InitializeSciEditCtrl(HWND hwndEditCtrl) #define _CARET_SYMETRY CARET_EVEN /// CARET_EVEN or 0 + #define _CARET_ENFORCE CARET_STRICT /// CARET_STRICT or 0 if (iCurrentLineHorizontalSlop > 0) - SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | CARET_STRICT), iCurrentLineHorizontalSlop); + SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), iCurrentLineHorizontalSlop); else - SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | CARET_STRICT), (LPARAM)0); + SendMessage(hwndEditCtrl, SCI_SETXCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), (LPARAM)0); if (iCurrentLineVerticalSlop > 0) - SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | CARET_STRICT), iCurrentLineVerticalSlop); + SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(CARET_SLOP | _CARET_SYMETRY | _CARET_ENFORCE), iCurrentLineVerticalSlop); else SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(_CARET_SYMETRY), 0); @@ -8882,10 +8883,10 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) if (cchText == 0) bIsEmptyNewFile = true; else if (cchText < 1023) { - char tchText[1024]; - SendMessage(g_hwndEdit,SCI_GETTEXT,(WPARAM)1023,(LPARAM)tchText); - StrTrimA(tchText," \t\n\r"); - if (lstrlenA(tchText) == 0) + char chTextBuf[1024]; + SciCall_GetText(1023, chTextBuf); + StrTrimA(chTextBuf," \t\n\r"); + if (lstrlenA(chTextBuf) == 0) bIsEmptyNewFile = true; } } @@ -8993,9 +8994,9 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) WCHAR wchBookMarks[MRU_BMRK_SIZE] = { L'\0' }; EditGetBookmarkList(g_hwndEdit, wchBookMarks, COUNTOF(wchBookMarks)); MRU_AddFile(g_pFileMRU,g_wchCurFile,g_flagRelativeFileMRU,g_flagPortableMyDocs,iCurrEnc,iCaretPos,wchBookMarks); - if (g_flagUseSystemMRU == 2) - SHAddToRecentDocs(SHARD_PATHW,g_wchCurFile); - + if (g_flagUseSystemMRU == 2) { + SHAddToRecentDocs(SHARD_PATHW, g_wchCurFile); + } _SetDocumentModified(false); // Install watching of the current file @@ -9067,6 +9068,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy) MsgBoxLng(MBWARN,IDS_MUI_ERR_SAVEFILE,tchFile); } } + //@@@EditEnsureSelectionVisible(g_hwndEdit); return(fSuccess); } diff --git a/src/SciCall.h b/src/SciCall.h index 9aebf496b..8e680cb66 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -77,7 +77,7 @@ extern HANDLE g_hwndEdit; #ifdef SCI_DIRECTFUNCTION_INTERFACE LRESULT WINAPI Scintilla_DirectFunction(HANDLE, UINT, WPARAM, LPARAM); -#define SciCall(m, w, l) Scintilla_DirectFunction(g_hScintilla, m, w, l) +#define SciCall(m, w, l) Scintilla_DirectFunction(g_hScintilla, (m), (w), (l)) #else @@ -257,6 +257,7 @@ DeclareSciCallV1(SetEndAtLastLine, SETENDATLASTLINE, bool, flag) DeclareSciCallR0(GetXoffset, GETXOFFSET, int) DeclareSciCallV1(SetXoffset, SETXOFFSET, int, offset) DeclareSciCallV2(SetVisiblePolicy, SETVISIBLEPOLICY, int, flags, DocLn, lines) +DeclareSciCallV0(MoveCaretInsideView, MOVECARETINSIDEVIEW) DeclareSciCallR0(LinesOnScreen, LINESONSCREEN, DocLn) DeclareSciCallR0(GetFirstVisibleLine, GETFIRSTVISIBLELINE, DocLn) From 27722889b68451106790ecc0145b36d978085c40 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 9 Jul 2018 14:03:02 +0200 Subject: [PATCH 2/3] + add: translation author added to "copy version text" --- src/Dialogs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Dialogs.c b/src/Dialogs.c index 30e4cb8f2..60e25a7fc 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -631,9 +631,13 @@ INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam case IDC_COPYVERSTRG: { WCHAR wchVerInfo[1024] = { L'\0' }; + WCHAR wchAuthInfo[128] = { L'\0' }; StringCchCopy(wchVerInfo, COUNTOF(wchVerInfo), L"" VERSION_FILEVERSION_LONG); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_SCIVERSION); StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n" VERSION_COMPILER); + StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), L"\n"); + GetLngString(IDS_MUI_TRANSL_AUTHOR, wchAuthInfo, COUNTOF(wchAuthInfo)); + StringCchCat(wchVerInfo, COUNTOF(wchVerInfo), wchAuthInfo); SetClipboardTextW(g_hwndMain, wchVerInfo); } break; From 5c34fb50b68112284726abc7dfb04e8cbdc07c00 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Mon, 9 Jul 2018 14:23:17 +0200 Subject: [PATCH 3/3] + fix: don't reset scroll-width tracking on saving file (fix for issue #539) --- src/Notepad3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index a54b88a4e..688e71c12 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -6153,7 +6153,6 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) case SCN_SAVEPOINTREACHED: - SciCall_SetScrollWidth(1); _SetDocumentModified(false); break;