theide: Ctrl+Click onto symbol jumps to definition

git-svn-id: svn://ultimatepp.org/upp/trunk@1189 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-05-15 18:48:42 +00:00
parent 9c2cc3a794
commit c07c50dca7
5 changed files with 34 additions and 8 deletions

View file

@ -549,13 +549,18 @@ bool CodeEditor::GetWordPos(int pos, int& l, int& h) {
return true;
}
String CodeEditor::GetWord()
String CodeEditor::GetWord(int pos)
{
int l, h;
GetWordPos(cursor, l, h);
GetWordPos(pos, l, h);
return Get(l, h - l);
}
String CodeEditor::GetWord()
{
return GetWord(cursor);
}
void CodeEditor::LeftDouble(Point p, dword keyflags) {
int l, h;
int pos = GetMousePos(p);
@ -566,6 +571,10 @@ void CodeEditor::LeftDouble(Point p, dword keyflags) {
}
void CodeEditor::LeftDown(Point p, dword keyflags) {
if((keyflags & K_CTRL) && WhenCtrlClick) {
WhenCtrlClick(GetMousePos(p));
return;
}
LineEdit::LeftDown(p, keyflags);
WhenLeftDown();
}
@ -612,6 +621,8 @@ void CodeEditor::MouseMove(Point p, dword f) {
Image CodeEditor::CursorImage(Point p, dword keyflags)
{
if(WhenCtrlClick && (keyflags & K_CTRL))
return Image::Hand();
if(tip.IsOpen())
return Image::Arrow();
return LineEdit::CursorImage(p, keyflags);

View file

@ -393,6 +393,7 @@ public:
Callback WhenSelection;
Gate1<MouseTip&> WhenTip;
Callback WhenLeftDown;
Callback1<int> WhenCtrlClick;
Callback WhenAnnotationMove;
Callback WhenAnnotationClick;
Callback WhenAnnotationRightClick;
@ -445,6 +446,7 @@ public:
void MoveNextBrk(bool sel);
void MovePrevBrk(bool sel);
String GetWord(int pos);
String GetWord();
bool GetWordPos(int pos, int& l, int& h);

View file

@ -862,13 +862,13 @@ bool IsPendif(const String& l)
return l.Find("#endif") >= 0;
}
void Ide::ContextGoto()
void Ide::ContextGoto0(int pos)
{
if(designer)
return;
if(!editor.assist_active)
return;
int li = editor.GetCursorLine();
int li = editor.GetLine(pos);
String l = editor.GetUtf8Line(li);
if(IsPif(l) || IsPelse(l)) {
int lvl = 0;
@ -911,14 +911,14 @@ void Ide::ContextGoto()
}
return;
}
q = editor.GetCursor();
q = pos;
while(iscid(editor.Ch(q - 1)))
q--;
String tp;
Vector<String> xp = editor.ReadBack(q);
Index<String> type;
Parser parser;
int ci = editor.GetCursor();
int ci = pos;
for(;;) {
int c = editor.Ch(ci);
if(c == '{' && editor.Ch(ci + 1)) {
@ -937,7 +937,7 @@ void Ide::ContextGoto()
if(type.GetCount() == 0)
return;
}
String id = editor.GetWord();
String id = editor.GetWord(pos);
if(id.GetCount() == 0)
return;
Vector<String> scope;
@ -988,6 +988,16 @@ void Ide::ContextGoto()
}
}
void Ide::ContextGoto()
{
ContextGoto0(editor.GetCursor());
}
void Ide::CtrlClick(int pos)
{
ContextGoto0(pos);
}
void Ide::JumpToDefinition(const Array<CppItem>& n, int q)
{
String qitem = n[q].qitem;

View file

@ -389,7 +389,7 @@ struct AssistEditor : CodeEditor {
void NewTopic(String group, String coderef);
bool Esc();
void SerializeNavigator(Stream& s);
typedef AssistEditor CLASSNAME;
@ -870,7 +870,9 @@ public:
void ScanFile();
bool SwapSIf(const char *cref);
void SwapS();
void ContextGoto0(int pos);
void ContextGoto();
void CtrlClick(int pos);
void ConsoleMenu(Bar& menu);

View file

@ -613,6 +613,7 @@ Ide::Ide()
showtime = true;
editor.WhenTip = THISBACK(EditorTip);
editor.WhenCtrlClick = THISBACK(CtrlClick);
}
Ide::~Ide()