[NEW_FEATURE] Add scroll pos in the middle for function list feature.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1035 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-04-07 09:30:16 +00:00
parent 3aff6b23a1
commit 06756d2958
4 changed files with 30 additions and 3 deletions

View File

@ -2759,6 +2759,26 @@ void ScintillaEditView::foldChanged(int line, int levelNow, int levelPrev)
}
}
void ScintillaEditView::scrollPosToCenter(int pos)
{
execute(SCI_GOTOPOS, pos);
int line = execute(SCI_LINEFROMPOSITION, pos);
int firstVisibleDisplayLine = execute(SCI_GETFIRSTVISIBLELINE);
int firstVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine);
int nbLine = execute(SCI_LINESONSCREEN, firstVisibleDisplayLine);
int lastVisibleDocLine = execute(SCI_DOCLINEFROMVISIBLE, firstVisibleDisplayLine + nbLine);
int middleLine;
if (line - firstVisibleDocLine < lastVisibleDocLine - line)
middleLine = firstVisibleDocLine + nbLine/2;
else
middleLine = lastVisibleDocLine - nbLine/2;
int nbLines2scroll = line - middleLine;
scroll(0, nbLines2scroll);
}
void ScintillaEditView::hideLines() {
//Folding can screw up hide lines badly if it unfolds a hidden section.
//Adding runMarkers(hide, foldstart) directly (folding on single document) can help

View File

@ -199,8 +199,7 @@ struct LanguageName {
class ScintillaEditView : public Window
{
//friend class Notepad_plus;
friend class Finder;
friend class Finder;
public:
ScintillaEditView()
: Window(), _pScintillaFunc(NULL),_pScintillaPtr(NULL),
@ -626,6 +625,7 @@ public:
return ((_codepage == CP_CHINESE_TRADITIONAL) || (_codepage == CP_CHINESE_SIMPLIFIED) ||
(_codepage == CP_JAPANESE) || (_codepage == CP_KOREAN));
};
void scrollPosToCenter(int pos);
protected:
static HINSTANCE _hLib;

View File

@ -270,7 +270,8 @@ bool FunctionListPanel::openSelection()
int sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, pos);
(*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line);
(*_ppEditView)->execute(SCI_GOTOPOS, pos);
//(*_ppEditView)->execute(SCI_GOTOPOS, pos);
(*_ppEditView)->scrollPosToCenter(pos);
return true;
}

View File

@ -637,6 +637,12 @@ void FunctionMixParser::parse(std::vector<foundInfo> & foundInfos, size_t begin,
classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName);
// the second level
for (size_t i = 0; i < scannedZones.size(); i++)
{
vector< pair<int, int> > temp;
classParse(foundInfos, temp, commentZones, scannedZones[i].first, scannedZones[i].second, ppEditView, classStructName);
}
// invert scannedZones
getInvertZones(nonScannedZones, scannedZones, begin, end);