diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 6ee5025bb..8188fed55 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -871,7 +871,7 @@ BEGIN POPUP "MD5" BEGIN MENUITEM "Generate...", IDM_TOOL_MD5_GENERATE - MENUITEM "Generate from files...", IDM_TOOL_MD5_GENERATEFROMFILE + MENUITEM "Generate from files...", IDM_TOOL_MD5_GENERATEFROMFILE MENUITEM "Generate into clipboard", IDM_TOOL_MD5_GENERATEINTOCLIPBOARD END END @@ -889,17 +889,7 @@ BEGIN BEGIN MENUITEM "&Run...", IDM_EXECUTE END -/* - POPUP "Tools" - BEGIN - POPUP "MD5" - BEGIN - MENUITEM "Generate...", IDM_TOOL_MD5_GENERATE - MENUITEM "Generate from a file...", IDM_TOOL_MD5_GENERATEFROMFILE - MENUITEM "Generate into clipboard", IDM_TOOL_MD5_GENERATEINTOCLIPBOARD - END - END -*/ + POPUP "&?" BEGIN //MENUITEM "Help Contents", IDM_HELP @@ -1002,6 +992,3 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN PUSHBUTTON "+",IDC_RESTORE_BUTTON,0,0,12,10 END - -// xp style -//1 RT_MANIFEST "notepad++.exe.manifest" diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 5a3308aaa..66e521907 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -36,6 +36,8 @@ using namespace std; +bool doSnapshot = true; +bool doSnapshotOnMap = true; // Only for 2 main Scintilla editors BOOL Notepad_plus::notify(SCNotification *notification) @@ -151,35 +153,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) case TCN_MOUSEHOVERING: case TCN_MOUSEHOVERSWITCHING: { - /* - if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) - { - TBHDR *tbHdr = reinterpret_cast(notification); - DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr); - if (pTabDocView) - { - BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin); - Buffer *pBuf = MainFileManager->getBufferByID(id); - - Buffer *currentBuf = getCurrentBuffer(); - - if (pBuf != currentBuf) // if hover on other tab - { - _pDocMap->showInMapTemporarily(pBuf, notifyView); - _pDocMap->setSyntaxHiliting(); - } - else // if hover on current active tab - { - _pDocMap->reloadMap(); - _pDocMap->setSyntaxHiliting(); - } - _pDocMap->setTemporarilyShowing(true); - } - } - */ - - /* - if (true) + if (doSnapshot) { TBHDR *tbHdr = reinterpret_cast(notification); DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr); @@ -207,27 +181,49 @@ BOOL Notepad_plus::notify(SCNotification *notification) } } } - */ + + if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible() && doSnapshotOnMap) + { + TBHDR *tbHdr = reinterpret_cast(notification); + DocTabView *pTabDocView = isFromPrimary ? &_mainDocTab : (isFromSecondary ? &_subDocTab : nullptr); + if (pTabDocView) + { + BufferID id = pTabDocView->getBufferByIndex(tbHdr->_tabOrigin); + Buffer *pBuf = MainFileManager->getBufferByID(id); + + Buffer *currentBuf = getCurrentBuffer(); + + if (pBuf != currentBuf) // if hover on other tab + { + _pDocMap->showInMapTemporarily(pBuf, notifyView); + _pDocMap->setSyntaxHiliting(); + } + else // if hover on current active tab + { + _pDocMap->reloadMap(); + _pDocMap->setSyntaxHiliting(); + } + _pDocMap->setTemporarilyShowing(true); + } + } + break; } case TCN_MOUSELEAVING: { - /* - if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) + if (doSnapshot) + { + _documentSnapshot.display(false); + } + + if (doSnapshotOnMap && _pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) { _pDocMap->reloadMap(); _pDocMap->setSyntaxHiliting(); _pDocMap->setTemporarilyShowing(false); } - - bool doSnapshot = true; - if (doSnapshot) - { - _documentSnapshot.display(false); - } - */ break; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 853d8645d..c9a8722ed 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2004,7 +2004,10 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p MapPosition mapPosition; int32_t mapPosVal; - const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDocLine"), &mapPosVal); + const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"), &mapPosVal); + if (mapPosStr) + mapPosition._firstVisibleDisplayLine = mapPosVal; + mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDocLine"), &mapPosVal); if (mapPosStr) mapPosition._firstVisibleDocLine = mapPosVal; mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapLastVisibleDocLine"), &mapPosVal); @@ -2969,7 +2972,8 @@ void NppParameters::writeSession(const Session & session, const TCHAR *fileName) (fileNameNode->ToElement())->SetAttribute(TEXT("originalFileLastModifTimestamp"), static_cast(viewSessionFiles[i]._originalFileLastModifTimestamp)); // docMap - (fileNameNode->ToElement())->SetAttribute(TEXT("mapFirstVisibleDocLine"), viewSessionFiles[i]._mapPos._lastVisibleDocLine); + (fileNameNode->ToElement())->SetAttribute(TEXT("mapFirstVisibleDisplayLine"), viewSessionFiles[i]._mapPos._firstVisibleDisplayLine); + (fileNameNode->ToElement())->SetAttribute(TEXT("mapFirstVisibleDocLine"), viewSessionFiles[i]._mapPos._firstVisibleDocLine); (fileNameNode->ToElement())->SetAttribute(TEXT("mapLastVisibleDocLine"), viewSessionFiles[i]._mapPos._lastVisibleDocLine); (fileNameNode->ToElement())->SetAttribute(TEXT("mapNbLine"), viewSessionFiles[i]._mapPos._nbLine); (fileNameNode->ToElement())->SetAttribute(TEXT("mapHigherPos"), viewSessionFiles[i]._mapPos._higherPos); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e0d24f2de..230f482b5 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -140,15 +140,17 @@ struct Position struct MapPosition { - int32_t _firstVisibleDocLine = -1; - int32_t _lastVisibleDocLine = -1; - int32_t _nbLine = -1; - int32_t _higherPos = -1; + int32_t _firstVisibleDisplayLine = -1; + + int32_t _firstVisibleDocLine = -1; // map + int32_t _lastVisibleDocLine = -1; // map + int32_t _nbLine = -1; // map + int32_t _higherPos = -1; // map int32_t _width = -1; int32_t _height = -1; int32_t _wrapIndentMode = -1; bool _isWrap = false; - bool isValid() { return _firstVisibleDocLine != -1; }; + bool isValid() { return _firstVisibleDisplayLine != -1; }; }; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index f2a5ba6c5..3568e03f8 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -349,7 +349,7 @@ public: void updateTimeStamp(); void reload(); void setMapPosition(const MapPosition & mapPosition) { _mapPosition = mapPosition; }; - MapPosition getMapPosition() { return _mapPosition; }; + MapPosition getMapPosition() const { return _mapPosition; }; private: int indexOfReference(const ScintillaEditView * identifier) const; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp index 352808ef8..f90dd7808 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp @@ -32,22 +32,22 @@ void DocumentMap::reloadMap() { - if (_pScintillaEditView && _ppEditView) + if (_pMapView && _ppEditView) { Document currentDoc = (*_ppEditView)->execute(SCI_GETDOCPOINTER); - _pScintillaEditView->execute(SCI_SETDOCPOINTER, 0, static_cast(currentDoc)); + _pMapView->execute(SCI_SETDOCPOINTER, 0, static_cast(currentDoc)); // // sync with the current document // Buffer *editBuf = (*_ppEditView)->getCurrentBuffer(); - _pScintillaEditView->setCurrentBuffer(editBuf); + _pMapView->setCurrentBuffer(editBuf); // folding std::vector lineStateVector; (*_ppEditView)->getCurrentFoldStates(lineStateVector); - _pScintillaEditView->syncFoldStateWith(lineStateVector); + _pMapView->syncFoldStateWith(lineStateVector); // Wrapping if ((*_ppEditView)->isWrap() && needToRecomputeWith()) @@ -61,33 +61,32 @@ void DocumentMap::reloadMap() void DocumentMap::showInMapTemporarily(Buffer *buf2show, ScintillaEditView *fromEditView) { - if (_pScintillaEditView && fromEditView) + if (_pMapView && fromEditView) { - _pScintillaEditView->execute(SCI_SETDOCPOINTER, 0, static_cast(buf2show->getDocument())); - _pScintillaEditView->setCurrentBuffer(buf2show); + _pMapView->execute(SCI_SETDOCPOINTER, 0, static_cast(buf2show->getDocument())); + _pMapView->setCurrentBuffer(buf2show); // folding const std::vector & lineStateVector = buf2show->getHeaderLineState(fromEditView); - _pScintillaEditView->syncFoldStateWith(lineStateVector); + _pMapView->syncFoldStateWith(lineStateVector); // Wrapping if (fromEditView->isWrap() && needToRecomputeWith(fromEditView)) { wrapMap(fromEditView); } + MapPosition mp = buf2show->getMapPosition(); if (mp.isValid()) - scrollMapWith(mp, *fromEditView); - else - scrollMap(fromEditView); + scrollMapWith(mp); } } void DocumentMap::setSyntaxHiliting() { - Buffer *buf = _pScintillaEditView->getCurrentBuffer(); - _pScintillaEditView->defineDocType(buf->getLangType()); - _pScintillaEditView->showMargin(ScintillaEditView::_SC_MARGE_FOLDER, false); + Buffer *buf = _pMapView->getCurrentBuffer(); + _pMapView->defineDocType(buf->getLangType()); + _pMapView->showMargin(ScintillaEditView::_SC_MARGE_FOLDER, false); } bool DocumentMap::needToRecomputeWith(const ScintillaEditView *editView) @@ -107,23 +106,23 @@ bool DocumentMap::needToRecomputeWith(const ScintillaEditView *editView) void DocumentMap::initWrapMap() { - if (_pScintillaEditView && _ppEditView) + if (_pMapView && _ppEditView) { RECT rect; getClientRect(rect); - ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, rect.right - rect.left, rect.bottom-rect.top, TRUE); - _pScintillaEditView->wrap(false); - _pScintillaEditView->redraw(true); + ::MoveWindow(_pMapView->getHSelf(), 0, 0, rect.right - rect.left, rect.bottom-rect.top, TRUE); + _pMapView->wrap(false); + _pMapView->redraw(true); bool isRTL = (*_ppEditView)->isTextDirectionRTL(); - if (_pScintillaEditView->isTextDirectionRTL() != isRTL) - _pScintillaEditView->changeTextDirection(isRTL); + if (_pMapView->isTextDirectionRTL() != isRTL) + _pMapView->changeTextDirection(isRTL); } } void DocumentMap::changeTextDirection(bool isRTL) { - _pScintillaEditView->changeTextDirection(isRTL); + _pMapView->changeTextDirection(isRTL); } /* @@ -185,11 +184,11 @@ void DocumentMap::wrapMap(const ScintillaEditView *editView) // compute doc map width: dzw/ezw = 1/zoomRatio double docMapWidth = editZoneWidth / zr; - ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, int(docMapWidth), rect.bottom-rect.top, TRUE); - _pScintillaEditView->wrap(true); + ::MoveWindow(_pMapView->getHSelf(), 0, 0, int(docMapWidth), rect.bottom-rect.top, TRUE); + _pMapView->wrap(true); // sync wrapping indent mode - _pScintillaEditView->execute(SCI_SETWRAPINDENTMODE, pEditView->execute(SCI_GETWRAPINDENTMODE)); + _pMapView->execute(SCI_SETWRAPINDENTMODE, pEditView->execute(SCI_GETWRAPINDENTMODE)); } } @@ -209,113 +208,118 @@ int DocumentMap::getEditorTextZoneWidth(const ScintillaEditView *editView) return editorRect.right - editorRect.left - marginWidths; } -void DocumentMap::scrollMap(ScintillaEditView *editView) +void DocumentMap::scrollMap() { - ScintillaEditView *pEditView = editView ? editView : *_ppEditView; - - if (_pScintillaEditView && pEditView) + if (_pMapView && _ppEditView) { // Visible document line for the code view (but not displayed line) - auto firstVisibleDisplayLine = pEditView->execute(SCI_GETFIRSTVISIBLELINE); - const auto firstVisibleDocLine = pEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine); - const auto nbLine = pEditView->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine); - const auto lastVisibleDocLine = pEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine); + auto firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE); + const auto firstVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine); + const auto nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine); + const auto lastVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine); // Visible document line for the map view - auto firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE); - auto firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); - auto nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); - auto lastVisibleDocLineMap = pEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); + auto firstVisibleDisplayLineMap = _pMapView->execute(SCI_GETFIRSTVISIBLELINE); + auto firstVisibleDocLineMap = _pMapView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); + auto nbLineMap = _pMapView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); + auto lastVisibleDocLineMap = _pMapView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); // If part of editor view is out of map, then scroll map + LRESULT mapLineToScroll = 0; if (lastVisibleDocLineMap < lastVisibleDocLine) - _pScintillaEditView->execute(SCI_GOTOLINE, lastVisibleDocLine); + mapLineToScroll = lastVisibleDocLine; else - _pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleDocLine); + mapLineToScroll = firstVisibleDocLine; + // + // Scroll to make whole view zone visible + // + _pMapView->execute(SCI_GOTOLINE, mapLineToScroll); // Get the editor's higher/lower Y, then compute the map's higher/lower Y LRESULT higherY = 0; LRESULT lowerY = 0; - LRESULT higherPos = -1 ; // -1 => not pEditView->isWrap() - if (not pEditView->isWrap()) + LRESULT higherPos = -1 ; // -1 => not (*_ppEditView)->isWrap() + if (not (*_ppEditView)->isWrap()) { - auto higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine); - auto lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleDocLine); - higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); - lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos); + higherPos = _pMapView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine); + auto lowerPos = _pMapView->execute(SCI_POSITIONFROMLINE, lastVisibleDocLine); + higherY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); + lowerY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos); if (lowerY == 0) { - auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); + auto lineHeight = _pMapView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); lowerY = nbLine * lineHeight + firstVisibleDocLine; } } else { - higherPos = pEditView->execute(SCI_POSITIONFROMPOINT, 0, 0); - higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, static_cast(higherPos)); - auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); + // Get the position of the 1st showing char from the original edit view + higherPos = (*_ppEditView)->execute(SCI_POSITIONFROMPOINT, 0, 0); + + // Get the map higher Y point from the position in map + higherY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, static_cast(higherPos)); + + // Get line height + auto lineHeight = _pMapView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); + + // Get the map lower Y point lowerY = nbLine * lineHeight + higherY; } - char toto[256]; - sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY); - OutputDebugStringA(toto); - - // set current map position in buffer - //Buffer *buffer = pEditView->getCurrentBuffer(); - //buffer->setMapPosition(static_cast(firstVisibleDocLine), static_cast(lastVisibleDocLine), static_cast(nbLine), static_cast(higherPos)); - - // Update view zone in map - _vzDlg.drawZone(static_cast(higherY), static_cast(lowerY)); + // + // Mark view zone in map + // + _vzDlg.drawZone(static_cast(higherY), static_cast(lowerY)); } } -void DocumentMap::scrollMapWith(const MapPosition & mapPos, ScintillaEditView & editView) +void DocumentMap::scrollMapWith(const MapPosition & mapPos) { - if (_pScintillaEditView) + if (_pMapView) { // Visible document line for the map view - auto firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE); - //char toto[256]; - //sprintf(toto, "MAP : highfirstVisibleDisplayLineerY: %d\n", firstVisibleDisplayLine); - //OutputDebugStringA(toto); - - auto firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); - auto nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); - auto lastVisibleDocLineMap = editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); + auto firstVisibleDisplayLineMap = _pMapView->execute(SCI_GETFIRSTVISIBLELINE); + auto firstVisibleDocLineMap = _pMapView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap); + auto nbLineMap = _pMapView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap); + auto lastVisibleDocLineMap = _pMapView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap + nbLineMap); // If part of editor view is out of map, then scroll map + LRESULT mapLineToScroll = 0; if (lastVisibleDocLineMap < mapPos._lastVisibleDocLine) - _pScintillaEditView->execute(SCI_GOTOLINE, mapPos._lastVisibleDocLine); + mapLineToScroll = mapPos._lastVisibleDocLine; else - _pScintillaEditView->execute(SCI_GOTOLINE, mapPos._firstVisibleDocLine); + mapLineToScroll = mapPos._firstVisibleDocLine; + // + // Scroll to make whole view zone visible + // + _pMapView->execute(SCI_GOTOLINE, mapLineToScroll); // Get the editor's higher/lower Y, then compute the map's higher/lower Y LRESULT higherY = 0; LRESULT lowerY = 0; - if (mapPos._higherPos == -1) // mapPos._higherPos == -1 => not pEditView->isWrap() + if (not mapPos._isWrap) { - auto higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, mapPos._firstVisibleDocLine); - auto lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, mapPos._lastVisibleDocLine); - higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); - lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos); + auto higherPos = _pMapView->execute(SCI_POSITIONFROMLINE, mapPos._firstVisibleDocLine); + auto lowerPos = _pMapView->execute(SCI_POSITIONFROMLINE, mapPos._lastVisibleDocLine); + higherY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); + lowerY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos); if (lowerY == 0) { - auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); + auto lineHeight = _pMapView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); lowerY = mapPos._nbLine * lineHeight + mapPos._firstVisibleDocLine; } } else { - higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, mapPos._higherPos); - auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); + higherY = _pMapView->execute(SCI_POINTYFROMPOSITION, 0, static_cast(mapPos._higherPos)); + auto lineHeight = _pMapView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); lowerY = mapPos._nbLine * lineHeight + higherY; } - //sprintf(toto, "MAP : %d & %d\n\n", higherY, lowerY); - //OutputDebugStringA(toto); - // Update view zone in map - _vzDlg.drawZone(static_cast(higherY), static_cast(lowerY)); + // + // Mark view zone in map + // + _vzDlg.drawZone(static_cast(higherY), static_cast(lowerY)); } } @@ -330,12 +334,12 @@ void DocumentMap::doMove() void DocumentMap::fold(int line, bool foldOrNot) { - _pScintillaEditView->fold(line, foldOrNot); + _pMapView->fold(line, foldOrNot); } void DocumentMap::foldAll(bool mode) { - _pScintillaEditView->foldAll(mode); + _pMapView->foldAll(mode); } void DocumentMap::scrollMap(bool direction, moveMode whichMode) @@ -351,7 +355,7 @@ void DocumentMap::scrollMap(bool direction, moveMode whichMode) void DocumentMap::redraw(bool) const { - _pScintillaEditView->execute(SCI_COLOURISE, 0, -1); + _pMapView->execute(SCI_COLOURISE, 0, -1); } INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) @@ -361,13 +365,13 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP case WM_INITDIALOG : { HWND hwndScintilla = reinterpret_cast(::SendMessage(_hParent, NPPM_CREATESCINTILLAHANDLE, 0, reinterpret_cast(_hSelf))); - _pScintillaEditView = reinterpret_cast(::SendMessage(_hParent, NPPM_INTERNAL_GETSCINTEDTVIEW, 0, reinterpret_cast(hwndScintilla))); - _pScintillaEditView->execute(SCI_SETZOOM, static_cast(-10), 0); - _pScintillaEditView->execute(SCI_SETVSCROLLBAR, FALSE, 0); - _pScintillaEditView->execute(SCI_SETHSCROLLBAR, FALSE, 0); + _pMapView = reinterpret_cast(::SendMessage(_hParent, NPPM_INTERNAL_GETSCINTEDTVIEW, 0, reinterpret_cast(hwndScintilla))); + _pMapView->execute(SCI_SETZOOM, static_cast(-10), 0); + _pMapView->execute(SCI_SETVSCROLLBAR, FALSE, 0); + _pMapView->execute(SCI_SETHSCROLLBAR, FALSE, 0); - _pScintillaEditView->showIndentGuideLine(false); - _pScintillaEditView->display(); + _pMapView->showIndentGuideLine(false); + _pMapView->display(); reloadMap(); @@ -377,17 +381,17 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP setSyntaxHiliting(); - _pScintillaEditView->showMargin(0, false); - _pScintillaEditView->showMargin(1, false); - _pScintillaEditView->showMargin(2, false); - _pScintillaEditView->showMargin(3, false); + _pMapView->showMargin(0, false); + _pMapView->showMargin(1, false); + _pMapView->showMargin(2, false); + _pMapView->showMargin(3, false); return TRUE; } case WM_SIZE: { - if (_pScintillaEditView) + if (_pMapView) { int width = LOWORD(lParam); int height = HIWORD(lParam); @@ -396,8 +400,8 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP { POINT pt = {0,0}; ::ClientToScreen(_hSelf, &pt); - if (!_pScintillaEditView->isWrap()) - ::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, width, height, TRUE); + if (!_pMapView->isWrap()) + ::MoveWindow(_pMapView->getHSelf(), 0, 0, width, height, TRUE); ::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, width, height, TRUE); } @@ -436,11 +440,6 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP int width = rc.right - rc.left; int height = rc.bottom - rc.top; - //RECT scinrc; - //_pScintillaEditView->getClientRect(scinrc); - //int scinrcWidth = scinrc.right - scinrc.left; - //::MoveWindow(_pScintillaEditView->getHSelf(), 0, 0, scinrcWidth, height, TRUE); - POINT pt = {0,0}; ::ClientToScreen(_hSelf, &pt); ::MoveWindow(_vzDlg.getHSelf(), pt.x, pt.y, width, height, TRUE); @@ -471,7 +470,7 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP { int newPosY = HIWORD(lParam); int currentCenterPosY = _vzDlg.getCurrentCenterPosY(); - int pixelPerLine = static_cast(_pScintillaEditView->execute(SCI_TEXTHEIGHT, 0)); + int pixelPerLine = static_cast(_pMapView->execute(SCI_TEXTHEIGHT, 0)); int jumpDistance = newPosY - currentCenterPosY; int nbLine2jump = jumpDistance/pixelPerLine; (*_ppEditView)->execute(SCI_LINESCROLL, 0, nbLine2jump); diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.h b/PowerEditor/src/WinControls/DocumentMap/documentMap.h index 046443bdb..33273986a 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.h +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.h @@ -124,9 +124,9 @@ public: void showInMapTemporarily(Buffer *buf2show, ScintillaEditView *fromEditView); void wrapMap(const ScintillaEditView *editView = nullptr); void initWrapMap(); - void scrollMap(ScintillaEditView *editView = nullptr); + void scrollMap(); void scrollMap(bool direction, moveMode whichMode); - void scrollMapWith(const MapPosition & mapPos, ScintillaEditView & editView); + void scrollMapWith(const MapPosition & mapPos); void doMove(); void fold(int line, bool foldOrNot); void foldAll(bool mode); @@ -142,7 +142,7 @@ protected: private: ScintillaEditView **_ppEditView = nullptr; - ScintillaEditView *_pScintillaEditView = nullptr; + ScintillaEditView *_pMapView = nullptr; ViewZoneDlg _vzDlg; bool _isTemporarilyShowing = false; diff --git a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp index dbc209b25..6af7d823c 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentSnapshot.cpp @@ -138,10 +138,10 @@ void DocumentSnapshot::scrollSnapshotWith(const MapPosition & mapPos) // // Get the first visible display line from the first visible document line - auto firstVisibleDisplayLine = _pScintillaEditView->execute(SCI_VISIBLEFROMDOCLINE, mapPos._firstVisibleDocLine); + //auto firstVisibleDisplayLine = _pScintillaEditView->execute(SCI_VISIBLEFROMDOCLINE, mapPos._firstVisibleDocLine); // scroll to the first visible display line - _pScintillaEditView->execute(SCI_LINESCROLL, 0, firstVisibleDisplayLine); + _pScintillaEditView->execute(SCI_LINESCROLL, 0,mapPos._firstVisibleDisplayLine); } } @@ -150,16 +150,17 @@ void DocumentSnapshot::saveCurrentSnapshot(ScintillaEditView & editView) { if (_pScintillaEditView) { - MapPosition mapPos; + Buffer *buffer = editView.getCurrentBuffer(); + MapPosition mapPos = buffer->getMapPosition(); // First visible document line for scrolling to this line - auto firstVisibleDisplayLine = editView.execute(SCI_GETFIRSTVISIBLELINE); - mapPos._firstVisibleDocLine = static_cast(editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine)); - mapPos._nbLine = static_cast(editView.execute(SCI_LINESONSCREEN, firstVisibleDisplayLine)); - mapPos._lastVisibleDocLine = static_cast(editView.execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + mapPos._nbLine)); + mapPos._firstVisibleDisplayLine = static_cast(editView.execute(SCI_GETFIRSTVISIBLELINE)); + mapPos._firstVisibleDocLine = static_cast(editView.execute(SCI_DOCLINEFROMVISIBLE, mapPos._firstVisibleDisplayLine)); + mapPos._nbLine = static_cast(editView.execute(SCI_LINESONSCREEN, mapPos._firstVisibleDisplayLine)); + mapPos._lastVisibleDocLine = static_cast(editView.execute(SCI_DOCLINEFROMVISIBLE, mapPos._firstVisibleDisplayLine + mapPos._nbLine)); - int32_t lineHeight = static_cast(_pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine)); - mapPos._height = mapPos._nbLine * lineHeight; + auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, mapPos._firstVisibleDocLine); + mapPos._height = static_cast(mapPos._nbLine * lineHeight); // Width RECT editorRect; @@ -175,9 +176,12 @@ void DocumentSnapshot::saveCurrentSnapshot(ScintillaEditView & editView) mapPos._wrapIndentMode = static_cast(editView.execute(SCI_GETWRAPINDENTMODE)); mapPos._isWrap = static_cast(editView.isWrap()); + if (editView.isWrap()) + { + mapPos._higherPos = static_cast(editView.execute(SCI_POSITIONFROMPOINT, 0, 0)); + } // set current map position in buffer - Buffer *buffer = editView.getCurrentBuffer(); buffer->setMapPosition(mapPos); } }