ide: Developing new navigator

git-svn-id: svn://ultimatepp.org/upp/trunk@7543 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-07-27 07:34:05 +00:00
parent 51f035371a
commit 934a772905
5 changed files with 78 additions and 19 deletions

View file

@ -245,7 +245,7 @@ void MergeWith(String& dest, const char *delim, __List##I(E__NFSValue)) \
__List##I(E__Merge); \
} \
__Expand8(E__NFBody)
__Expand12(E__NFBody)
#undef E__TL
#undef E__NFIf
@ -315,7 +315,7 @@ void MergeWith(WString& dest, const wchar *delim, __List##I(E__NFSValue)) \
__List##I(E__Merge); \
} \
__Expand8(E__NFBody)
__Expand12(E__NFBody)
#undef E__TL
#undef E__NFIf

View file

@ -33,7 +33,7 @@ bool SplitTo(const char *s, const char *delim, __List##I(E__NFValue)); \
String Merge(const char *delim, __List##I(E__NFSValue)); \
void MergeWith(String& dest, const char *delim, __List##I(E__NFSValue)); \
__Expand8(E__NFBody)
__Expand12(E__NFBody)
#undef E__NFBody
#undef E__NFValue
@ -52,7 +52,7 @@ bool SplitTo(const wchar *s, const char *delim, __List##I(E__NFValue)); \
WString Merge(const wchar *delim, __List##I(E__NFSValue)); \
void MergeWith(WString& dest, const wchar *delim, __List##I(E__NFSValue)); \
__Expand8(E__NFBody)
__Expand12(E__NFBody)
#undef E__NFBody
#undef E__NFValue

View file

@ -85,6 +85,9 @@ struct ItemTextPart : Moveable<ItemTextPart> {
int pari;
};
Vector<ItemTextPart> ParseItemNatural(const String& name, const String& natural, const String& ptype,
const String& pname, const String& type, const String& tname,
const String& ctname, const char *s);
Vector<ItemTextPart> ParseItemNatural(const String& name, const CppItem& m, const char *natural);
Vector<ItemTextPart> ParseItemNatural(const CppItemInfo& m);
Vector<ItemTextPart> ParseItemNatural(const CppItemInfo& m);
@ -107,6 +110,11 @@ enum AdditionalKinds {
KIND_INCLUDEFOLDER,
};
void PaintText(Draw& w, int& x, int y, const char *text,
const Vector<ItemTextPart>& n, int starti, int count, bool focuscursor,
Color _ink, bool italic);
void PaintCppItemImage(Draw& w, int& x, int ry, int access, int kind, bool focuscursor);
struct CppItemInfoDisplay : public Display
{
bool namestart;

View file

@ -1,7 +1,7 @@
#include "Browser.h"
void PaintText(Draw& w, int& x, int y, const CppItemInfo& m, const Vector<ItemTextPart>& n,
int starti, int count, bool focuscursor, Color _ink)
void PaintText(Draw& w, int& x, int y, const char *text, const Vector<ItemTextPart>& n,
int starti, int count, bool focuscursor, Color _ink, bool italic)
{
for(int i = starti; i < count; i++) {
const ItemTextPart& p = n[i];
@ -23,20 +23,24 @@ void PaintText(Draw& w, int& x, int y, const CppItemInfo& m, const Vector<ItemTe
break;
case ITEM_CPP_TYPE:
case ITEM_CPP:
case ITEM_SIGN:
ink = LtBlue;
break;
case ITEM_SIGN:
ink = Magenta;
break;
}
if(m.overed)
if(italic)
f.Italic();
Size fsz = GetTextSize(~m.natural + p.pos, f, p.len);
w.DrawText(x, y, ~m.natural + p.pos, f, focuscursor ? _ink : ink, p.len);
Size fsz = GetTextSize(text + p.pos, f, p.len);
w.DrawText(x, y, text + p.pos, f, focuscursor ? _ink : ink, p.len);
x += fsz.cx;
}
}
void PaintText(Draw& w, int& x, int y, const CppItemInfo& m, const Vector<ItemTextPart>& n,
int starti, int count, bool focuscursor, Color _ink)
{
PaintText(w, x, y, ~m.natural, n, starti, count, focuscursor, _ink, m.overed);
}
void PaintCppItemImage(Draw& w, int& x, int ry, int access, int kind, bool focuscursor)
{
Image img = decode(access, PROTECTED, BrowserImg::mprotected(),

View file

@ -13,21 +13,68 @@ struct Navigator : TopWindow {
Navigator();
};
struct NavigatorDisplay : Display {
virtual void Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
CppItem m;
LoadFromString(m, q);
w.DrawRect(r, paper);
bool focuscursor = (style & (FOCUS|CURSOR)) == (FOCUS|CURSOR) || (style & SELECT);
if(IsNull(q)) return;
int x = r.left;
int fcy = Draw::GetStdFontCy();
int y = r.top + r.GetHeight() / 2 - fcy;
int x0 = x;
Vector<ItemTextPart> n = ParseItemNatural(m.name, m, ~m.natural + m.at);
int starti = 0;
for(int i = 0; i < n.GetCount(); i++)
if(n[i].type == ITEM_NAME) {
starti = i;
break;
}
PaintText(w, x, y, ~m.natural, n, 0, starti, focuscursor, ink, false);
if(m.item.GetCount()) {
String h = ' ' + m.item;
h.Cat("::");
w.DrawText(x, y, h, StdFont().Bold(), Magenta());
x += GetTextSize(h, StdFont()).cx;
}
int x1 = r.left;
PaintText(w, x1, y + fcy, ~m.natural, n, starti, n.GetCount(), focuscursor, ink, false);
}
};
void Navigator::Search()
{
String s = ~search;
list.Clear();
const CppBase& b = CodeBase();
// TODO: Be smarter with '::'
CppBase& b = CodeBase();
for(int i = 0; i < b.GetCount(); i++) {
String nest = b.GetKey(i);
String unest = ToUpper(nest);
const Array<CppItem>& item = b[i];
Array<CppItem>& item = b[i];
for(int j = 0; j < item.GetCount(); j++) {
const CppItem& m = item[j];
CppItem m;
{ DTIMING("Copy");
m = item[j]; }
m.item = nest; // Ugly trick...
String h = unest;
h << "::" << m.uname;
if(h.Find(s) >= 0)
list.Add(nest, m.natural, h);
{ DTIMING("CAT");
h << "::" << m.uname; }
int q;
{ DTIMING("FIND");
q = h.Find(s);
}
if(h.Find(s) >= 0) {
String sh;
{ DTIMING("StoreAsString");
sh = StoreAsString(m);
}
DTIMING("Add");
list.Add(nest, sh, h);
}
}
}
}
@ -44,7 +91,7 @@ Navigator::Navigator()
Add(list.VSizePos(cy, 0).HSizePos());
list.NoHeader();
list.AddColumn();
list.AddColumn();
list.AddColumn().SetDisplay(Single<NavigatorDisplay>());
list.AddColumn();
list.SetLineCy(2 * GetStdFontCy());