From 61af975ae0ddec9b14da417bcbc4939b013ee7e9 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 7 Nov 2008 11:15:08 +0000 Subject: [PATCH] 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 --- uppsrc/CodeEditor/CodeEditor.cpp | 3 +- uppsrc/CodeEditor/CodeEditor.h | 7 +- uppsrc/CodeEditor/Highlight.cpp | 56 ++++++++------- uppsrc/CodeEditor/hl_color.i | 1 + uppsrc/CtrlLib/FileList.cpp | 119 ++++++++++++++++--------------- uppsrc/Draw/Draw.cpp | 32 +++++---- uppsrc/Draw/Draw.h | 32 +++++---- 7 files changed, 132 insertions(+), 118 deletions(-) diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 5cb84c857..8934c2db6 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -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)); diff --git a/uppsrc/CodeEditor/CodeEditor.h b/uppsrc/CodeEditor/CodeEditor.h index 67c26db04..538584ede 100644 --- a/uppsrc/CodeEditor/CodeEditor.h +++ b/uppsrc/CodeEditor/CodeEditor.h @@ -189,10 +189,8 @@ protected: static Index keyword[HIGHLIGHT_COUNT]; static Index name[HIGHLIGHT_COUNT]; - static Index kw_upp_macros; - static Index kw_sql_base; - static Index kw_sql_bool; - static Index kw_sql_func; + static Index kw_upp; + static int kw_macros, kw_logs, kw_sql_base, kw_sql_func; struct Isx : Moveable { 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); diff --git a/uppsrc/CodeEditor/Highlight.cpp b/uppsrc/CodeEditor/Highlight.cpp index 84d32fa86..913fc63ec 100644 --- a/uppsrc/CodeEditor/Highlight.cpp +++ b/uppsrc/CodeEditor/Highlight.cpp @@ -227,10 +227,11 @@ void CodeEditor::Bracket(int pos, HlSt& hls) Index CodeEditor::keyword[HIGHLIGHT_COUNT]; Index CodeEditor::name[HIGHLIGHT_COUNT]; -Index CodeEditor::kw_upp_macros; -Index CodeEditor::kw_sql_base; -Index CodeEditor::kw_sql_bool; -Index CodeEditor::kw_sql_func; +Index CodeEditor::kw_upp; +int CodeEditor::kw_macros; +int CodeEditor::kw_logs; +int CodeEditor::kw_sql_base; +int CodeEditor::kw_sql_func; const Index& CodeEditor::CppKeywords() { @@ -238,6 +239,13 @@ const Index& 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& 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; diff --git a/uppsrc/CodeEditor/hl_color.i b/uppsrc/CodeEditor/hl_color.i index 3912c8bce..aec59ff5f 100644 --- a/uppsrc/CodeEditor/hl_color.i +++ b/uppsrc/CodeEditor/hl_color.i @@ -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) diff --git a/uppsrc/CtrlLib/FileList.cpp b/uppsrc/CtrlLib/FileList.cpp index d18649375..34b100f8e 100644 --- a/uppsrc/CtrlLib/FileList.cpp +++ b/uppsrc/CtrlLib/FileList.cpp @@ -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, diff --git a/uppsrc/Draw/Draw.cpp b/uppsrc/Draw/Draw.cpp index d3c8c8dce..349bbd871 100644 --- a/uppsrc/Draw/Draw.cpp +++ b/uppsrc/Draw/Draw.cpp @@ -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() {} // --------------------------- diff --git a/uppsrc/Draw/Draw.h b/uppsrc/Draw/Draw.h index acf9cd1d8..6ffdf1654 100644 --- a/uppsrc/Draw/Draw.h +++ b/uppsrc/Draw/Draw.h @@ -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();