[ENHANCEMENT] Doc map: Improve wrapping operation.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@877 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
44a37232db
commit
9206fd252e
@ -39,14 +39,32 @@ void DocumentMap::reloadMap()
|
|||||||
_pScintillaEditView->syncFoldStateWith((*_ppEditView)->getCurrentFoldStates());
|
_pScintillaEditView->syncFoldStateWith((*_ppEditView)->getCurrentFoldStates());
|
||||||
|
|
||||||
// Wrapping
|
// Wrapping
|
||||||
|
if ((*_ppEditView)->isWrap() && needToRecomputeWith())
|
||||||
|
{
|
||||||
initWrapMap();
|
initWrapMap();
|
||||||
wrapMap();
|
wrapMap();
|
||||||
|
}
|
||||||
scrollMap();
|
scrollMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DocumentMap::needToRecomputeWith()
|
||||||
|
{
|
||||||
|
int currentZoom = (*_ppEditView)->execute(SCI_GETZOOM);
|
||||||
|
if (_displayZoom != currentZoom)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
int currentTextZoneWidth = getEditorTextZoneWidth();
|
||||||
|
if (_displayWidth != currentTextZoneWidth)
|
||||||
|
return true;
|
||||||
|
/*
|
||||||
|
if (_displayHeight != )
|
||||||
|
return true;
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void DocumentMap::initWrapMap()
|
void DocumentMap::initWrapMap()
|
||||||
{
|
{
|
||||||
if (_pScintillaEditView && _ppEditView)
|
if (_pScintillaEditView && _ppEditView)
|
||||||
@ -133,15 +151,7 @@ void DocumentMap::wrapMap()
|
|||||||
int Xlength2 = xEnd2 - xBegin2;
|
int Xlength2 = xEnd2 - xBegin2;
|
||||||
|
|
||||||
// get current scintilla width W1
|
// get current scintilla width W1
|
||||||
RECT editorRect;
|
int w1 = getEditorTextZoneWidth();
|
||||||
(*_ppEditView)->getClientRect(editorRect);
|
|
||||||
|
|
||||||
int marginWidths = 0;
|
|
||||||
for (int m = 0; m < 4; m++)
|
|
||||||
{
|
|
||||||
marginWidths += (*_ppEditView)->execute(SCI_GETMARGINWIDTHN, m);
|
|
||||||
}
|
|
||||||
int w1 = editorRect.right - editorRect.left - marginWidths;
|
|
||||||
|
|
||||||
// resize map width W2 according W1, Xlength1 and Xlength2
|
// resize map width W2 according W1, Xlength1 and Xlength2
|
||||||
int w2 = (w1 * Xlength2)/Xlength1;
|
int w2 = (w1 * Xlength2)/Xlength1;
|
||||||
@ -151,9 +161,26 @@ void DocumentMap::wrapMap()
|
|||||||
|
|
||||||
// sync wrapping indent mode
|
// sync wrapping indent mode
|
||||||
_pScintillaEditView->execute(SCI_SETWRAPINDENTMODE, (*_ppEditView)->execute(SCI_GETWRAPINDENTMODE));
|
_pScintillaEditView->execute(SCI_SETWRAPINDENTMODE, (*_ppEditView)->execute(SCI_GETWRAPINDENTMODE));
|
||||||
|
|
||||||
|
|
||||||
|
// update the wrap needed data
|
||||||
|
_displayWidth = w1;
|
||||||
|
_displayZoom = (*_ppEditView)->execute(SCI_GETZOOM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DocumentMap::getEditorTextZoneWidth()
|
||||||
|
{
|
||||||
|
RECT editorRect;
|
||||||
|
(*_ppEditView)->getClientRect(editorRect);
|
||||||
|
|
||||||
|
int marginWidths = 0;
|
||||||
|
for (int m = 0; m < 4; m++)
|
||||||
|
{
|
||||||
|
marginWidths += (*_ppEditView)->execute(SCI_GETMARGINWIDTHN, m);
|
||||||
|
}
|
||||||
|
return editorRect.right - editorRect.left - marginWidths;
|
||||||
|
}
|
||||||
|
|
||||||
void DocumentMap::scrollMap()
|
void DocumentMap::scrollMap()
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
bool needToRecomputeWith();
|
||||||
|
int getEditorTextZoneWidth();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScintillaEditView **_ppEditView;
|
ScintillaEditView **_ppEditView;
|
||||||
@ -131,6 +133,11 @@ private:
|
|||||||
ViewZoneDlg _vzDlg;
|
ViewZoneDlg _vzDlg;
|
||||||
bool _isMainEditorWrap;
|
bool _isMainEditorWrap;
|
||||||
bool _wrapUnwrapTriggered;
|
bool _wrapUnwrapTriggered;
|
||||||
|
|
||||||
|
// for needToRecomputeWith function
|
||||||
|
int _displayZoom;
|
||||||
|
int _displayWidth;
|
||||||
|
//int _displayHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user