A++ navigator range button

git-svn-id: svn://ultimatepp.org/upp/trunk@614 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-11-06 18:29:42 +00:00
parent 9ad2de5a49
commit 6443f4fa99
15 changed files with 203 additions and 72 deletions

View file

@ -34,8 +34,11 @@ void ScanLayFile(const char *fn);
String MakeCodeRef(const String& scope, const String& item);
void SplitCodeRef(const String& ref, String& scope, String& item);
const CppItem *GetCodeRefItem(const String& ref, const String& rfile);
const CppItem *GetCodeRefItem(const String& ref);
int GetMatchLen(const char *s, const char *t);
enum { WITHBODY = 33 };
inline Font BrowserFont()
@ -118,12 +121,15 @@ public:
EditString search_item;
EditString search;
FrameRight<Button> clear;
int range;
ButtonOption rangebutton[4];
Callback WhenKeyItem;
Callback WhenClear;
String GetPm();
void Load();
void LoadScope();
void Goto(const String& coderef);
void Goto(const String& coderef, const String& rfile);
void Search();
void NameStart() { display.namestart = true; }
String GetCodeRef(int i) const;
@ -133,6 +139,7 @@ public:
bool Key(dword key, int count);
bool IsSearch() const;
void ClearSearch();
void SetRange(int r);
CodeBrowser();
};

View file

