ide: Navigator: Now jumping to layout / iml items, Laydes: Nos jumping to first use of layout

git-svn-id: svn://ultimatepp.org/upp/trunk@8663 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-07-10 12:34:33 +00:00
parent deffbd37df
commit fcb86cf257
7 changed files with 103 additions and 29 deletions

View file

@ -344,6 +344,39 @@ void Ide::CtrlClick(int pos)
ContextGoto0(pos);
}
bool Ide::GotoDesignerFile(const String& path, const String& scope, const String& name, int line)
{
if(ToLower(GetFileExt(path)) == ".lay") {
AddHistory();
EditFile(path);
LayDesigner *l = dynamic_cast<LayDesigner *>(~designer);
if(l) {
if(scope.StartsWith("With"))
l->FindLayout(scope.Mid(4), name);
}
else {
editor.SetCursor(editor.GetPos(line - 1));
editor.TopCursor(4);
editor.SetFocus();
}
AddHistory();
return true;
}
else
if(ToLower(GetFileExt(path)) == ".iml") {
AddHistory();
EditFile(path);
IdeIconDes *l = dynamic_cast<IdeIconDes *>(~designer);
if(l)
l->FindId(name);
else
editor.SetFocus();
AddHistory();
return true;
}
return false;
}
void Ide::JumpToDefinition(const Array<CppItem>& n, int q, const String& scope)
{
String qitem = n[q].qitem;
@ -375,32 +408,37 @@ void Ide::JumpToDefinition(const Array<CppItem>& n, int q, const String& scope)
String path = GetSourceFilePath(pos.file);
editastext.RemoveKey(path);
editashex.RemoveKey(path);
if(ToLower(GetFileExt(path)) == ".lay") {
AddHistory();
EditFile(path);
LayDesigner *l = dynamic_cast<LayDesigner *>(~designer);
if(l) {
if(scope.StartsWith("With"))
l->FindLayout(scope.Mid(4), pos.name);
}
else {
editor.SetCursor(editor.GetPos(pos.line - 1));
editor.TopCursor(4);
editor.SetFocus();
}
AddHistory();
}
else
if(ToLower(GetFileExt(path)) == ".iml") {
AddHistory();
EditFile(path);
IdeIconDes *l = dynamic_cast<IdeIconDes *>(~designer);
if(l)
l->FindId(pos.name);
else
editor.SetFocus();
AddHistory();
}
else
if(!GotoDesignerFile(path, scope, pos.name, pos.line))
GotoCpp(pos);
}
void Ide::GotoFileAndId(const String& path, const String& id)
{
AddHistory();
EditFile(path);
WString wid = id.ToWString();
if(editor.GetLength() < 100000) {
for(int i = 0; i < editor.GetLineCount(); i++) {
WString ln = editor.GetWLine(i);
int q = ln.Find(wid);
while(q >= 0) {
if(q == 0 || !iscid(ln[q - 1]) && !iscid(ln[q + wid.GetCount()])) {
editor.SetCursor(editor.GetPos(i, q));
editor.CenterCursor();
return;
}
if(q + 1 >= ln.GetCount())
break;
q = ln.Find(wid, q + 1);
}
}
}
AddHistory();
}
void IdeGotoFileAndId(const String& path, const String& id)
{
Ide *ide = dynamic_cast<Ide *>(TheIde());
if(ide)
ide->GotoFileAndId(path, id);
}

View file

@ -139,6 +139,8 @@ bool IdeIsDebugLock();
void IdeSetBar();
void IdeGotoFileAndId(const String& path, const String& id);
#include "Host.h"
struct IdeMacro {

View file

@ -5,6 +5,7 @@
#include <RichEdit/RichEdit.h>
#include <CodeEditor/CodeEditor.h>
#include <IconDes/IconDes.h>
#include <ide/Browser/Browser.h>
#define LAYOUTFILE <ide/LayDes/LayDes.lay>
#include <CtrlCore/lay.h>
@ -448,6 +449,8 @@ private:
void MainMenuBar(Bar& bar);
void EditMenu(Bar& bar);
void GotoUsing();
void SyncUsc();
void Save();

View file

@ -41,3 +41,4 @@ KEY2(MOVELAYOUTUP, "Move Layout Up", K_ALT|K_CTRL_PAGEUP, K_ALT|K_CTRL_UP)
KEY2(MOVELAYOUTDOWN, "Move Layout Down", K_ALT|K_CTRL_PAGEDOWN, K_ALT|K_CTRL_DOWN)
KEY(VISGEN, "Generate code..", K_ALT_C)
KEY(FINDSOURCE, "Go to class using this layout..", K_ALT_J)

View file

@ -29,6 +29,7 @@ void LayDes::EditBar(Bar& bar)
bar.Add(islayout, "Select all", CtrlImg::select_all(), THISBACK(SelectAll))
.Key(K_CTRL_A);
bar.Add(islayout, AK_VISGEN, LayImg::Members(), THISBACK(VisGen));
bar.Add(islayout, AK_FINDSOURCE, IdeCommonImg::Cpp(), THISBACK(GotoUsing));
bar.Separator();
bar.Add(islayout && CurrentLayout().IsUndo(), "Undo", CtrlImg::undo(), THISBACK(Undo))
.Key(K_ALT_BACKSPACE)
@ -158,6 +159,30 @@ void LayDes::Settings()
SyncItems();
}
void LayDes::GotoUsing()
{
if(IsNull(currentlayout))
return;
String lid = "With" + CurrentLayout().name;
const Workspace& wspc = GetIdeWorkspace();
for(int i = 0; i < wspc.GetCount(); i++) { // find lowest file time
const Package& pk = wspc.GetPackage(i);
String n = wspc[i];
for(int i = 0; i < pk.GetCount(); i++) {
String path = SourcePath(n, pk.file[i]);
if(IsCPPFile(path) || IsHFile(path)) {
const PPFile& f = GetPPFile(NormalizeSourcePath(path));
if(FindIndex(f.keywords, lid) >= 0) {
IdeGotoFileAndId(path, lid);
return;
}
}
}
}
Exclamation("No code found using this layout.");
}
void LayDes::OptionBar(Bar& bar)
{
bar.Add("Use grid", LayImg::Grid(), THISBACK(ToggleGrid))

View file

@ -248,8 +248,11 @@ void Navigator::Navigate()
q = (i + l.GetCount() + 1) % l.GetCount();
break;
}
if(q >= 0 && q < l.GetCount())
theide->GotoPos(GetSourceFilePath(l[q].file), l[q].line);
if(q >= 0 && q < l.GetCount()) {
String path = GetSourceFilePath(l[q].file);
if(!theide->GotoDesignerFile(path, m.nest, m.name, l[q].line))
theide->GotoPos(path, l[q].line);
}
}
}
navigating = false;

View file

@ -1050,7 +1050,9 @@ public:
bool OpenMainPackage();
void NewMainPackage();
bool GotoDesignerFile(const String& path, const String& scope, const String& name, int line);
void JumpToDefinition(const Array<CppItem>& n, int q, const String& scope);
void GotoFileAndId(const String& path, const String& id);
void SearchTopics();
void ShowTopics();
void ShowTopicsWin();