[FIXED_BUG] doc map: Fix folding (doc map view zone) problem.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@870 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
41a9d6854b
commit
f89bd5aeea
@ -276,7 +276,7 @@ void Buffer::setHeaderLineState(const std::vector<HeaderLineState> & folds, Scin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HeaderLineState> & Buffer::getHeaderLineState(ScintillaEditView * identifier) {
|
const std::vector<HeaderLineState> & Buffer::getHeaderLineState(const ScintillaEditView * identifier) const {
|
||||||
int index = indexOfReference(identifier);
|
int index = indexOfReference(identifier);
|
||||||
return _foldStates.at(index);
|
return _foldStates.at(index);
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ Lang * Buffer::getCurrentLang() const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
int Buffer::indexOfReference(ScintillaEditView * identifier) const {
|
int Buffer::indexOfReference(const ScintillaEditView * identifier) const {
|
||||||
int size = (int)_referees.size();
|
int size = (int)_referees.size();
|
||||||
for(int i = 0; i < size; i++) {
|
for(int i = 0; i < size; i++) {
|
||||||
if (_referees[i] == identifier)
|
if (_referees[i] == identifier)
|
||||||
|
@ -246,7 +246,7 @@ public :
|
|||||||
Position & getPosition(ScintillaEditView * identifier);
|
Position & getPosition(ScintillaEditView * identifier);
|
||||||
|
|
||||||
void setHeaderLineState(const std::vector<HeaderLineState> & folds, ScintillaEditView * identifier);
|
void setHeaderLineState(const std::vector<HeaderLineState> & folds, ScintillaEditView * identifier);
|
||||||
std::vector<HeaderLineState> & getHeaderLineState(ScintillaEditView * identifier);
|
const std::vector<HeaderLineState> & getHeaderLineState(const ScintillaEditView * identifier) const;
|
||||||
|
|
||||||
bool isUserDefineLangExt() const {
|
bool isUserDefineLangExt() const {
|
||||||
return (_userLangExt[0] != '\0');
|
return (_userLangExt[0] != '\0');
|
||||||
@ -355,7 +355,7 @@ private :
|
|||||||
|
|
||||||
void updateTimeStamp();
|
void updateTimeStamp();
|
||||||
|
|
||||||
int indexOfReference(ScintillaEditView * identifier) const;
|
int indexOfReference(const ScintillaEditView * identifier) const;
|
||||||
|
|
||||||
void setStatus(DocFileStatus status) {
|
void setStatus(DocFileStatus status) {
|
||||||
_currentStatus = status;
|
_currentStatus = status;
|
||||||
|
@ -1445,19 +1445,7 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
|
|||||||
saveCurrentPos();
|
saveCurrentPos();
|
||||||
|
|
||||||
// get foldStateInfo of current doc
|
// get foldStateInfo of current doc
|
||||||
std::vector<HeaderLineState> lineStateVector;
|
std::vector<HeaderLineState> lineStateVector = getCurrentFoldStates();
|
||||||
|
|
||||||
int maxLine = execute(SCI_GETLINECOUNT);
|
|
||||||
|
|
||||||
for (int line = 0; line < maxLine; line++)
|
|
||||||
{
|
|
||||||
int level = execute(SCI_GETFOLDLEVEL, line);
|
|
||||||
if (level & SC_FOLDLEVELHEADERFLAG)
|
|
||||||
{
|
|
||||||
bool expanded = (execute(SCI_GETFOLDEXPANDED, line) != 0);
|
|
||||||
lineStateVector.push_back(HeaderLineState(line, expanded));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// put the state into the future ex buffer
|
// put the state into the future ex buffer
|
||||||
_currentBuffer->setHeaderLineState(lineStateVector, this);
|
_currentBuffer->setHeaderLineState(lineStateVector, this);
|
||||||
@ -1479,18 +1467,8 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restore the collapsed info
|
// restore the collapsed info
|
||||||
std::vector<HeaderLineState> & lineStateVectorNew = newBuf->getHeaderLineState(this);
|
const std::vector<HeaderLineState> & lineStateVectorNew = newBuf->getHeaderLineState(this);
|
||||||
int nbLineState = lineStateVectorNew.size();
|
syncFoldStateWith(lineStateVectorNew);
|
||||||
for (int i = 0 ; i < nbLineState ; i++)
|
|
||||||
{
|
|
||||||
HeaderLineState & hls = lineStateVectorNew.at(i);
|
|
||||||
bool expanded = isFolded(hls._headerLineNumber);
|
|
||||||
// set line to state folded
|
|
||||||
if (hls._isExpanded != expanded)
|
|
||||||
{
|
|
||||||
fold(hls._headerLineNumber, !expanded);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
restoreCurrentPos();
|
restoreCurrentPos();
|
||||||
|
|
||||||
@ -1506,6 +1484,38 @@ void ScintillaEditView::activateBuffer(BufferID buffer)
|
|||||||
return; //all done
|
return; //all done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<HeaderLineState> ScintillaEditView::getCurrentFoldStates()
|
||||||
|
{
|
||||||
|
std::vector<HeaderLineState> lineStateVector;
|
||||||
|
int maxLine = execute(SCI_GETLINECOUNT);
|
||||||
|
|
||||||
|
for (int line = 0; line < maxLine; line++)
|
||||||
|
{
|
||||||
|
int level = execute(SCI_GETFOLDLEVEL, line);
|
||||||
|
if (level & SC_FOLDLEVELHEADERFLAG)
|
||||||
|
{
|
||||||
|
bool expanded = (execute(SCI_GETFOLDEXPANDED, line) != 0);
|
||||||
|
lineStateVector.push_back(HeaderLineState(line, expanded));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lineStateVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScintillaEditView::syncFoldStateWith(const std::vector<HeaderLineState> & lineStateVectorNew)
|
||||||
|
{
|
||||||
|
int nbLineState = lineStateVectorNew.size();
|
||||||
|
for (int i = 0 ; i < nbLineState ; i++)
|
||||||
|
{
|
||||||
|
const HeaderLineState & hls = lineStateVectorNew.at(i);
|
||||||
|
bool expanded = isFolded(hls._headerLineNumber);
|
||||||
|
// set line to state folded
|
||||||
|
if (hls._isExpanded != expanded)
|
||||||
|
{
|
||||||
|
fold(hls._headerLineNumber, !expanded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
|
void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask)
|
||||||
{
|
{
|
||||||
//actually only care about language and lexing etc
|
//actually only care about language and lexing etc
|
||||||
|
@ -231,6 +231,9 @@ public:
|
|||||||
|
|
||||||
void activateBuffer(BufferID buffer);
|
void activateBuffer(BufferID buffer);
|
||||||
|
|
||||||
|
std::vector<HeaderLineState> getCurrentFoldStates();
|
||||||
|
void syncFoldStateWith(const std::vector<HeaderLineState> & lineStateVectorNew);
|
||||||
|
|
||||||
void getText(char *dest, int start, int end) const;
|
void getText(char *dest, int start, int end) const;
|
||||||
void getGenericText(TCHAR *dest, int start, int end) const;
|
void getGenericText(TCHAR *dest, int start, int end) const;
|
||||||
void getGenericText(TCHAR *dest, int start, int end, int *mstart, int *mend) const;
|
void getGenericText(TCHAR *dest, int start, int end, int *mstart, int *mend) const;
|
||||||
|
@ -29,7 +29,16 @@ void DocumentMap::reloadMap()
|
|||||||
Document currentDoc = (*_ppEditView)->execute(SCI_GETDOCPOINTER);
|
Document currentDoc = (*_ppEditView)->execute(SCI_GETDOCPOINTER);
|
||||||
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETDOCPOINTER, 0, (LPARAM)currentDoc);
|
::SendMessage(_pScintillaEditView->getHSelf(), SCI_SETDOCPOINTER, 0, (LPARAM)currentDoc);
|
||||||
//_pScintillaEditView->wrap((*_ppEditView)->isWrap());
|
//_pScintillaEditView->wrap((*_ppEditView)->isWrap());
|
||||||
|
|
||||||
|
// sync with the current document
|
||||||
|
// Lexing
|
||||||
|
_pScintillaEditView->defineDocType((*_ppEditView)->getCurrentBuffer()->getLangType());
|
||||||
|
|
||||||
|
// folding
|
||||||
|
_pScintillaEditView->syncFoldStateWith((*_ppEditView)->getCurrentFoldStates());
|
||||||
|
|
||||||
scrollMap();
|
scrollMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +140,6 @@ BOOL CALLBACK DocumentMap::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara
|
|||||||
reloadMap();
|
reloadMap();
|
||||||
|
|
||||||
_pScintillaEditView->showIndentGuideLine(false);
|
_pScintillaEditView->showIndentGuideLine(false);
|
||||||
_pScintillaEditView->defineDocType((*_ppEditView)->getCurrentBuffer()->getLangType());
|
|
||||||
|
|
||||||
_pScintillaEditView->showMargin(0, false);
|
_pScintillaEditView->showMargin(0, false);
|
||||||
_pScintillaEditView->showMargin(1, false);
|
_pScintillaEditView->showMargin(1, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user