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/Versions/day.txt b/Versions/day.txt index 9b5c4542c..18eed1357 100644 --- a/Versions/day.txt +++ b/Versions/day.txt @@ -1 +1 @@ -319 +320 diff --git a/language/np3_it_it/strings_it_it.rc b/language/np3_it_it/strings_it_it.rc index dac3afe2e..edbc7a2e5 100644 --- a/language/np3_it_it/strings_it_it.rc +++ b/language/np3_it_it/strings_it_it.rc @@ -278,7 +278,7 @@ Opzioni:\r\n\ /n\tApri sempre una nuova finestra (/ns istanza singola).\r\n\ /r\tRiutilizza finestra (/rs istanza singola).\r\n\ /p\tImposta posizione e dimensione della finestra (/p0, /ps, /pf,l,t,r,b,m)\r\n\ -\tor /p ,,,, [all integers].\r\n\ +\tor /p ,,,, [numeri interi].\r\n\ /t\tImposta titolo della finestra.\r\n\ /i\tAvvia come icona nella Tray.\r\n\ /o\tMantieni finestra in primo piano.\r\n\ diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index eeb8c94da..2a86c5835 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 ac0acd065..fb8818f3b 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -694,6 +694,7 @@ extern "C" bool FindIniFile() WCHAR tchModule[MAX_PATH] = { L'\0' }; GetModuleFileName(NULL, tchModule, COUNTOF(tchModule)); + PathCanonicalizeEx(tchModule, COUNTOF(tchModule)); // set env path to module dir StringCchCopy(tchPath, COUNTOF(tchPath), tchModule); diff --git a/src/Dialogs.c b/src/Dialogs.c index 7605f1de0..57089e90e 100644 --- a/src/Dialogs.c +++ b/src/Dialogs.c @@ -993,6 +993,7 @@ static INT_PTR CALLBACK RunDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM l if (StringCchCompareNI(arg1, COUNTOF(arg1), _W(SAPPNAME), CSTRLEN(_W(SAPPNAME))) == 0 || StringCchCompareNI(arg1, COUNTOF(arg1), L"notepad3.exe", CSTRLEN(L"notepad3.exe")) == 0) { GetModuleFileName(NULL, arg1, COUNTOF(arg1)); + PathCanonicalizeEx(arg1, COUNTOF(arg1)); bQuickExit = true; } @@ -3398,9 +3399,7 @@ void DialogFileBrowse(HWND hwnd) StringCchCopy(tchExeFile, COUNTOF(tchExeFile), Constants.FileBrowserMiniPath); } if (PathIsRelative(tchExeFile)) { - GetModuleFileName(NULL, tchTemp, COUNTOF(tchTemp)); - NormalizePathEx(tchTemp, COUNTOF(tchTemp), true, false); - PathCchRemoveFileSpec(tchTemp, COUNTOF(tchTemp)); + PathGetAppDirectory(tchTemp, COUNTOF(tchTemp)); PathAppend(tchTemp, tchExeFile); if (PathFileExists(tchTemp)) { StringCchCopy(tchExeFile, COUNTOF(tchExeFile), tchTemp); @@ -3476,7 +3475,7 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern) const WCHAR* const tchParamFmt = L"/portable /content %s /searchpath:\"%s\" /searchfor:\"%s\""; GetModuleFileName(NULL, tchModulePath, COUNTOF(tchModulePath)); - NormalizePathEx(tchModulePath, COUNTOF(tchModulePath), true, false); + PathCanonicalizeEx(tchModulePath, COUNTOF(tchModulePath)); // grepWin executable if (StrIsNotEmpty(Settings2.GrepWinPath)) { @@ -3499,7 +3498,9 @@ void DialogGrepWin(HWND hwnd, LPCWSTR searchPattern) StringCchCopy(tchGrepWinDir, COUNTOF(tchGrepWinDir), tchExeFile); PathCchRemoveFileSpec(tchGrepWinDir, COUNTOF(tchGrepWinDir)); // relative Notepad3 path (for grepWin's EditorCmd) - PathRelativePathTo(tchModulePath, tchGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, tchModulePath, FILE_ATTRIBUTE_NORMAL); + if (PathRelativePathToW(tchTemp, tchGrepWinDir, FILE_ATTRIBUTE_DIRECTORY, tchModulePath, FILE_ATTRIBUTE_NORMAL)) { + StringCchCopy(tchModulePath, COUNTOF(tchModulePath), tchTemp); + } // grepWin INI-File StringCchCopy(tchIniFilePath, COUNTOF(tchIniFilePath), tchGrepWinDir); PathAppend(tchIniFilePath, L"grepwin.ini"); @@ -3570,8 +3571,7 @@ void DialogAdminExe(HWND hwnd, bool bExecInstaller) WCHAR tchExePath[MAX_PATH]; if (!SearchPath(NULL, tchExe, L".exe", COUNTOF(tchExePath), tchExePath, NULL)) { // try Notepad3's dir path - GetModuleFileName(NULL, tchExePath, COUNTOF(tchExePath)); - PathCchRemoveFileSpec(tchExePath, COUNTOF(tchExePath)); + PathGetAppDirectory(tchExePath, COUNTOF(tchExePath)); PathCchAppend(tchExePath, COUNTOF(tchExePath), tchExe); } diff --git a/src/Edit.c b/src/Edit.c index 17ddbfa1d..3a747c918 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4794,14 +4794,11 @@ void EditSetSelectionEx(DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcAnchor if (vSpcCurrent > 0) { SciCall_SetRectangularSelectionCaretVirtualSpace(vSpcCurrent); } - SciCall_ScrollRange(iAnchorPos, iCurrentPos); } else { SciCall_SetSel(iAnchorPos, iCurrentPos); // scrolls into view } - - // remember x-pos for moving caret vertically - SciCall_ChooseCaretX(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } //~~~_END_UNDO_ACTION_;~~~ @@ -4820,6 +4817,21 @@ void EditEnsureConsistentLineEndings(HWND hwnd) } +//============================================================================= +// +// EditScrollToLine() - normalize View +// +void EditScrollToLine(const DocLn iDocLine) +{ + if (iDocLine == Sci_GetCurrentLineNumber()) { + Sci_ScrollChooseCaret(); + } + //~Sci_ScrollToLine(iDocLine); + DocLn const vSlop = max_ln(2, Settings2.CurrentLineVerticalSlop); + SciCall_SetFirstVisibleLine(clampp((iDocLine - vSlop), 0, Sci_GetLastDocLineNumber())); +} + + //============================================================================= // // EditEnsureSelectionVisible() @@ -4834,7 +4846,7 @@ void EditEnsureSelectionVisible() SciCall_EnsureVisible(iAnchorLine); if (iAnchorLine != iCurrentLine) { SciCall_EnsureVisible(iCurrentLine); } - Sci_ScrollToLine(iCurrentLine, true); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } @@ -4842,66 +4854,25 @@ void EditEnsureSelectionVisible() // // EditJumpTo() // -void EditJumpTo(HWND hwnd, DocLn iNewLine, DocPos iNewCol) +void EditJumpTo(DocLn iNewLine, DocPos iNewCol) { - UNUSED(hwnd); // jump to end with line set to -1 if (iNewLine < 0) { SciCall_DocumentEnd(); return; } - const DocLn iMaxLine = SciCall_GetLineCount(); + DocLn const iMaxLine = SciCall_GetLineCount(); // Line maximum is iMaxLine - 1 (doc line count starts with 0) iNewLine = (min_ln(iNewLine, iMaxLine) - 1); - const DocPos iLineEndPos = SciCall_GetLineEndPosition(iNewLine); + DocPos const iLineEndPos = SciCall_GetLineEndPosition(iNewLine); // Column minimum is 1 DocPos const colOffset = Globals.bZeroBasedColumnIndex ? 0 : 1; - iNewCol = max_p(0, min_p((iNewCol - colOffset), iLineEndPos)); + iNewCol = clampp((iNewCol - colOffset), 0, iLineEndPos); const DocPos iNewPos = SciCall_FindColumn(iNewLine, iNewCol); SciCall_GotoPos(iNewPos); - Sci_ScrollToLine(iNewLine, true); - - // remember x-pos for moving caret vertically - SciCall_ChooseCaretX(); -} - - - -//============================================================================= -// -// EditGetCurrentDocView() -// -const DOCVIEWPOS_T EditGetCurrentDocView(HWND hwnd) -{ - UNUSED(hwnd); - DOCVIEWPOS_T docView = INIT_DOCVIEWPOS; - docView.iCurPos = Sci_IsMultiOrRectangleSelection() ? SciCall_GetSelectionNCaret(0) : SciCall_GetCurrentPos(); - docView.iAnchorPos = Sci_IsMultiOrRectangleSelection() ? SciCall_GetSelectionNAnchor(SciCall_GetSelections() - 1) : SciCall_GetAnchor(); - //docView.vSpcCaretPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionCaretVirtualSpace() : -1; - //docView.vSpcAnchorPos = SciCall_IsSelectionRectangle() ? SciCall_GetRectangularSelectionAnchorVirtualSpace() : -1; - docView.iCurrLine = SciCall_LineFromPosition(docView.iCurPos); - docView.iCurColumn = SciCall_GetColumn(docView.iCurPos); - docView.iVisTopLine = SciCall_GetFirstVisibleLine(); - docView.iDocTopLine = SciCall_DocLineFromVisible(docView.iVisTopLine); - docView.iXOffset = SciCall_GetXOffset(); - docView.bIsTail = (docView.iCurPos == docView.iAnchorPos) && (docView.iCurrLine >= (SciCall_GetLineCount() - 1)); - return docView; -} - - -//============================================================================= -// -// EditSetDocView() -// -void EditSetDocView(HWND hwnd, const DOCVIEWPOS_T docView) -{ - EditJumpTo(hwnd, docView.iCurrLine + 1, docView.iCurColumn + 1); - DocLn const iNewTopLine = SciCall_GetFirstVisibleLine(); - SciCall_EnsureVisible(iNewTopLine); - SciCall_LineScroll(0, docView.iVisTopLine - iNewTopLine); - SciCall_SetXOffset(docView.iXOffset); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } @@ -6663,12 +6634,8 @@ void EditSelectionMultiSelectAll() DocPos const iMainCaret = SciCall_GetSelectionNCaret(0); if (iMainAnchor > iMainCaret) { SciCall_SwapMainAnchorCaret(); - SciCall_ScrollRange(iMainCaret, iMainAnchor); } - else { - SciCall_ScrollRange(iMainAnchor, iMainCaret); - } - SciCall_ChooseCaretX(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view SciCall_SetTargetRange(saveTargetBeg, saveTargetEnd); //restore } @@ -6983,11 +6950,11 @@ void EditToggleView(HWND hwnd) EditHideNotMarkedLineRange(hwnd, FocusedView.HideNonMatchedLines); if (FocusedView.HideNonMatchedLines) { - Sci_ScrollToLine(0, false); + EditScrollToLine(0); SciCall_SetReadOnly(true); } else { - Sci_ScrollToLine(Sci_GetCurrentLineNumber(), true); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view SciCall_SetReadOnly(false); } @@ -7727,7 +7694,7 @@ static INT_PTR CALLBACK EditLinenumDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPA if ((iNewLine > 0) && (iNewLine <= iMaxLnNum) && (iNewCol > 0)) { - EditJumpTo(Globals.hwndEdit, iNewLine, iNewCol); + EditJumpTo(iNewLine, iNewCol); EndDialog(hwnd, IDOK); } else { @@ -8706,7 +8673,7 @@ void EditFoldClick(DocLn ln, int mode) EditFoldPerformAction(ln, mode, SNIFF); if (fGotoFoldPoint) { - EditJumpTo(Globals.hwndEdit, ln + 1, 0); + EditJumpTo(ln + 1, 0); } } @@ -8725,7 +8692,7 @@ void EditFoldCmdKey(FOLD_MOVE move, FOLD_ACTION action) { if ((SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) && SciCall_GetLineVisible(ln)) { - EditJumpTo(Globals.hwndEdit, ln + 1, 0); + EditJumpTo(ln + 1, 0); return; } } @@ -8736,7 +8703,7 @@ void EditFoldCmdKey(FOLD_MOVE move, FOLD_ACTION action) { if ((SciCall_GetFoldLevel(ln) & SC_FOLDLEVELHEADERFLAG) && SciCall_GetLineVisible(ln)) { - EditJumpTo(Globals.hwndEdit, ln + 1, 0); + EditJumpTo(ln + 1, 0); return; } } diff --git a/src/Edit.h b/src/Edit.h index 6e34796d9..f4428da27 100644 --- a/src/Edit.h +++ b/src/Edit.h @@ -80,11 +80,10 @@ void EditSplitLines(HWND hwnd); void EditJoinLinesEx(bool,bool); void EditSortLines(HWND hwnd,int iSortFlags); -void EditJumpTo(HWND hwnd, DocLn iNewLine, DocPos iNewCol); -const DOCVIEWPOS_T EditGetCurrentDocView(HWND hwnd); -void EditSetDocView(HWND hwnd, const DOCVIEWPOS_T docView); +void EditJumpTo(DocLn iNewLine, DocPos iNewCol); void EditSetSelectionEx(DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcAnchor, DocPos vSpcCurrent); void EditFixPositions(); +void EditScrollToLine(const DocLn iDocLine); void EditEnsureSelectionVisible(); void EditEnsureConsistentLineEndings(HWND hwnd); void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt); diff --git a/src/Helpers.c b/src/Helpers.c index 3a541b739..1f70b58de 100644 --- a/src/Helpers.c +++ b/src/Helpers.c @@ -790,6 +790,19 @@ bool GetKnownFolderPath(REFKNOWNFOLDERID rfid, LPWSTR lpOutPath, size_t cchCount return false; } + +//============================================================================= +// +// PathGetModuleDirectory() +// +void PathGetAppDirectory(LPWSTR lpszDest, DWORD cchDest) +{ + GetModuleFileName(NULL, lpszDest, cchDest); + PathCanonicalizeEx(lpszDest, cchDest); + PathCchRemoveFileSpec(lpszDest, (size_t)cchDest); +} + + //============================================================================= // // PathRelativeToApp() @@ -798,47 +811,52 @@ void PathRelativeToApp( LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool bSrcIsFile, bool bUnexpandEnv,bool bUnexpandMyDocs) { - WCHAR wchAppPath[MAX_PATH] = { L'\0' }; + WCHAR wchAppDir[MAX_PATH] = { L'\0' }; WCHAR wchWinDir[MAX_PATH] = { L'\0' }; WCHAR wchUserFiles[MAX_PATH] = { L'\0' }; WCHAR wchPath[MAX_PATH] = { L'\0' }; WCHAR wchResult[MAX_PATH] = { L'\0' }; - DWORD dwAttrTo = (bSrcIsFile) ? 0 : FILE_ATTRIBUTE_DIRECTORY; + DWORD dwAttrTo = (bSrcIsFile) ? FILE_ATTRIBUTE_NORMAL : FILE_ATTRIBUTE_DIRECTORY; + + PathGetAppDirectory(wchAppDir, COUNTOF(wchAppDir)); - GetModuleFileName(NULL,wchAppPath,COUNTOF(wchAppPath)); - PathCanonicalizeEx(wchAppPath,MAX_PATH); - PathCchRemoveFileSpec(wchAppPath,COUNTOF(wchAppPath)); (void)GetWindowsDirectory(wchWinDir,COUNTOF(wchWinDir)); GetKnownFolderPath(&FOLDERID_Documents, wchUserFiles, COUNTOF(wchUserFiles)); if (bUnexpandMyDocs && !PathIsRelative(lpszSrc) && - !PathIsPrefix(wchUserFiles,wchAppPath) && + !PathIsPrefix(wchUserFiles,wchAppDir) && PathIsPrefix(wchUserFiles,lpszSrc) && - PathRelativePathTo(wchPath,wchUserFiles,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) { + PathRelativePathTo(wchPath,wchUserFiles,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) + { StringCchCopy(wchUserFiles,COUNTOF(wchUserFiles),L"%CSIDL:MYDOCUMENTS%"); PathCchAppend(wchUserFiles,COUNTOF(wchUserFiles),wchPath); StringCchCopy(wchPath,COUNTOF(wchPath),wchUserFiles); } - else if (PathIsRelative(lpszSrc) || PathCommonPrefix(wchAppPath,wchWinDir,NULL)) - StringCchCopyN(wchPath,COUNTOF(wchPath),lpszSrc,COUNTOF(wchPath)); + else if (PathIsRelative(lpszSrc) || PathCommonPrefix(wchAppDir, wchWinDir, NULL)) { + StringCchCopyN(wchPath, COUNTOF(wchPath), lpszSrc, COUNTOF(wchPath)); + } else { - if (!PathRelativePathTo(wchPath,wchAppPath,FILE_ATTRIBUTE_DIRECTORY,lpszSrc,dwAttrTo)) - StringCchCopyN(wchPath,COUNTOF(wchPath),lpszSrc,COUNTOF(wchPath)); + if (!PathRelativePathTo(wchPath, wchAppDir, FILE_ATTRIBUTE_DIRECTORY, lpszSrc, dwAttrTo)) { + StringCchCopyN(wchPath, COUNTOF(wchPath), lpszSrc, COUNTOF(wchPath)); + } } if (bUnexpandEnv) { - if (!PathUnExpandEnvStrings(wchPath,wchResult,COUNTOF(wchResult))) - StringCchCopyN(wchResult,COUNTOF(wchResult),wchPath,COUNTOF(wchResult)); + if (!PathUnExpandEnvStrings(wchPath, wchResult, COUNTOF(wchResult))) { + StringCchCopyN(wchResult, COUNTOF(wchResult), wchPath, COUNTOF(wchResult)); + } + } + else { + StringCchCopyN(wchResult, COUNTOF(wchResult), wchPath, COUNTOF(wchResult)); } - else - StringCchCopyN(wchResult,COUNTOF(wchResult),wchPath,COUNTOF(wchResult)); - int cchLen = (cchDest == 0) ? MAX_PATH : cchDest; - if (lpszDest == NULL || lpszSrc == lpszDest) - StringCchCopyN(lpszSrc,cchLen,wchResult,cchLen); - else - StringCchCopyN(lpszDest,cchLen,wchResult,cchLen); + if (lpszDest == NULL || lpszSrc == lpszDest) { + StringCchCopyN(lpszSrc, cchLen, wchResult, cchLen); + } + else { + StringCchCopyN(lpszDest, cchLen, wchResult, cchLen); + } } @@ -870,9 +888,7 @@ void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool bExpand ExpandEnvironmentStringsEx(wchPath,COUNTOF(wchPath)); if (PathIsRelative(wchPath)) { - GetModuleFileName(NULL,wchResult,COUNTOF(wchResult)); - PathCanonicalizeEx(wchResult, COUNTOF(wchResult)); - PathCchRemoveFileSpec(wchResult, COUNTOF(wchResult)); + PathGetAppDirectory(wchResult, COUNTOF(wchResult)); PathCchAppend(wchResult,COUNTOF(wchResult),wchPath); } else @@ -1004,7 +1020,6 @@ bool PathIsLnkToDirectory(LPCWSTR pszPath,LPWSTR pszResPath,int cchResPath) // bool PathCreateDeskLnk(LPCWSTR pszDocument) { - WCHAR tchExeFile[MAX_PATH] = { L'\0' }; WCHAR tchDocTemp[MAX_PATH] = { L'\0' }; WCHAR tchArguments[MAX_PATH+16] = { L'\0' }; @@ -1021,6 +1036,7 @@ bool PathCreateDeskLnk(LPCWSTR pszDocument) // init strings GetModuleFileName(NULL,tchExeFile,COUNTOF(tchExeFile)); + PathCanonicalizeEx(tchExeFile, COUNTOF(tchExeFile)); StringCchCopy(tchDocTemp,COUNTOF(tchDocTemp),pszDocument); PathQuoteSpaces(tchDocTemp); diff --git a/src/Helpers.h b/src/Helpers.h index b12b8ffaa..f1094bee3 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -280,6 +280,7 @@ inline bool IsButtonUnchecked(HWND hwnd, int iButtonID) { return (IsDlgButtonChe bool ReadFileXL(HANDLE hFile, char* const lpBuffer, const size_t nNumberOfBytesToRead, size_t* const lpNumberOfBytesRead); bool WriteFileXL(HANDLE hFile, const char* const lpBuffer, const size_t nNumberOfBytesToWrite, size_t* const lpNumberOfBytesWritten); +void PathGetAppDirectory(LPWSTR lpszDest, DWORD cchDest); bool GetKnownFolderPath(REFKNOWNFOLDERID, LPWSTR lpOutPath, size_t cchCount); void PathRelativeToApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool,bool,bool); void PathAbsoluteFromApp(LPWSTR lpszSrc,LPWSTR lpszDest,int cchDest,bool); diff --git a/src/Notepad3.c b/src/Notepad3.c index 41bea84b7..5f3712747 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -810,10 +810,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, Globals.hPrevInst = hPrevInstance; Globals.hndlProcessHeap = GetProcessHeap(); - WCHAR wchAppDir[2 * MAX_PATH + 4] = { L'\0' }; - GetModuleFileName(NULL,wchAppDir,COUNTOF(wchAppDir)); - PathCchRemoveFileSpec(wchAppDir, COUNTOF(wchAppDir)); - PathCanonicalizeEx(wchAppDir,COUNTOF(wchAppDir)); + WCHAR wchAppDir[MAX_PATH] = { L'\0' }; + PathGetAppDirectory(wchAppDir, COUNTOF(wchAppDir)); if (!GetCurrentDirectory(COUNTOF(Globals.WorkingDirectory),Globals.WorkingDirectory)) { StringCchCopy(Globals.WorkingDirectory,COUNTOF(Globals.WorkingDirectory),wchAppDir); @@ -1262,7 +1260,7 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow) } } if (s_flagJumpTo) { // Jump to position - EditJumpTo(Globals.hwndEdit,s_iInitialLine,s_iInitialColumn); + EditJumpTo(s_iInitialLine,s_iInitialColumn); } } } @@ -1319,7 +1317,7 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow) if (SciCall_CanPaste()) { bool bAutoIndent2 = Settings.AutoIndent; Settings.AutoIndent = 0; - EditJumpTo(Globals.hwndEdit, -1, 0); + EditJumpTo(-1, 0); _BEGIN_UNDO_ACTION_; if (!Sci_IsDocEmpty()) { SciCall_NewLine(); @@ -1329,7 +1327,7 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow) _END_UNDO_ACTION_; Settings.AutoIndent = bAutoIndent2; if (s_flagJumpTo) - EditJumpTo(Globals.hwndEdit, s_iInitialLine, s_iInitialColumn); + EditJumpTo(s_iInitialLine, s_iInitialColumn); else EditEnsureSelectionVisible(); } @@ -2099,8 +2097,7 @@ static HBITMAP LoadBitmapFile(LPCWSTR path) { WCHAR szTmp[MAX_PATH]; if (PathIsRelative(path)) { - GetModuleFileName(NULL, szTmp, COUNTOF(szTmp)); - PathCchRemoveFileSpec(szTmp, COUNTOF(szTmp)); + PathGetAppDirectory(szTmp, COUNTOF(szTmp)); PathAppend(szTmp, path); path = szTmp; } @@ -2807,7 +2804,7 @@ LRESULT MsgCopyData(HWND hwnd, WPARAM wParam, LPARAM lParam) if (params->flagJumpTo) { if (params->iInitialLine == 0) params->iInitialLine = 1; - EditJumpTo(Globals.hwndEdit, params->iInitialLine, params->iInitialColumn); + EditJumpTo(params->iInitialLine, params->iInitialColumn); } if (params->flagMatchText) { @@ -2940,7 +2937,7 @@ LRESULT MsgChangeNotify(HWND hwnd, WPARAM wParam, LPARAM lParam) if (FileWatching.MonitoringLog) { SciCall_SetReadOnly(FileWatching.MonitoringLog); - Sci_ScrollToLine(Sci_GetLastDocLineNumber(), false); + EditScrollToLine(Sci_GetLastDocLineNumber()); } else { SciCall_GotoPos(iCurPos); @@ -4752,7 +4749,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { SciCall_EnsureVisible(iNextLine); SciCall_GotoLine(iNextLine); - SciCall_ScrollCaret(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } } break; @@ -4773,7 +4770,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) { SciCall_EnsureVisible(iNextLine); SciCall_GotoLine(iNextLine); - SciCall_ScrollCaret(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } } break; @@ -4842,9 +4839,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case IDM_EDIT_SELTONEXT: { SciCall_RotateSelection(); - DocPosU const iMain = SciCall_GetMainSelection(); - SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iMain), SciCall_GetSelectionNCaret(iMain)); - SciCall_ChooseCaretX(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } break; @@ -4853,13 +4848,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) DocPosU const iMain = SciCall_GetMainSelection(); if (iMain > 0) { SciCall_SetMainSelection(iMain - 1); - SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iMain - 1), SciCall_GetSelectionNCaret(iMain - 1)); } else { DocPosU const iNewMain = SciCall_GetSelections() - 1; SciCall_SetMainSelection(iNewMain); - SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iNewMain), SciCall_GetSelectionNCaret(iNewMain)); } - SciCall_ChooseCaretX(); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } break; @@ -5270,7 +5263,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) FileWatching.AutoReloadTimeout = 250UL; UndoRedoRecordingStop(); SciCall_SetEndAtLastLine(false); - Sci_ScrollToLine(Sci_GetLastDocLineNumber(), false); + EditScrollToLine(Sci_GetLastDocLineNumber()); } else { s_flagChangeNotify = FileWatching.flagChangeNotify; @@ -5280,7 +5273,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) FileWatching.AutoReloadTimeout = Settings2.AutoReloadTimeout; UndoRedoRecordingStart(); SciCall_SetEndAtLastLine(!Settings.ScrollPastEOF); - Sci_ScrollToLine(Sci_GetCurrentLineNumber(), true); + EditScrollToLine(Sci_GetCurrentLineNumber()); // normalize view } InstallFileWatching(Globals.CurrentFile); // force @@ -9652,7 +9645,8 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc) if (StrIsEmpty(szFileName)) { return false; } bool bPreserveView = true; - DOCVIEWPOS_T const docView = EditGetCurrentDocView(Globals.hwndEdit); + DocLn const curLineNum = Sci_GetCurrentLineNumber(); + bool const bIsAtDocEnd = (curLineNum >= (Sci_GetLastDocLineNumber() - Settings2.CurrentLineVerticalSlop)); Encoding_SrcWeak(CPI_NONE); if (bIgnoreCmdLnEnc) { @@ -9670,9 +9664,10 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc) } if (FileWatching.FileWatchingMode == FWM_AUTORELOAD) { - if (docView.bIsTail || FileWatching.MonitoringLog) { + if (bIsAtDocEnd || FileWatching.MonitoringLog) { bPreserveView = false; - Sci_ScrollToLine(Sci_GetLastDocLineNumber(), false); + SciCall_DocumentEnd(); + EditScrollToLine(Sci_GetLastDocLineNumber()); } } @@ -9683,12 +9678,12 @@ bool FileRevert(LPCWSTR szFileName, bool bIgnoreCmdLnEnc) SciCall_ClearSelections(); bPreserveView = false; SciCall_DocumentEnd(); - EditEnsureSelectionVisible(); + EditScrollToLine(Sci_GetLastDocLineNumber()); } } if (bPreserveView) { - EditSetDocView(Globals.hwndEdit, docView); + EditJumpTo(curLineNum, 0); } SciCall_SetSavePoint(); @@ -10050,10 +10045,8 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) ExpandEnvironmentStrings(Settings2.DefaultDirectory,tchInitialDir,COUNTOF(tchInitialDir)); if (PathIsRelative(tchInitialDir)) { WCHAR tchModule[MAX_PATH] = { L'\0' }; - GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); - PathCchRemoveFileSpec(tchModule, COUNTOF(tchModule)); + PathGetAppDirectory(tchModule, COUNTOF(tchModule)); PathCchAppend(tchModule,COUNTOF(tchModule),tchInitialDir); - PathCchCanonicalize(tchInitialDir,COUNTOF(tchInitialDir),tchModule); } } else @@ -10094,8 +10087,9 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) StringCchCopy(szNewFile,COUNTOF(szNewFile),lpstrFile); Style_GetOpenDlgFilterStr(s_szFilter,COUNTOF(s_szFilter)); - if (StrIsNotEmpty(lpstrInitialDir)) - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),lpstrInitialDir); + if (StrIsNotEmpty(lpstrInitialDir)) { + StringCchCopy(tchInitialDir, COUNTOF(tchInitialDir), lpstrInitialDir); + } else if (StrIsNotEmpty(Globals.CurrentFile)) { StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.CurrentFile); PathCchRemoveFileSpec(tchInitialDir, COUNTOF(tchInitialDir)); @@ -10104,15 +10098,13 @@ bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir) ExpandEnvironmentStrings(Settings2.DefaultDirectory,tchInitialDir,COUNTOF(tchInitialDir)); if (PathIsRelative(tchInitialDir)) { WCHAR tchModule[MAX_PATH] = { L'\0' }; - GetModuleFileName(NULL,tchModule,COUNTOF(tchModule)); - PathCchRemoveFileSpec(tchModule, COUNTOF(tchModule)); + PathGetAppDirectory(tchModule, COUNTOF(tchModule)); PathCchAppend(tchModule,COUNTOF(tchModule),tchInitialDir); - PathCchCanonicalize(tchInitialDir,COUNTOF(tchInitialDir),tchModule); } } - else - StringCchCopy(tchInitialDir,COUNTOF(tchInitialDir),Globals.WorkingDirectory); - + else { + StringCchCopy(tchInitialDir, COUNTOF(tchInitialDir), Globals.WorkingDirectory); + } ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwnd; @@ -10451,6 +10443,7 @@ bool RelaunchElevated(LPWSTR lpNewCmdLnArgs) ExtractFirstArgument(lpCmdLine, lpExe, szOrigArgs, (int)wlen); // override GetModuleFileName(NULL, lpExe, COUNTOF(lpExe)); // full path + PathCanonicalizeEx(lpExe, COUNTOF(lpExe)); if (lpNewCmdLnArgs) { StringCchCopy(szOrigArgs, COUNTOF(szOrigArgs), lpNewCmdLnArgs); } @@ -10811,7 +10804,7 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime) if (SciCall_CanPaste()) { bool bAutoIndent2 = Settings.AutoIndent; Settings.AutoIndent = 0; - EditJumpTo(Globals.hwndEdit,-1,0); + EditJumpTo(-1,0); _BEGIN_UNDO_ACTION_; if (!Sci_IsDocEmpty()) { SciCall_NewLine(); diff --git a/src/SciCall.h b/src/SciCall.h index aeaee204c..8df7cfc5f 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -599,7 +599,10 @@ inline DocPos Sci_GetRangeMaxLineLength(DocLn iBeginLine, DocLn iEndLine) { } // respect VSlop settings -#define Sci_ScrollToLine(L,C) { SciCall_ScrollRange(SciCall_PositionFromLine(L), SciCall_GetLineEndPosition(L)); if (C) { SciCall_ScrollCaret(); } } +inline void Sci_ScrollChooseCaret() { SciCall_ScrollCaret(); SciCall_ChooseCaretX(); } +inline void Sci_ScrollToLine(DocLn line) { SciCall_ScrollRange(SciCall_PositionFromLine(line), SciCall_GetLineEndPosition(line)); } +inline void Sci_ScrollToCurrentLine() { Sci_ScrollToLine(Sci_GetCurrentLineNumber()); } + #define Sci_ReplaceTarget(M,L,T) (((M) == SCI_REPLACETARGET) ? SciCall_ReplaceTarget((L),(T)) : SciCall_ReplaceTargetRe((L),(T))) diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 88f00d95a..e42c0fc66 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -624,25 +624,6 @@ typedef struct _editfileiostatus //============================================================================= -typedef struct _docviewpos_t -{ - DocPos iCurPos; - DocPos iAnchorPos; - //DocPos vSpcCaretPos; - //DocPos vSpcAnchorPos; - DocLn iCurrLine; - DocPos iCurColumn; - DocLn iVisTopLine; - DocLn iDocTopLine; - int iXOffset; - bool bIsTail; - -} DOCVIEWPOS_T, * PDOCVIEWPOS_T; - -#define INIT_DOCVIEWPOS { 0, 0, /*0, 0,*/ 0, 0, 0, 0, 0, false } - -//============================================================================= - typedef struct _themeFiles { UINT rid; diff --git a/src/Version.h b/src/Version.h index f268f78d4..a0d7422b2 100644 --- a/src/Version.h +++ b/src/Version.h @@ -73,7 +73,11 @@ #undef VER_CPL #if defined(_MSC_VER) - #if (_MSC_VER == 1924) + #if (_MSC_VER == 1925) + #if(_MSC_FULL_VER >= 192528610) + #define VER_CPL MS Visual C++ 2019 v16.5.0 + #endif + #elif (_MSC_VER == 1924) #if(_MSC_FULL_VER >= 192428319) #define VER_CPL MS Visual C++ 2019 v16.4.6 #elif(_MSC_FULL_VER >= 192428316) diff --git a/src/VersionEx.h b/src/VersionEx.h index 2cc059d72..5a8133da5 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -8,12 +8,12 @@ #define SAPPNAME "Notepad3" #define VERSION_MAJOR 5 #define VERSION_MINOR 20 -#define VERSION_REV 319 -#define VERSION_BUILD 1 +#define VERSION_REV 320 +#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_PATCH RC3 #define VERSION_COMMIT_ID t7820-rk