ultimatepp/uppsrc/ide/Jump.cpp
cxl 9288d7db01 .docs
git-svn-id: svn://ultimatepp.org/upp/trunk@8618 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2015-06-29 19:30:28 +00:00

70 lines
1.2 KiB
C++

#include "ide.h"
struct NavDlg : WithJumpLayout<TopWindow>, Navigator {
typedef NavDlg CLASSNAME;
virtual bool Key(dword key, int count);
virtual int GetCurrentLine();
void GoTo();
void Serialize(Stream& s);
NavDlg();
};
void NavDlg::Serialize(Stream& s)
{
SerializePlacement(s);
}
INITBLOCK {
RegisterGlobalConfig("NavDlg");
}
NavDlg::NavDlg()
{
CtrlLayoutOKCancel(*this, "Navigator");
dlgmode = true;
search.WhenEnter.Clear();
Sizeable().Zoomable();
Icon(IdeImg::Navigator());
}
bool NavDlg::Key(dword key, int count)
{
if(key == K_UP || key == K_DOWN) {
if(list.IsCursor())
return list.Key(key, count);
else
list.GoBegin();
return true;
}
return TopWindow::Key(key, count);
}
void NavDlg::GoTo()
{
if(navlines.IsCursor()) {
const NavLine& l = navlines.Get(0).To<NavLine>();
theide->GotoPos(GetSourceFilePath(l.file), l.line);
}
}
int NavDlg::GetCurrentLine()
{
return theide->editor.GetCurrentLine();
}
void Ide::NavigatorDlg()
{
NavDlg dlg;
LoadFromGlobal(dlg, "NavDlg");
dlg.theide = this;
dlg.Search();
if(dlg.ExecuteOK())
dlg.GoTo();
StoreToGlobal(dlg, "NavDlg");
}