@ -1,4 +1,8 @@
PREMULTIPLIED
IMAGE_ID(range_all)
IMAGE_ID(range_nest)
IMAGE_ID(range_package)
IMAGE_ID(range_file)
IMAGE_ID(Clear)
IMAGE_ID(data)
IMAGE_ID(instance_data)
@ -26,44 +30,61 @@ IMAGE_ID(Ref)
IMAGE_ID(Query)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,237,153,207,107,212,64,20,199,159,214,31,37,40,20,247,224,197,163,158,252,7,10,43,172,165,7,193,131,215,218)
IMAGE_DATA(222,164,167,130,20,86,79,85,208,32,34,74,65,47,173,133,254,96,11,22,20,234,218,127,64,232,246,86,44,130,176,23)
IMAGE_DATA(21,255,3,79,158,234,165,140,147,172,217,157,36,51,153,55,243,182,155,38,59,223,101,216,77,200,231,59,153,151,55,111)
IMAGE_DATA(134,44,120,224,129,169,174,1,220,186,95,169,236,190,111,52,118,170,92,209,249,211,0,35,247,0,62,191,158,158,222,189)
IMAGE_DATA(201,117,9,224,234,28,192,193,43,207,99,251,203,203,135,19,92,167,248,53,119,1,62,126,154,154,98,235,43,43,155,35)
IMAGE_DATA(92,1,123,22,192,155,0,120,242,210,243,142,14,214,214,254,222,1,120,251,117,117,245,232,65,189,254,48,186,70,84,13)
IMAGE_DATA(224,241,115,0,182,89,173,178,71,243,243,47,100,247,25,244,191,0,240,123,103,102,134,45,84,42,63,190,53,155,127,110)
IMAGE_DATA(112,137,215,92,0,184,92,7,248,185,53,57,201,222,109,108,124,56,199,79,205,121,222,94,187,217,60,20,199,198,239,121)
IMAGE_DATA(187,49,62,206,190,183,219,191,198,184,130,115,231,1,46,62,171,213,246,214,151,150,182,162,235,110,3,188,217,94,92,252)
IMAGE_DATA(114,157,75,236,39,184,118,101,118,118,31,19,223,202,232,232,149,240,199,24,4,253,48,134,129,10,38,134,108,106,158,177)
IMAGE_DATA(236,230,248,114,243,180,252,41,158,92,49,80,243,154,84,114,124,201,121,100,43,143,92,49,80,243,173,86,43,179,57,190)
IMAGE_DATA(220,60,178,149,71,5,41,6,182,193,239,48,233,173,33,198,135,178,197,164,242,250,45,110,182,71,222,124,222,241,235,121)
IMAGE_DATA(216,63,255,180,79,217,38,127,82,195,80,12,36,91,67,84,34,17,182,152,84,30,51,21,51,39,115,206,124,222,241,235)
IMAGE_DATA(122,36,125,192,21,3,181,92,49,80,179,170,68,68,108,49,149,124,200,34,86,213,76,22,177,178,107,89,3,94,202,34)
IMAGE_DATA(199,96,201,134,188,146,117,59,131,227,145,43,6,106,182,31,43,155,120,15,146,223,218,190,1,210,205,116,101,151,177,88)
IMAGE_DATA(222,178,127,234,248,83,99,112,59,131,1,200,21,3,53,43,114,62,126,34,197,120,95,241,173,225,227,201,15,255,57,195)
IMAGE_DATA(201,236,131,186,153,20,19,139,254,169,227,79,221,131,111,30,127,0,87,12,204,52,12,197,64,242,6,25,149,72,132,55)
IMAGE_DATA(209,84,94,251,38,92,227,145,55,159,119,252,186,30,73,31,112,197,64,45,84,49,240,121,16,162,102,162,136,17,63,88)
IMAGE_DATA(31,145,19,31,134,232,163,99,187,43,67,79,49,31,153,135,192,102,73,233,65,225,145,172,210,35,111,62,239,248,245,227)
IMAGE_DATA(249,39,61,108,242,79,244,176,205,127,153,143,41,103,170,51,97,49,80,75,8,162,244,24,210,21,51,118,156,55,111,164)
IMAGE_DATA(1,110,147,40,125,136,89,109,197,38,102,134,21,107,232,161,159,217,150,172,198,3,197,246,195,131,50,6,74,12,145,172)
IMAGE_DATA(212,195,144,141,121,88,178,93,15,2,59,24,233,42,35,232,43,207,73,63,198,235,120,42,35,197,47,204,65,102,239,81)
IMAGE_DATA(100,190,195,246,222,124,216,123,20,115,252,39,129,239,120,216,179,5,86,65,222,38,5,162,109,179,158,146,150,57,10,31)
IMAGE_DATA(178,81,179,240,160,240,49,214,194,131,194,75,89,3,15,10,159,201,34,60,152,65,43,143,134,166,24,224,255,155,232,55)
IMAGE_DATA(159,88,237,45,138,129,61,31,99,45,60,40,188,148,53,253,159,206,146,207,100,17,30,174,24,100,202,39,12,220,55,120)
IMAGE_DATA(29,167,98,193,194,67,96,153,141,7,133,79,176,177,4,196,120,80,120,5,139,246,160,240,26,86,235,65,225,145,172,210)
IMAGE_DATA(67,204,53,108,83,221,3,246,163,138,33,182,245,83,5,217,25,80,42,115,86,32,181,171,147,230,65,100,174,78,136,7)
IMAGE_DATA(169,94,153,112,137,48,188,60,37,246,148,231,142,205,57,251,124,205,77,255,0,66,216,5,143,0,0,0,0,0,0,0)
IMAGE_END_DATA(896, 19)
IMAGE_DATA(120,156,237,153,95,104,91,85,28,199,127,235,90,83,146,170,165,33,230,101,172,47,74,177,101,43,246,193,70,90,104,107)
IMAGE_DATA(16,169,160,165,127,210,174,219,195,28,195,150,193,72,155,9,99,83,48,65,100,85,74,245,161,105,3,251,67,86,28,84)
IMAGE_DATA(58,235,16,11,123,17,210,193,30,134,67,25,244,69,101,48,217,147,176,39,65,168,3,231,207,115,238,205,77,79,146,115)
IMAGE_DATA(114,207,61,39,107,150,244,254,202,143,220,123,238,239,243,61,127,238,57,191,115,184,5,47,120,65,108,145,136,233,60,139)
IMAGE_DATA(197,0,14,28,48,175,23,22,76,167,70,203,232,51,203,232,253,195,135,166,206,218,154,233,244,154,150,89,188,101,244,25)
IMAGE_DATA(162,249,140,58,189,166,101,150,133,66,166,182,21,199,58,45,163,207,104,140,108,156,108,189,78,250,33,59,46,18,227,92)
IMAGE_DATA(250,229,8,205,23,12,6,83,173,173,173,25,234,62,159,239,152,32,238,56,49,140,199,227,134,119,118,118,146,78,67,156)
IMAGE_DATA(241,227,86,220,234,106,15,62,120,144,230,250,226,162,127,155,196,140,210,184,76,38,141,100,232,184,62,51,3,152,213,44)
IMAGE_DATA(123,220,205,155,67,152,201,0,215,167,167,115,113,190,64,0,82,205,205,144,225,121,83,19,164,104,140,244,40,23,188,156)
IMAGE_DATA(0,241,193,172,39,219,218,218,176,151,248,65,128,199,228,126,42,91,110,196,68,34,17,76,38,23,112,124,124,24,231,207)
IMAGE_DATA(157,195,63,223,10,99,212,83,143,103,207,198,176,191,191,159,54,246,29,26,71,99,16,7,73,108,16,215,95,106,193,255)
IMAGE_DATA(38,235,48,246,254,62,188,125,251,53,28,29,125,215,138,75,82,29,26,51,62,14,184,113,4,240,143,71,128,111,70,1)
IMAGE_DATA(99,49,31,30,58,244,42,141,91,162,237,153,155,155,51,124,104,104,8,23,55,0,195,232,193,250,232,11,36,46,102,148)
IMAGE_DATA(211,152,238,238,110,220,220,220,52,124,118,118,22,95,220,240,96,29,206,96,195,236,7,184,178,178,98,148,135,66,33,36)
IMAGE_DATA(19,236,241,216,216,24,78,76,12,99,87,215,97,132,31,206,32,252,242,55,214,29,62,141,131,131,97,28,25,25,54,98)
IMAGE_DATA(104,223,105,191,104,155,105,123,224,194,6,54,190,254,47,182,180,76,225,242,242,65,28,24,232,69,107,124,104,223,105,191)
IMAGE_DATA(104,155,61,77,223,227,212,244,125,210,214,17,35,166,163,163,195,234,111,32,251,75,125,169,161,161,139,212,255,70,174,174)
IMAGE_DATA(92,12,103,229,172,181,183,183,27,3,92,232,228,25,178,113,137,68,34,55,8,172,215,66,28,45,179,139,99,98,132,113)
IMAGE_DATA(86,12,79,143,29,103,250,44,16,8,228,143,179,74,90,123,5,224,237,211,126,127,102,53,157,190,209,67,204,42,175,3)
IMAGE_DATA(216,127,2,224,199,47,39,39,51,164,146,254,22,128,151,79,1,220,253,194,235,197,59,75,75,219,3,196,246,145,152,35)
IMAGE_DATA(0,223,126,55,49,129,151,83,169,171,251,137,81,182,129,52,101,0,224,147,207,189,222,39,119,47,93,250,231,61,128,229)
IMAGE_DATA(159,47,94,124,114,38,22,251,208,138,97,173,15,224,227,207,72,39,174,246,244,224,71,209,232,5,94,59,105,253,231,1)
IMAGE_DATA(30,221,56,122,20,207,251,253,191,221,91,95,255,171,151,24,27,211,4,16,36,27,193,239,215,194,97,252,250,202,149,111)
IMAGE_DATA(158,35,69,167,188,222,91,91,235,235,219,108,223,72,155,175,167,201,106,251,117,107,235,126,51,49,90,230,1,120,254,211)
IMAGE_DATA(190,190,91,151,147,201,107,86,28,153,242,95,93,159,159,255,137,172,146,14,182,30,26,155,58,121,242,142,204,248,250,27)
IMAGE_DATA(27,205,61,171,25,104,61,136,165,195,171,210,80,210,197,188,112,55,202,186,203,215,54,175,55,127,170,207,220,100,32,230)
IMAGE_DATA(109,166,146,203,215,56,47,233,181,99,110,50,16,243,188,243,120,137,179,185,203,215,24,47,233,181,99,85,146,12,84,7)
IMAGE_DATA(223,100,138,143,134,50,58,58,71,76,93,222,254,136,91,90,163,210,124,165,199,111,71,67,253,253,23,235,212,218,226,47)
IMAGE_DATA(180,189,144,12,56,71,67,169,137,164,113,196,212,229,101,150,98,201,197,92,97,190,210,227,151,211,40,212,1,55,25,136)
IMAGE_DATA(205,77,6,98,86,52,17,37,142,152,66,222,96,37,118,213,146,172,196,206,110,203,58,224,185,172,100,31,20,89,131,23)
IMAGE_DATA(178,238,201,224,233,152,155,12,196,108,57,118,54,182,13,156,107,219,186,1,138,221,233,206,206,99,101,121,197,250,117,251)
IMAGE_DATA(95,212,7,247,100,176,11,230,38,3,49,203,114,9,249,133,148,199,39,4,191,54,124,254,228,135,44,231,112,49,39,64)
IMAGE_DATA(236,78,146,137,66,253,186,253,47,106,67,194,249,248,3,184,201,192,153,237,133,100,192,249,130,44,53,145,52,190,68,235)
IMAGE_DATA(242,182,95,194,109,52,42,205,87,122,252,114,26,133,58,224,38,3,177,73,37,131,4,25,4,203,157,152,197,176,127,178)
IMAGE_DATA(58,44,199,190,12,86,199,142,205,237,12,59,150,167,195,211,96,216,82,38,212,208,225,37,89,161,70,165,249,74,143,95)
IMAGE_DATA(57,222,127,161,134,202,252,99,53,84,231,63,79,199,41,231,212,234,141,100,32,54,102,16,185,247,80,156,49,243,238,43)
IMAGE_DATA(205,59,178,93,60,38,233,212,193,206,106,37,182,96,101,40,177,14,53,236,87,182,34,107,163,33,197,150,67,67,167,15)
IMAGE_DATA(58,99,40,201,114,53,28,178,121,26,138,108,78,67,131,221,29,179,203,140,96,159,121,158,245,123,121,123,58,153,81,71)
IMAGE_DATA(207,152,131,168,174,81,205,188,201,238,124,249,80,215,168,206,254,63,11,188,169,161,206,86,177,85,201,215,36,106,122,199)
IMAGE_DATA(172,184,214,54,167,195,27,172,229,10,26,58,124,30,171,160,161,195,115,89,7,26,58,124,73,86,66,3,29,120,237,216)
IMAGE_DATA(158,73,6,242,255,155,40,55,95,176,219,43,36,3,117,62,143,85,208,208,225,185,172,211,255,211,41,242,37,89,9,141)
IMAGE_DATA(61,153,12,254,7,62,29,127,102,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_END_DATA(1344, 21)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,237,151,219,14,131,48,8,134,185,223,46,124,228,62,154,111,134,157,137,166,34,32,135,213,67,226,159,176,44,29)
IMAGE_DATA(223,79,109,77,233,96,128,1,0,16,97,47,110,204,163,12,143,227,56,98,194,35,195,207,236,18,1,143,12,191,97,3)
IMAGE_DATA(30,168,196,171,87,186,148,195,224,74,101,95,96,252,41,225,131,173,2,62,200,201,225,195,242,14,31,149,39,62,167,213)
IMAGE_DATA(143,62,191,131,219,240,1,110,229,131,220,179,213,241,48,224,58,147,167,91,113,157,209,210,45,87,127,146,43,142,73,117)
IMAGE_DATA(45,209,131,79,206,255,93,191,107,215,111,55,143,150,55,212,189,78,55,189,25,228,85,234,98,23,97,193,181,223,142,242)
IMAGE_DATA(172,44,151,239,101,169,71,164,174,22,61,249,236,252,41,75,191,123,89,109,204,202,122,61,158,166,15,124,129,28,6,210)
IMAGE_DATA(127,78,238,68,171,139,82,228,160,185,14,95,199,245,118,30,43,181,30,13,41,247,142,190,194,181,86,244,171,159,135,185)
IMAGE_DATA(75,30,151,107,218,139,147,58,69,198,159,123,184,110,30,5,234,102,53,225,241,160,172,215,131,230,51,60,245,16,175,32)
IMAGE_DATA(2,187,241,104,163,245,176,176,90,125,133,207,236,165,123,15,163,117,9,255,151,247,47,193,158,166,9,87,237,245,57,0)
IMAGE_END_DATA(288, 6)
IMAGE_DATA(120,156,237,153,91,142,131,48,12,69,253,63,243,209,37,103,105,236,44,67,43,129,130,235,247,45,47,77,141,44,33,234)
IMAGE_DATA(115,29,236,40,9,42,61,232,65,68,189,147,103,141,252,24,139,125,94,21,141,133,165,130,198,192,246,138,6,194,51,118)
IMAGE_DATA(241,176,6,194,43,108,88,3,225,29,214,213,64,248,32,171,106,140,115,45,234,218,24,162,151,86,195,168,127,210,194,139)
IMAGE_DATA(193,185,102,53,196,103,245,66,122,188,215,8,139,143,52,82,227,163,19,225,255,242,72,237,145,190,71,231,92,125,190,158)
IMAGE_DATA(103,198,98,128,14,28,225,251,52,77,72,241,16,254,197,46,94,208,64,248,13,91,208,184,231,36,252,218,53,236,162,39)
IMAGE_DATA(3,116,2,247,167,1,58,125,180,130,78,151,44,161,35,242,9,29,147,103,58,135,229,175,190,127,130,219,240,5,110,229)
IMAGE_DATA(139,220,189,109,199,197,64,218,153,50,187,149,180,51,70,118,203,85,159,197,170,207,180,188,17,223,131,7,199,255,173,223)
IMAGE_DATA(185,245,123,27,199,200,7,242,158,103,23,61,25,224,214,214,111,188,220,111,94,92,148,149,226,179,44,215,168,228,181,124)
IMAGE_DATA(79,30,29,63,103,249,125,150,181,158,69,217,172,198,221,236,135,126,137,45,6,218,55,167,180,162,205,69,105,186,243,216)
IMAGE_DATA(132,110,226,120,251,122,214,230,124,220,181,216,43,234,42,199,90,85,175,119,63,118,137,147,98,67,189,56,104,167,64,244)
IMAGE_DATA(165,151,219,77,163,209,220,172,193,51,26,156,205,106,240,120,129,231,26,234,17,68,97,55,26,111,127,187,36,88,43,191)
IMAGE_DATA(193,35,189,76,247,176,154,151,241,31,153,127,0,123,152,253,1,11,246,165,32,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_END_DATA(384, 8)

View file

@ -7,6 +7,23 @@ bool MatchCib(const String& s, const String& match)
return q > 0 && !iscid(s[q - 1]) || q == 0;
}
bool MatchPm(int file, const String& pm)
{
if(IsNull(pm))
return true;
return GetCppFile(file).StartsWith(pm);
}
bool MatchPm(const Array<CppItem>& n, const String& pm)
{
if(IsNull(pm))
return true;
for(int i = 0; i < n.GetCount(); i++)
if(MatchPm(n[i].file, pm))
return true;
return false;
}
bool HasItem(const Array<CppItem>& n, const String& m)
{
if(IsNull(m))
@ -39,10 +56,25 @@ struct ScopeLess {
}
};
String CodeBrowser::GetPm()
{
String pm;
if(TheIde() && range)
if(range == 1)
pm = TheIde()->IdeGetNestFolder();
else {
pm = TheIde()->IdeGetFileName();
if(range == 2)
pm = GetFileFolder(pm);
}
return pm;
}
void CodeBrowser::Load()
{
String find = ToUpper((String)~search);
String match = ToUpper((String)~search_scope);
String pm = GetPm();
Vector<String> txt;
Vector<Value> ndx;
Index<int> fi;
@ -50,7 +82,7 @@ void CodeBrowser::Load()
String s = CodeBase().GetKey(i);
const Array<CppItem>& n = CodeBase()[i];
if(s.GetCount()) {
if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find))) {
if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find)) && MatchPm(n, pm)) {
txt.Add(s);
ndx.Add(s);
}
@ -58,8 +90,10 @@ void CodeBrowser::Load()
else {
int i = 0;
while(i < n.GetCount()) {
fi.FindAdd(n[i].file);
i = FindNext(n, i);
int f = n[i].file;
if(fi.Find(f) < 0 && MatchPm(f, pm))
fi.Add(f);
i++;
}
}
}
@ -135,10 +169,13 @@ void CodeBrowser::LoadScope()
VectorMap<String, bool> inherited;
if(file < 0)
GatherMethods(scope, inherited, false);
for(int i = 0; i < n.GetCount(); i = FindNext(n, i)) {
Index<String> set;
for(int i = 0; i < n.GetCount(); i = file < 0 ? FindNext(n, i) : i + 1) {
CppItemInfo m;
(CppItem&) m = n[i];
if((file < 0 || m.file == file) && m.uname.StartsWith(match) && (all || m.uname.StartsWith(find))) {
if((file < 0 || m.file == file) && m.uname.StartsWith(match) &&
(all || m.uname.StartsWith(find)) && set.Find(m.qitem) < 0) {
set.Add(m.qitem);
int q = inherited.Find(m.qitem);
if(q >= 0) {
m.over = true;
@ -188,7 +225,7 @@ int SearchItemFilter(int c)
return IsAlNum(c) ? c : 0;
}
void CodeBrowser::Goto(const String& coderef)
void CodeBrowser::Goto(const String& coderef, const String& rfile)
{
if(IsNull(coderef))
item.KillCursor();
@ -201,7 +238,7 @@ void CodeBrowser::Goto(const String& coderef)
String sc, im;
SplitCodeRef(coderef, sc, im);
if(IsNull(sc)) {
const CppItem *m = GetCodeRefItem(coderef);
const CppItem *m = GetCodeRefItem(coderef, rfile);
if(m)
scope.FindSetCursor(m->file, 2);
}
@ -262,6 +299,14 @@ void CodeBrowser::ClearSearch()
WhenClear();
}
void CodeBrowser::SetRange(int r)
{
range = r;
for(int i = 0; i < 4; i++)
rangebutton[i] <<= range == i;
Load();
}
CodeBrowser::CodeBrowser()
{
scope.AddKey();
@ -285,4 +330,10 @@ CodeBrowser::CodeBrowser()
clear.SetImage(BrowserImg::Clear());
clear.NoWantFocus();
clear <<= THISBACK(ClearSearch);
range = 0;
static const char *tip[] = { "All", "Nest", "Package", "File" };
for(int i = 0; i < 4; i++)
rangebutton[i].SetImage(BrowserImg::Get(BrowserImg::I_range_all + i)).Tip(tip[i])
<<= THISBACK1(SetRange, i);
rangebutton[0] <<= true;
}

View file

@ -15,7 +15,7 @@ void ReferenceDlg::EnterItemOk()
void ReferenceDlg::Set(const String& s)
{
Goto(s);
Goto(s, Null);
reference <<= s;
}

View file

@ -21,7 +21,15 @@ String MakeCodeRef(const String& nest, const String& item)
return item;
}
const CppItem *GetCodeRefItem(const String& ref)
int GetMatchLen(const char *s, const char *t)
{
int i = 0;
while(s[i] == t[i] && *s)
i++;
return i;
}
const CppItem *GetCodeRefItem(const String& ref, const String& rfile)
{
String scope;
String item;
@ -33,5 +41,22 @@ const CppItem *GetCodeRefItem(const String& ref)
q = FindItem(n, item);
if(q < 0)
return NULL;
if(!IsNull(rfile)) {
int i = q;
int qml = 0;
while(i < n.GetCount() && n[i].qitem == item) {
int ml = GetMatchLen(GetCppFile(n[i].file), rfile);
if(ml > qml) {
q = i;
qml = ml;
}
i++;
}
}
return &n[q];
}
const CppItem *GetCodeRefItem(const String& ref)
{
return GetCodeRefItem(ref, Null);
}

View file

@ -4,7 +4,7 @@
#include "ide\Common/init"
#include "PdfDraw/init"
#include "RichEdit/init"
#define BLITZ_INDEX__ F85DF9C95A76CA3576D27A3E33F57D4BB
#define BLITZ_INDEX__ F6E4212E192F89F940FE740C750E7BAB0
#include "TopicI.icpp"
#undef BLITZ_INDEX__
#endif