Skip to content

Commit

Permalink
Merge pull request #541 from RaiKoHoff/Dev_0704
Browse files Browse the repository at this point in the history
Fix issue #539
  • Loading branch information
RaiKoHoff committed Jul 9, 2018
2 parents 4960b1d + 5c34fb5 commit e3efa24
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
4 changes: 4 additions & 0 deletions src/Dialogs.c
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/Edit.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
23 changes: 12 additions & 11 deletions src/Notepad3.c
Expand Up @@ -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);

Expand Down Expand Up @@ -6152,7 +6153,6 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)


case SCN_SAVEPOINTREACHED:
SciCall_SetScrollWidth(1);
_SetDocumentModified(false);
break;

Expand Down Expand Up @@ -8882,10 +8882,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;
}
}
Expand Down Expand Up @@ -8993,9 +8993,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
Expand Down Expand Up @@ -9067,6 +9067,7 @@ bool FileSave(bool bSaveAlways,bool bAsk,bool bSaveAs,bool bSaveCopy)
MsgBoxLng(MBWARN,IDS_MUI_ERR_SAVEFILE,tchFile);
}
}
//@@@EditEnsureSelectionVisible(g_hwndEdit);
return(fSuccess);
}

Expand Down
3 changes: 2 additions & 1 deletion src/SciCall.h
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e3efa24

Please sign in to comment.