Improved appearance of package file list underlines, U++ LOG macros now highlighted (default green)

git-svn-id: svn://ultimatepp.org/upp/trunk@618 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-11-07 11:15:08 +00:00
parent ec204cf931
commit 61af975ae0
7 changed files with 132 additions and 118 deletions

View file

@ -858,7 +858,8 @@ void CodeEditor::DefaultHlStyles()
SetHlStyle(INK_SQLBASE, Black);
SetHlStyle(INK_SQLFUNC, Black);
SetHlStyle(INK_SQLBOOL, Black);
SetHlStyle(INK_UPPMACROS, Black);
SetHlStyle(INK_UPPMACROS, Cyan);
SetHlStyle(INK_UPPLOGS, Green);
SetHlStyle(PAPER_BLOCK1, Blend(LtBlue, White, 240));
SetHlStyle(PAPER_BLOCK2, Blend(LtGreen, White, 240));

View file

@ -189,10 +189,8 @@ protected:
static Index<String> keyword[HIGHLIGHT_COUNT];
static Index<String> name[HIGHLIGHT_COUNT];
static Index<String> kw_upp_macros;
static Index<String> kw_sql_base;
static Index<String> kw_sql_bool;
static Index<String> kw_sql_func;
static Index<String> kw_upp;
static int kw_macros, kw_logs, kw_sql_base, kw_sql_func;
struct Isx : Moveable<Isx> {
int line;
@ -304,6 +302,7 @@ protected:
struct HlSt;
static int InitUpp(const char **q);
static void InitKeywords();
const wchar *HlString(HlSt& hls, const wchar *p);

View file

@ -227,10 +227,11 @@ void CodeEditor::Bracket(int pos, HlSt& hls)
Index<String> CodeEditor::keyword[HIGHLIGHT_COUNT];
Index<String> CodeEditor::name[HIGHLIGHT_COUNT];
Index<String> CodeEditor::kw_upp_macros;
Index<String> CodeEditor::kw_sql_base;
Index<String> CodeEditor::kw_sql_bool;
Index<String> CodeEditor::kw_sql_func;
Index<String> CodeEditor::kw_upp;
int CodeEditor::kw_macros;
int CodeEditor::kw_logs;
int CodeEditor::kw_sql_base;
int CodeEditor::kw_sql_func;
const Index<String>& CodeEditor::CppKeywords()
{
@ -238,6 +239,13 @@ const Index<String>& CodeEditor::CppKeywords()
return keyword[0];
}
int CodeEditor::InitUpp(const char **q)
{
while(*q)
kw_upp.Add(*q++);
return kw_upp.GetCount();
}
void CodeEditor::InitKeywords()
{
if(keyword[0].GetCount() == 0)
@ -313,14 +321,17 @@ void CodeEditor::InitKeywords()
};
static const char *upp_macros[] = {
"CLASSNAME", "THISBACK", "THISBACK1", "THISBACK2", "THISBACK3",
"QUOTE", "XASSERT", "NEVER", "XNEVER", "CHECK", "XCHECK", "ASSERT", "RQUOTE",
"NAMESPACE_UPP", "END_UPP_NAMESPACE",
NULL
};
static const char *upp_logs[] = {
"LOG", "LOGF", "DUMP", "DUMPC", "DUMPCC", "DUMPCCC",
"LLOG", "LLOGF", "LDUMP", "LDUMPC", "LDUMPCC", "LDUMPCCC",
"DLOG", "DLOGF", "DDUMP", "DDUMPC", "DDUMPCC", "DDUMPCCC",
"LOGBEGIN", "LOGEND", "LOGBLOCK", "LOGHEXDUMP",
"QUOTE", "XASSERT", "NEVER", "XNEVER", "CHECK", "XCHECK", "ASSERT",
"RLOG", "RLOGBEGIN", "RLOGEND", "RLOGBLOCK", "RLOGHEXDUMP", "RQUOTE",
"RLOGSRCPOS", "RDUMP", "RDUMPC",
"NAMESPACE_UPP", "END_UPP_NAMESPACE",
"RLOG", "RLOGF", "RDUMP", "RDUMPC", "RDUMPCC", "RDUMPCCC",
"LOGBEGIN", "LOGEND", "LOGBLOCK", "LOGHEXDUMP", "LOGSRCPOS",
"RLOGBEGIN", "RLOGEND", "RLOGBLOCK", "RLOGHEXDUMP", "RLOGSRCPOS",
NULL
};
static const char *sql_base[] = {
@ -366,18 +377,11 @@ void CodeEditor::InitKeywords()
while(*q)
name[i].Add(*q++);
}
q = upp_macros;
while(*q)
kw_upp_macros.Add(*q++);
q = sql_base;
while(*q)
kw_sql_base.Add(*q++);
q = sql_func;
while(*q)
kw_sql_func.Add(*q++);
q = sql_bool;
while(*q)
kw_sql_bool.Add(*q++);
kw_macros = InitUpp(upp_macros);
kw_logs = InitUpp(upp_logs);
kw_sql_base = InitUpp(sql_base);
kw_sql_func = InitUpp(sql_func);
InitUpp(sql_bool);
}
}
@ -575,12 +579,14 @@ void CodeEditor::HighlightLine(int line, Vector<LineEdit::Highlight>& hl, int po
while(iscid(*q) && q < e)
id.Cat(*q++);
String iid = id;
int uq = kw_upp.Find(iid);
hls.Put(int(q - p), keyword[highlight].Find(iid) >= 0 ? hl_style[INK_KEYWORD] :
name[highlight].Find(iid) >= 0 ? hl_style[INK_UPP] :
kw_upp_macros.Find(iid) >= 0 ? hl_style[INK_UPPMACROS] :
kw_sql_base.Find(iid) >= 0 ? hl_style[INK_SQLBASE] :
kw_sql_func.Find(iid) >= 0 ? hl_style[INK_SQLFUNC] :
kw_sql_bool.Find(iid) >= 0 ? hl_style[INK_SQLBOOL] :
uq >= 0 ? uq < kw_macros ? hl_style[INK_UPPMACROS] :
uq < kw_logs ? hl_style[INK_UPPLOGS] :
uq < kw_sql_base ? hl_style[INK_SQLBASE] :
uq < kw_sql_func ? hl_style[INK_SQLFUNC] :
hl_style[INK_SQLBOOL] :
IsUpperString(iid) && !sm.macro ? hl_style[INK_UPPER] :
hl_style[INK_NORMAL]);
p = q;

View file

@ -41,3 +41,4 @@ HL_COLOR(INK_SQLBASE, "Sql keywords", 1)
HL_COLOR(INK_SQLFUNC, "Sql functions", 1)
HL_COLOR(INK_SQLBOOL, "Sql boolean expressions", 1)
HL_COLOR(INK_UPPMACROS, "U++ macros", 0)
HL_COLOR(INK_UPPLOGS, "U++ log macros", 0)

View file

@ -33,7 +33,7 @@ const wchar *strdirsep(const wchar *s) {
return NULL;
}
void DrawFileName(Draw& w, int x, int y, int wcx, int cy, const WString& mname, bool isdir, Font font,
void DrawFileName(Draw& ww, int x0, int y, int wcx, int cy, const WString& mname, bool isdir, Font font,
Color ink, Color extink, const WString& desc, Font descfont, bool justname, Color uln)
{
FontInfo fi = font.Info();
@ -43,72 +43,75 @@ void DrawFileName(Draw& w, int x, int y, int wcx, int cy, const WString& mname,
extpos = -1;
const wchar *ext = extpos >= slash && extpos >= 0 ? mname.Begin() + extpos + 1
: mname.End();
const wchar *name = mname;
if(justname && slash >= 0)
name += slash + 1;
int txtcx = GetTextSize(fi, name);
int x0 = x;
if(txtcx <= wcx) {
w.DrawText(x, y, name, font, ink, (int)(ext - name));
w.DrawText(x + GetTextSize(fi, name, ext), y, ext, font, extink, (int)(mname.End() - ext));
if(!IsEmpty(desc))
DrawTextEllipsis(w, x + fi.GetHeight(), y, wcx - txtcx,
desc, "...", descfont, extink);
x += txtcx;
}
else {
int dot3 = 3 * fi['.'];
if(2 * dot3 > wcx) {
int n = GetTextFitCount(fi, name, wcx);
w.DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
for(int pass = IsNull(uln); pass < 2; pass++) {
NilDraw nd;
Draw *w = pass ? &ww : &nd;
const wchar *name = mname;
if(justname && slash >= 0)
name += slash + 1;
int txtcx = GetTextSize(fi, name);
int x = x0;
if(txtcx <= wcx) {
w->DrawText(x, y, name, font, ink, (int)(ext - name));
w->DrawText(x + GetTextSize(fi, name, ext), y, ext, font, extink, (int)(mname.End() - ext));
if(!IsEmpty(desc) && pass)
DrawTextEllipsis(*w, x + fi.GetHeight(), y, wcx - txtcx,
desc, "...", descfont, extink);
x += txtcx;
}
else {
const wchar *end = mname.End();
int dircx = 2 * fi['.'] + fi[DIR_SEP];
const wchar *bk = strdirsep(name);
if(bk) {
wcx -= dircx;
w.DrawText(x, y, ".." DIR_SEPS, font, SColorDisabled, 3);
x += dircx;
do {
txtcx -= GetTextSize(fi, name, bk + 1);
name = bk + 1;
if(txtcx < wcx) {
w.DrawText(x, y, name, font, ink, (int)(ext - name));
x += GetTextSize(fi, name, ext);
w.DrawText(x, y, ext, font, extink, (int)(end - ext));
x += GetTextSize(fi, ext, end);
goto end;
}
bk = strdirsep(name);
}
while(bk);
}
wcx -= dot3;
int extcx = GetTextSize(fi, ext, end);
if(2 * extcx > wcx || ext == end) {
int dot3 = 3 * fi['.'];
if(2 * dot3 > wcx) {
int n = GetTextFitCount(fi, name, wcx);
w.DrawText(x, y, name, font, ink, n);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w.DrawText(x, y, "...", font, SColorDisabled, 3);
x += dot3;
}
else {
wcx -= extcx;
int n = (int)(GetTextFitLim(fi, name, end, wcx) - name);
w.DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w.DrawText(x, y, "...", font, SColorDisabled, 3);
w.DrawText(x + dot3, y, ext, font, extink, (int)(end - ext));
x += dot3 + extcx;
const wchar *end = mname.End();
int dircx = 2 * fi['.'] + fi[DIR_SEP];
const wchar *bk = strdirsep(name);
if(bk) {
wcx -= dircx;
w->DrawText(x, y, ".." DIR_SEPS, font, SColorDisabled, 3);
x += dircx;
do {
txtcx -= GetTextSize(fi, name, bk + 1);
name = bk + 1;
if(txtcx < wcx) {
w->DrawText(x, y, name, font, ink, (int)(ext - name));
x += GetTextSize(fi, name, ext);
w->DrawText(x, y, ext, font, extink, (int)(end - ext));
x += GetTextSize(fi, ext, end);
goto end;
}
bk = strdirsep(name);
}
while(bk);
}
wcx -= dot3;
int extcx = GetTextSize(fi, ext, end);
if(2 * extcx > wcx || ext == end) {
int n = GetTextFitCount(fi, name, wcx);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w->DrawText(x, y, "...", font, SColorDisabled, 3);
x += dot3;
}
else {
wcx -= extcx;
int n = (int)(GetTextFitLim(fi, name, end, wcx) - name);
w->DrawText(x, y, name, font, ink, n);
x += GetTextSize(fi, name, name + n);
w->DrawText(x, y, "...", font, SColorDisabled, 3);
w->DrawText(x + dot3, y, ext, font, extink, (int)(end - ext));
x += dot3 + extcx;
}
}
}
end:
if(pass == 0)
ww.DrawRect(x0, y + fi.GetAscent() + 1, x - x0, 1, uln);
}
end:
if(IsNull(uln))
return;
w.DrawRect(x0, y + fi.GetAscent() + 1, x - x0, 1, uln);
}
void FileList::Paint(Draw& w, const Rect& r, const Value& q,

View file

@ -296,24 +296,26 @@ bool Draw::IsPainting(int x, int y, int cx, int cy) const
// ---------------------------
void NilDraw::BeginOp() {}
void NilDraw::EndOp() {}
void NilDraw::OffsetOp(Point p) {}
bool NilDraw::ClipOp(const Rect& r) { return false; }
bool NilDraw::ClipoffOp(const Rect& r) { return false; }
bool NilDraw::ExcludeClipOp(const Rect& r) { return false; }
bool NilDraw::IntersectClipOp(const Rect& r) { return false; }
Rect NilDraw::GetClipOp() const { return Rect(0, 0, 0, 0); }
bool NilDraw::IsPaintingOp(const Rect& r) const { return false; }
void NilDraw::DrawRectOp(int x, int y, int cx, int cy, Color color) {}
void NilDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img,
const Rect& src, Color color) {}
void NilDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color) {}
void NilDraw::DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor) {}
void NilDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx) {}
void NilDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color) {}
void NilDraw::DrawDataOp(int x, int y, int cx, int cy, const String& data, const char *id) {}
void NilDraw::DrawDrawingOp(const Rect& target, const Drawing& w) {}
void NilDraw::DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor) {}
void NilDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color) {}
void NilDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color) {}
void NilDraw::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, const int *subpolygon_counts, int scc, const int *disjunct_polygon_counts, int dpcc, Color color, int width, Color outline, uint64 pattern, Color doxor) {}
void NilDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, const int *counts, int count_count, int width, Color color, Color doxor) {}
void NilDraw::DrawRectOp(int x, int y, int cx, int cy, Color color) {}
void NilDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx) {}
void NilDraw::EndOp() {}
void NilDraw::EndPage() {}
bool NilDraw::ExcludeClipOp(const Rect& r) { return false; }
Rect NilDraw::GetClipOp() const { return Null; }
bool NilDraw::IntersectClipOp(const Rect& r) { return false; }
bool NilDraw::IsPaintingOp(const Rect& r) const { return false; }
void NilDraw::OffsetOp(Point p) {}
void NilDraw::StartPage() {}
// ---------------------------

