From 6a3d9e994dd339b9df64194e811d7c0fc992badb Mon Sep 17 00:00:00 2001 From: Don HO Date: Tue, 14 Mar 2017 09:09:01 +0100 Subject: [PATCH] Fix a minor bug in "Show content in doc map on mous hover" Fix a compiling error for x64 build --- PowerEditor/src/NppNotification.cpp | 24 +++++++++++++------ PowerEditor/src/Parameters.cpp | 17 +++++++++---- .../WinControls/DocumentMap/documentMap.cpp | 10 +++----- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 26492de71..dd7dce820 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -151,7 +151,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) case TCN_MOUSEHOVERING: case TCN_MOUSEHOVERSWITCHING: { - /* + ///* if (_pDocMap && (!_pDocMap->isClosed()) && _pDocMap->isVisible()) { TBHDR *tbHdr = reinterpret_cast(notification); @@ -159,20 +159,30 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (pTabDocView) { BufferID id = pTabDocView->getBufferByIndex(tbHdr->tabOrigin); - Buffer * pBuf = MainFileManager->getBufferByID(id); - _pDocMap->showInMapTemporarily(pBuf, notifyView); - _pDocMap->setSyntaxHiliting(); + 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()) { _pDocMap->reloadMap(); @@ -180,7 +190,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) _pDocMap->setTemporarilyShowing(false); } - */ + //*/ break; } diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index cd8384b2e..6796bb157 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2003,10 +2003,19 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p (childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth); MapPosition mapPosition; - (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDocLine"), &mapPosition._firstVisibleDocLine); - (childNode->ToElement())->Attribute(TEXT("mapLastVisibleDocLine"), &mapPosition._lastVisibleDocLine); - (childNode->ToElement())->Attribute(TEXT("mapNbLine"), &mapPosition._nbLine); - (childNode->ToElement())->Attribute(TEXT("mapHigherPos"), &mapPosition._higherPos); + int32_t mapPosVal; + const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDocLine"), &mapPosVal); + if (mapPosStr) + mapPosition._firstVisibleDocLine = mapPosVal; + mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapLastVisibleDocLine"), &mapPosVal); + if (mapPosStr) + mapPosition._lastVisibleDocLine = mapPosVal; + mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapNbLine"), &mapPosVal); + if (mapPosStr) + mapPosition._nbLine = mapPosVal; + mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapHigherPos"), &mapPosVal); + if (mapPosStr) + mapPosition._higherPos = mapPosVal; const TCHAR *langName; langName = (childNode->ToElement())->Attribute(TEXT("lang")); diff --git a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp index e9597e101..04f658691 100644 --- a/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp +++ b/PowerEditor/src/WinControls/DocumentMap/documentMap.cpp @@ -236,7 +236,7 @@ void DocumentMap::scrollMap(ScintillaEditView *editView) // Get the editor's higher/lower Y, then compute the map's higher/lower Y LRESULT higherY = 0; LRESULT lowerY = 0; - auto higherPos = -1 ; // -1 => not pEditView->isWrap() + LRESULT higherPos = -1 ; // -1 => not pEditView->isWrap() if (not pEditView->isWrap()) { auto higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine); @@ -252,14 +252,14 @@ void DocumentMap::scrollMap(ScintillaEditView *editView) else { higherPos = pEditView->execute(SCI_POSITIONFROMPOINT, 0, 0); - higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos); + higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, static_cast(higherPos)); auto lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine); lowerY = nbLine * lineHeight + higherY; } // set current map position in buffer Buffer *buffer = pEditView->getCurrentBuffer(); - buffer->setMapPosition(firstVisibleDocLine, lastVisibleDocLine, nbLine, higherPos); + 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)); @@ -445,9 +445,7 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP default: break; - } - } return TRUE; @@ -478,8 +476,6 @@ INT_PTR CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } return TRUE; - - default : return DockingDlgInterface::run_dlgProc(message, wParam, lParam); }