1 #include "ide.h"
2 
3 struct NavDlg : WithJumpLayout<TopWindow>, Navigator {
4 	typedef NavDlg CLASSNAME;
5 
6 	virtual bool Key(dword key, int count);
7 
8 	virtual int GetCurrentLine();
9 
10 	void GoTo();
OkNavDlg11 	void Ok()               { if(navlines.IsCursor()) Break(IDOK); }
ListSelNavDlg12 	void ListSel()          { navlines.GoBegin(); }
13 
14 	void Serialize(Stream& s);
15 
16 	NavDlg();
17 };
18 
Serialize(Stream & s)19 void NavDlg::Serialize(Stream& s)
20 {
21 
22 	SerializePlacement(s);
23 }
24 
25 INITBLOCK {
26 	RegisterGlobalConfig("NavDlg");
27 }
28 
29 NavDlg::NavDlg()
30 {
31 	CtrlLayoutOKCancel(*this, "Navigator");
32 	dlgmode = true;
33 	search.WhenEnter.Clear();
34 	Sizeable().Zoomable();
35 	Icon(IdeImg::Navigator());
36 	list.WhenSel << THISBACK(ListSel);
37 	list.WhenLeftDouble = THISBACK(Ok);
38 	navlines.WhenLeftDouble = THISBACK(Ok);
39 }
40 
Key(dword key,int count)41 bool NavDlg::Key(dword key, int count)
42 {
43 	if(key == K_UP || key == K_DOWN) {
44 		if(list.IsCursor())
45 			return list.Key(key, count);
46 		else
47 			list.GoBegin();
48 		return true;
49 	}
50 	return TopWindow::Key(key, count);
51 }
52 
GoTo()53 void NavDlg::GoTo()
54 {
55 	if(navlines.IsCursor()) {
56 		const NavLine& l = navlines.Get(0).To<NavLine>();
57 		theide->GotoPos(GetSourceFilePath(l.file), l.line);
58 	}
59 }
60 
GetCurrentLine()61 int NavDlg::GetCurrentLine()
62 {
63 	return theide->editor.GetCurrentLine();
64 }
65 
NavigatorDlg()66 void Ide::NavigatorDlg()
67 {
68 	NavDlg dlg;
69 	LoadFromGlobal(dlg, "NavDlg");
70 	dlg.theide = this;
71 	dlg.Search();
72 	if(dlg.ExecuteOK())
73 		dlg.GoTo();
74 	StoreToGlobal(dlg, "NavDlg");
75 }
76