View file

@ -1068,24 +1068,26 @@ public:
class NilDraw : public Draw {
public:
virtual void BeginOp();
virtual void EndOp();
virtual void OffsetOp(Point p);
virtual bool ClipOp(const Rect& r);
virtual bool ClipoffOp(const Rect& r);
virtual bool ExcludeClipOp(const Rect& r);
virtual bool IntersectClipOp(const Rect& r);
virtual Rect GetClipOp() const;
virtual bool IsPaintingOp(const Rect& r) const;
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img,
const Rect& src, Color color);
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font,
Color ink, int n, const int *dx);
virtual void DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color);
virtual void DrawDataOp(int x, int y, int cx, int cy, const String& data, const char *id);
virtual void DrawDrawingOp(const Rect& target, const Drawing& w);
virtual void DrawEllipseOp(const Rect& r, Color color, int pen, Color pencolor);
virtual void DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color);
virtual void DrawLineOp(int x1, int y1, int x2, int y2, int width, Color color);
virtual void DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, const int *subpolygon_counts, int scc, const int *disjunct_polygon_counts, int dpcc, Color color, int width, Color outline, uint64 pattern, Color doxor);
virtual void DrawPolyPolylineOp(const Point *vertices, int vertex_count, const int *counts, int count_count, int width, Color color, Color doxor);
virtual void DrawRectOp(int x, int y, int cx, int cy, Color color);
virtual void DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink, int n, const int *dx);
virtual void EndOp();
virtual void EndPage();
virtual bool ExcludeClipOp(const Rect& r);
virtual Rect GetClipOp() const;
virtual bool IntersectClipOp(const Rect& r);
virtual bool IsPaintingOp(const Rect& r) const;
virtual void OffsetOp(Point p);
virtual void StartPage();
NilDraw();
~NilDraw();