mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
[FIXED_BUG] doc map: Fix folding (doc map view zone) problem.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@867 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
dd2f32bb69
commit
a1d9f0f4b4
@ -37,32 +37,36 @@ void DocumentMap::scrollMap()
|
|||||||
{
|
{
|
||||||
if (_pScintillaEditView && _ppEditView)
|
if (_pScintillaEditView && _ppEditView)
|
||||||
{
|
{
|
||||||
// Visible line for the code view
|
// Visible document line for the code view (but not displayed line)
|
||||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
int firstVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine);
|
||||||
//int nbTotalLine = (*_ppEditView)->getCurrentLineNumber();
|
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
|
||||||
|
int lastVisibleDocLine = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine);
|
||||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
|
||||||
|
|
||||||
// Visible line for the map view
|
// Visible document line for the map view
|
||||||
int firstVisibleLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE);
|
int firstVisibleDisplayLineMap = _pScintillaEditView->execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
int nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
int firstVisibleDocLineMap = _pScintillaEditView->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLineMap);
|
||||||
int lastVisibleLineMap = firstVisibleLineMap + nbLineMap;
|
int nbLineMap = _pScintillaEditView->execute(SCI_LINESONSCREEN, firstVisibleDocLineMap);
|
||||||
|
int lastVisibleDocLineMap = firstVisibleDisplayLineMap + nbLineMap;
|
||||||
|
|
||||||
if (lastVisibleLineMap < lastVisibleLine)
|
// If part of editor view is out of map, then scroll map
|
||||||
_pScintillaEditView->execute(SCI_GOTOLINE, lastVisibleLine);
|
if (lastVisibleDocLineMap < lastVisibleDocLine)
|
||||||
|
_pScintillaEditView->execute(SCI_GOTOLINE, lastVisibleDocLine);
|
||||||
else
|
else
|
||||||
_pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleLine);
|
_pScintillaEditView->execute(SCI_GOTOLINE, firstVisibleDocLine);
|
||||||
|
|
||||||
int higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleLine);
|
// Get the editor's higher/lower Y, then compute the map's higher/lower Y
|
||||||
int lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleLine);
|
int higherPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, firstVisibleDocLine);
|
||||||
|
int lowerPos = _pScintillaEditView->execute(SCI_POSITIONFROMLINE, lastVisibleDocLine);
|
||||||
int higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos);
|
int higherY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, higherPos);
|
||||||
int lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos);
|
int lowerY = _pScintillaEditView->execute(SCI_POINTYFROMPOSITION, 0, lowerPos);
|
||||||
if (lowerY == 0)
|
if (lowerY == 0)
|
||||||
{
|
{
|
||||||
int lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleLine);
|
int lineHeight = _pScintillaEditView->execute(SCI_TEXTHEIGHT, firstVisibleDocLine);
|
||||||
lowerY = nbLine * lineHeight + firstVisibleLine;
|
lowerY = nbLine * lineHeight + firstVisibleDocLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update view zone in map
|
||||||
_vzDlg.drawZone(higherY, lowerY);
|
_vzDlg.drawZone(higherY, lowerY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,20 +89,20 @@ void DocumentMap::fold(int line, bool foldOrNot)
|
|||||||
void DocumentMap::scrollMap(bool direction, moveMode whichMode)
|
void DocumentMap::scrollMap(bool direction, moveMode whichMode)
|
||||||
{
|
{
|
||||||
// Visible line for the code view
|
// Visible line for the code view
|
||||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
|
||||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
int lastVisibleDisplayLine = firstVisibleDisplayLine + nbLine;
|
||||||
|
|
||||||
int nbLine2go = (whichMode == perLine?1:nbLine);
|
int nbLine2go = (whichMode == perLine?1:nbLine);
|
||||||
int line2go = 1;
|
int line2go = 1;
|
||||||
|
|
||||||
if (direction == moveDown)
|
if (direction == moveDown)
|
||||||
{
|
{
|
||||||
line2go = lastVisibleLine + nbLine2go;
|
line2go = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, lastVisibleDisplayLine + nbLine2go);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
line2go = firstVisibleLine - nbLine2go;
|
line2go = (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine - nbLine2go);
|
||||||
}
|
}
|
||||||
(*_ppEditView)->execute(SCI_GOTOLINE, line2go);
|
(*_ppEditView)->execute(SCI_GOTOLINE, line2go);
|
||||||
|
|
||||||
@ -271,22 +275,22 @@ BOOL CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara
|
|||||||
{
|
{
|
||||||
jumpDistance = currentCenterPosY - newPosY;
|
jumpDistance = currentCenterPosY - newPosY;
|
||||||
int nbLine2jump = jumpDistance/pixelPerLine;
|
int nbLine2jump = jumpDistance/pixelPerLine;
|
||||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
firstVisibleLine -= nbLine2jump;
|
firstVisibleDisplayLine -= nbLine2jump;
|
||||||
if (firstVisibleLine < 0)
|
if (firstVisibleDisplayLine < 0)
|
||||||
firstVisibleLine = 0;
|
firstVisibleDisplayLine = 0;
|
||||||
(*_ppEditView)->execute(SCI_GOTOLINE, firstVisibleLine);
|
(*_ppEditView)->execute(SCI_GOTOLINE, (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jumpDistance = newPosY - currentCenterPosY;
|
jumpDistance = newPosY - currentCenterPosY;
|
||||||
int nbLine2jump = jumpDistance/pixelPerLine;
|
int nbLine2jump = jumpDistance/pixelPerLine;
|
||||||
int firstVisibleLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
int firstVisibleDisplayLine = (*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE);
|
||||||
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleLine);
|
int nbLine = (*_ppEditView)->execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
|
||||||
int lastVisibleLine = firstVisibleLine + nbLine;
|
int lastVisibleDisplayLine = firstVisibleDisplayLine + nbLine;
|
||||||
|
|
||||||
lastVisibleLine += nbLine2jump;
|
lastVisibleDisplayLine += nbLine2jump;
|
||||||
(*_ppEditView)->execute(SCI_GOTOLINE, lastVisibleLine);
|
(*_ppEditView)->execute(SCI_GOTOLINE, (*_ppEditView)->execute(SCI_DOCLINEFROMVISIBLE, lastVisibleDisplayLine));
|
||||||
}
|
}
|
||||||
scrollMap();
|
scrollMap();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user