TheIDE: Package coloring experiment

git-svn-id: svn://ultimatepp.org/upp/trunk@1047 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-04-05 18:30:09 +00:00
parent 37732e817c
commit 2f1cbc0744
33 changed files with 205 additions and 38 deletions

View file

@ -1,4 +1,4 @@
description "Non-GUI code. Streams, NTL containers, concrete types, Value, XML, C parsing etc...";
description "Non-GUI code. Streams, NTL containers, concrete types, Value, XML, C parsing etc...\377128,0,0";
acceptflags
USEMALLOC;

View file

@ -1,7 +1,63 @@
TITLE("U++ traps and pitfalls")
COMPRESSED
120,156,165,84,93,111,219,54,20,253,43,23,77,86,216,137,99,139,95,250,220,134,22,217,250,50,44,27,186,54,47,134,91,209,18,29,19,145,69,149,164,157,24,65,242,219,119,41,11,73,11,44,201,195,4,83,182,232,123,207,189,231,220,67,205,41,28,31,71,147,232,40,122,229,202,127,83,43,185,109,252,98,174,57,79,11,73,69,113,253,199,95,89,113,242,110,20,243,113,64,33,136,194,18,194,82,193,8,167,49,222,8,35,84,80,198,73,74,51,158,50,150,70,121,213,72,231,22,243,134,166,105,17,146,232,132,30,209,68,80,146,240,148,167,132,37,41,197,92,26,69,52,74,168,32,156,165,84,228,181,114,213,98,46,83,86,156,124,140,49,137,133,74,8,30,145,152,242,132,211,136,69,148,99,41,146,166,156,36,34,101,89,28,231,149,236,188,54,237,80,75,19,66,73,177,36,73,129,61,63,60,60,76,9,143,14,29,112,4,35,17,199,86,9,238,69,156,38,68,100,81,38,82,146,70,12,193,69,18,137,188,147,86,110,158,167,46,94,165,158,68,185,246,10,33,78,
78,9,73,48,37,158,196,71,132,39,72,52,101,92,164,73,132,197,41,165,140,81,194,104,150,81,17,139,36,95,43,89,43,139,20,56,137,251,102,147,73,114,36,132,224,24,207,185,72,82,78,25,206,134,51,142,82,112,146,9,158,9,154,183,202,121,85,151,103,7,217,14,244,31,27,15,125,7,164,116,146,30,197,60,206,8,170,207,179,132,71,89,76,18,22,196,35,40,123,204,56,205,196,35,210,48,181,187,175,247,63,253,126,113,246,249,31,152,59,86,192,231,242,180,60,5,111,101,231,64,182,53,116,218,175,100,211,184,183,139,185,139,10,192,47,184,187,19,193,59,225,214,204,24,179,184,60,174,37,46,8,65,231,239,4,92,170,202,27,251,243,7,99,126,133,219,226,144,28,246,167,120,61,61,221,78,223,251,145,30,67,249,11,220,150,243,111,229,162,88,228,121,51,163,194,226,242,51,34,150,184,122,76,248,219,154,101,163,54,57,188,247,160,219,157,108,116,45,189,114,96,213,74,89,213,86,248,211,155,161,108,1,122,53,0,194,149,242,14,20,198,111,49,188,134,149,
182,206,79,192,175,213,83,38,84,178,133,165,130,6,35,236,119,224,53,44,247,88,110,10,163,11,227,21,86,182,86,238,161,54,88,170,53,30,214,114,167,122,32,39,55,10,186,67,127,227,105,207,224,127,169,82,153,214,121,192,160,242,45,184,94,155,233,39,211,141,198,189,250,79,202,213,245,168,87,206,189,36,47,6,13,217,227,215,194,202,121,84,46,198,207,79,224,82,217,61,56,189,209,141,180,65,107,185,52,187,71,222,19,48,109,179,135,141,177,10,212,109,215,232,74,251,23,165,216,25,93,195,159,251,15,237,168,151,117,208,228,133,242,159,214,218,65,248,180,88,5,245,169,164,195,65,72,88,110,175,160,60,27,124,139,210,121,169,91,101,221,97,60,229,155,249,23,111,58,93,149,121,57,43,103,231,216,94,57,115,182,170,77,85,206,112,251,186,252,90,30,171,182,60,219,186,47,16,158,131,243,91,135,198,0,167,54,178,245,186,114,139,242,205,4,54,10,183,113,218,210,131,219,86,107,88,109,219,42,188,137,0,207,163,183,102,239,6,75,201,6,250,215,138,66,43,
161,113,62,74,171,154,253,4,214,230,70,237,148,13,198,67,10,131,223,48,187,219,218,206,56,245,178,107,116,235,225,54,76,250,98,219,52,223,77,177,54,91,148,30,246,189,69,158,23,238,188,87,230,186,53,55,189,111,215,186,189,10,179,219,250,65,179,128,26,132,171,84,135,39,99,15,55,26,159,131,193,177,69,217,255,59,133,112,0,14,236,47,241,36,169,48,7,121,131,220,6,160,192,61,4,78,192,153,129,162,169,85,254,244,206,120,133,201,1,116,119,32,242,223,4,119,197,15,104,216,92,24,48,182,225,130,223,240,92,169,122,186,184,191,255,49,104,241,47,157,23,10,78,
topic "U++ traps and pitfalls";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;*@(64)2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
[a83;*R6 $$3,0#31310162474203024125188417583966:caption]
[l288;i1121;b17;O9;~~~.1408;2 $$4,0#10431211400427159095818037425705:param]
[i448;a25;kKO9;*@(64)2 $$5,0#37138531426314131252341829483370:item]
[*+117 $$6,6#14700283458701402223321329925657:header]
[l416;2 $$7,7#55548704457842300043401641954952:nested`-desc]
[l288;i448;a25;kO9;*2 $$8,8#64691275497409617375831514634295:nested`-class]
[{_}%EN-US
[s3; U`+`+ traps and pitfalls&]
[s0; &]
[ {{5000:5000l/33r/33t/33b/33 [s0; [C@5 Vector<Foo> x;]&]
[s0; [C@5 ....]&]
[s0; [C@5 x.At(i) `= x`[q`];]]
::l/25r/25t/15b/15 [s0; Problem: At invalidates references to Vector; if x`[q`] gets
evaluated first, the reference can be later invalidated by At.
(Note: Array does not have the same problem).]
::l/33r/33t/33b/33 [s0; [C@5 Vector<Foo> x;]&]
[s0; [C@5 ....]&]
[s0; [C@5 const Foo`& s `= x.Top(); ]&]
[s0; [C@5 x.Add() `= s;]&]
[s0; [C@5 ....]&]
[s0; [C@5 x.Add(x.Top());]&]
[s0; [C@5 ....]&]
[s0; [C@5 x.Add(x`[0`]);]]
::l/25r/25t/15b/15 [s0; Very similar to above problem, only more explicit.]
::l/33r/33t/33b/33 [s0; [C@5 void MyFn(Array<Foo> x);]]
::l/25r/25t/15b/15 [s0; This is in most cases a bug `- U`+`+ containers have `"[^topic`:`/`/Core`/srcdoc`/pick`_`$en`-us^ p
ick transfer semantics]`", means that such function destroys
the real parameter. (Rarely, however, this can be on purpose).]
::l/33r/33t/33b/33 [s0; [C@5 int x `= Null;]&]
[s0; [C@5 double y `= x;]]
::l/25r/25t/15b/15 [s0; C`+`+ knows nothing about U`+`+ Null concept, y will not be
a Null. Note that Value is aware about the Null, so this code:&]
[s0; &]
[s0; [C@5 int x `= Null;]&]
[s0; [C@5 Value v `= x;]&]
[s0; [C@5 double y `= v;]&]
[s0; &]
[s0; behaves as expected.]
::l/33r/33t/33b/33 [s0; [C@5 #include <CtrlLib/CtrlLib.h>]&]
[s0; [C@5 using namespace Upp;]&]
[s0;C@5 &]
[s0; [C@5 class TestWindow : public TopWindow]&]
[s0; [C@5 `{]&]
[s0; [C@5 `};]&]
[s0;C@5 &]
[s0; [C@5 EditString es;]&]
[s0;C@5 &]
[s0; [C@5 GUI`_APP`_MAIN]&]
[s0; [C@5 `{]&]
[s0; [C@5 -|TestWindow().Run();]&]
[s0; [C@5 `}]]
::^l/25r/25t/15b/15 [s0; Warning: You cannot define widgets as global variable. This is
rather host platform dependent technical issue rather than deliberate
decision.&]
[s0; &]
[s0; The code might run OK on some platforms, but crash on others.
Means, just do not do it...]}}&]
[s0; &]
[s0; ]

View file

@ -24,7 +24,7 @@ topic "Resolving memory leaks";
[{_}%EN-US
[s2; Resolving memory leaks&]
[s0; Before 2008.1 release, the memory leaks debugging facilities
have changed. Where we try to explain why logic has changed and
have changed. Here we try to explain why logic has changed and
what problem is it supposed to solve:&]
[s0; &]
[s0; Previous method involved watching for particular ADDRESS to

View file

@ -1,4 +1,4 @@
description "GUI core system";
description "GUI core system\3770,0,255";
uses
Draw,

View file

@ -2,7 +2,7 @@
#define _CtrlCore_icpp_init_stub
#include "Draw/init"
#include "plugin\bmp/init"
#define BLITZ_INDEX__ F140BDB0A352E113A0463B24037B73D05
#define BLITZ_INDEX__ FBC17513242E99EC4440BC76CBB3D45F5
#include "CtrlCore.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "Basic library of GUI elements";
description "Basic library of GUI elements\3770,0,255";
acceptflags
NOGTK;

View file

@ -3,7 +3,7 @@
#include "CtrlCore/init"
#include "RichText/init"
#include "PdfDraw/init"
#define BLITZ_INDEX__ F978A8DB3120B5F54197F4DB2205753CA
#define BLITZ_INDEX__ F16BD2282D276FAA083462E9A73BE4887
#include "CtrlLib.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "Fundamental graphics operations, including raster image processing";
description "Fundamental graphics operations, including raster image processing\377128,0,255";
acceptflags
NOGTK;

View file

@ -1,4 +1,4 @@
description "PDF output as Draw derived class";
description "PDF output as Draw derived class\377128,0,255";
uses
Draw;

View file

@ -1,7 +1,7 @@
#ifndef _PdfDraw_icpp_init_stub
#define _PdfDraw_icpp_init_stub
#include "Draw/init"
#define BLITZ_INDEX__ F84CAEEC660789CDC9ACF6436B0FE0BF3
#define BLITZ_INDEX__ F4543603AB150C6109EA1477D5C54CC3C
#include "PdfReport.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "Rich-text data structures and painting, including RTF and HTML export/import";
description "Rich-text data structures and painting, including RTF and HTML export/import\3770,0,128";
uses
CtrlCore,

View file

@ -2,7 +2,7 @@
#define _RichText_icpp_init_stub
#include "CtrlCore/init"
#include "plugin\png/init"
#define BLITZ_INDEX__ FA628C8257B6D8216D316B02BA86806FB
#define BLITZ_INDEX__ FD9BFF8A7459D77CDDE8AF2999BB1DAC7
#include "RichImage.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "TCP/IP related stuff";
description "TCP/IP related stuff\377128,0,0";
uses
Core;

View file

@ -1,7 +1,7 @@
#ifndef _Web_icpp_init_stub
#define _Web_icpp_init_stub
#include "Core/init"
#define BLITZ_INDEX__ F3B8802768995E4DB828D13B0F9A48C61
#define BLITZ_INDEX__ F013A89C23D31A4716457864E38F2235B
#include "Web_init.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -265,6 +265,8 @@ public:
Array<Config> config;
Array<CustomStep> custom;
Time time;
bool bold, italic;
Color ink;
int GetCount() const { return file.GetCount(); }
File& operator[](int i) { return file[i]; }

View file

@ -161,6 +161,8 @@ Package::Package()
charset = 0;
optimize_speed = false;
noblitz = true;
bold = italic = false;
ink = Null;
}
bool StdResolver(const String& error, const String& path, int line)
@ -208,8 +210,29 @@ void Package::Load(const char *path)
if(p.Id("charset"))
charset = CharsetByName(p.ReadString());
else
if(p.Id("description"))
if(p.Id("description")) {
description = p.ReadString();
const char *q = strchr(description, 255);
ink = Null;
bold = italic = false;
if(q) {
CParser p(q + 1);
bold = p.Char('B');
italic = p.Char('I');
if(p.IsNumber()) {
RGBA c = Black();
c.r = p.ReadInt();
p.Char(',');
if(p.IsNumber())
c.g = p.ReadInt();
p.Char(',');
if(p.IsNumber())
c.b = p.ReadInt();
ink = c;
}
description = String(~description, q);
}
}
else
if(p.Id("acceptflags")) {
do
@ -340,8 +363,17 @@ void putfopt(Stream& out, const char *key, const Array<OptItem>& m)
bool Package::Save(const char *path) const {
StringStream out;
if(description.GetCount())
out << "description " << AsCString(description) << ";\n\n";
if(description.GetCount() || italic || bold || !IsNull(ink)) {
String d = description;
d.Cat(255);
if(bold)
d << 'B';
if(italic)
d << 'I';
if(!IsNull(ink))
d << (int)ink.GetR() << ',' << (int)ink.GetG() << ',' << (int)ink.GetB();
out << "description " << AsCString(d) << ";\n\n";
}
if(charset > 0 && charset < CharsetCount() || charset == CHARSET_UTF8)
out << "charset " << AsCString(CharsetName(charset)) << ";\n\n";
if(optimize_speed)

View file

@ -1,5 +1,38 @@
#include "ide.h"
static VectorMap<String, PackageInfo> sPi;
void InvalidatePackageInfo(const String& name)
{
int q = sPi.Find(name);
if(q >= 0)
sPi[q].path.Clear();
}
PackageInfo GetPackageInfo(const String& name)
{
String path = PackagePath(name);
Time tm = FileGetTime(path);
int q = sPi.Find(name);
if(q >= 0) {
if(path == sPi[q].path && tm == sPi[q].stamp)
return sPi[q];
}
else {
q = sPi.GetCount();
sPi.Add(name);
}
PackageInfo& pi = sPi[q];
pi.path = path;
pi.stamp = tm;
Package p;
p.Load(path);
pi.ink = p.ink;
pi.italic = p.italic;
pi.bold = p.bold;
return pi;
}
class BaseSetupDlg : public WithBaseSetupLayout<TopWindow>
{
public:

View file

@ -86,6 +86,9 @@ UsesDlg::UsesDlg()
void PackageEditor::SaveOptions() {
if(!actualpackage.IsEmpty()) {
actual.description = ~description;
actual.ink = ~ink;
actual.bold = ~bold;
actual.italic = ~italic;
actual.charset = (byte)(int)~charset;
actual.accepts = Split(accepts.GetText().ToString(), ' ');
actual.optimize_speed = optimize_speed;
@ -111,6 +114,9 @@ void PackageEditor::Empty()
charset.Disable();
noblitz.Disable();
description.Disable();
ink.Disable();
italic.Disable();
bold.Disable();
optimize_speed.Disable();
filelist.Clear();
filelist.Disable();
@ -154,6 +160,9 @@ void PackageEditor::PackageCursor()
Empty();
else {
description <<= actual.description;
ink <<= actual.ink;
bold <<= actual.bold;
italic <<= actual.italic;
charset <<= (int)actual.charset;
optimize_speed = actual.optimize_speed;
noblitz = actual.noblitz;
@ -164,6 +173,9 @@ void PackageEditor::PackageCursor()
}
accepts = s.ToWString();
description.Enable();
ink.Enable();
bold.Enable();
italic.Enable();
charset.Enable();
noblitz.Enable();
optimize_speed.Enable();
@ -556,6 +568,11 @@ PackageEditor::PackageEditor()
fileoption.WhenCursor = THISBACK(AdjustFileOptionCursor);
fileoption.WhenBar = THISBACK(FileOptionMenu);
fileoption.WhenLeftDouble = THISBACK(EditFileOption);
ink.NullText("(std)");
ink <<=
bold <<=
italic <<= THISBACK(SaveOptionsLoad);
}
void EditPackages(const char *main, const char *startwith, String& cfg) {

View file

@ -5,6 +5,16 @@ inline bool MoveFile(const char *oldpath, const char *newpath)
}
#endif
struct PackageInfo : Moveable<PackageInfo> {
Time stamp;
String path;
Color ink;
bool bold, italic;
};
void InvalidatePackageInfo(const String& name);
PackageInfo GetPackageInfo(const String& name);
struct FileTemplate {
String filename;
String condition;

View file

@ -41,10 +41,20 @@ void WorkspaceWork::ScanWorkspace() {
actualfileindex = -1;
filelist.Clear();
package.Clear();
for(int i = 0; i < wspc.package.GetCount(); i++)
package.Add(wspc.package.GetKey(i),
for(int i = 0; i < wspc.package.GetCount(); i++) {
String pk = wspc.package.GetKey(i);
Font fnt = ListFont();
if(i == 0)
fnt.Bold();
PackageInfo pi = GetPackageInfo(pk);
if(pi.bold)
fnt.Bold();
if(pi.italic)
fnt.Italic();
package.Add(pk,
wspc.GetPackage(i).optimize_speed ? IdeCommonImg::FastPackage() : IdeImg::Package(),
i == 0 ? ListFont().Bold() : ListFont(), SColorText, false, 0, Null, SColorMark);
fnt, Nvl(pi.ink, SColorText()), false, 0, Null, SColorMark);
}
if(!organizer) {
package.Add(prjaux, IdeImg::PrjAux(), ListFont(), Magenta);
package.Add(ideaux, IdeImg::IdeAux(), ListFont(), Magenta);
@ -58,6 +68,7 @@ void WorkspaceWork::SavePackage()
{
if(IsNull(actualpackage) || actualpackage == "<METAPACKAGE>")
return;
InvalidatePackageInfo(actualpackage);
String pp = PackagePathA(actualpackage);
RealizePath(pp);
if(organizer && backup.Find(pp) < 0) {

View file

@ -101,7 +101,7 @@ END_LAYOUT
LAYOUT(UppLayout, 800, 576)
UNTYPED(package, LeftPosZ(4, 240).TopPosZ(4, 376))
ITEM(Label, dv___1, SetLabel(t_("Description")).LeftPosZ(248, 56).TopPosZ(4, 19))
ITEM(DataPusher, description, HSizePosZ(304, 4).TopPosZ(4, 20))
ITEM(DataPusher, description, HSizePosZ(304, 212).TopPosZ(4, 20))
ITEM(Option, optimize_speed, SetLabel(t_("Optimize for speed")).LeftPosZ(248, 120).TopPosZ(28, 20))
ITEM(Label, dv___4, SetLabel(t_("&Accepts")).LeftPosZ(368, 40).TopPosZ(28, 19))
ITEM(EditString, accepts, HSizePosZ(408, 260).TopPosZ(28, 19))
@ -114,6 +114,10 @@ LAYOUT(UppLayout, 800, 576)
ITEM(Option, optimize_speed_file, SetLabel(t_("Optimize the file for speed")).LeftPosZ(248, 152).BottomPosZ(9, 19))
ITEM(Button, ok, SetLabel(t_("OK")).RightPosZ(76, 64).BottomPosZ(6, 22))
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(8, 64).BottomPosZ(6, 22))
ITEM(Label, dv___15, SetLabel(t_("Highlight")).LeftPosZ(596, 48).TopPosZ(4, 19))
ITEM(ColorPusher, ink, LeftPosZ(644, 52).TopPosZ(4, 20))
ITEM(Option, bold, SetLabel(t_("Bold")).LeftPosZ(700, 44).TopPosZ(4, 20))
ITEM(Option, italic, SetLabel(t_("Italic")).LeftPosZ(748, 44).TopPosZ(4, 20))
END_LAYOUT
LAYOUT(NewPackageLayout, 728, 560)

View file

@ -1,3 +1,5 @@
description "\3770,128,128";
uses
Core;

View file

@ -1,4 +1,4 @@
description "BMP image file format";
description "BMP image file format\3770,128,128";
uses
Draw;

View file

@ -1,7 +1,7 @@
#ifndef _plugin_bmp_icpp_init_stub
#define _plugin_bmp_icpp_init_stub
#include "Draw/init"
#define BLITZ_INDEX__ F33B1C6142814C0A7F99BE74C8CB2E5DB
#define BLITZ_INDEX__ FFD06CC4A52EF0C28A5D9BF2E2F65DA8C
#include "BmpReg.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "BZ2 compressor/decompressor";
description "BZ2 compressor/decompressor\3770,128,128";
optimize_speed;

View file

@ -1,4 +1,4 @@
description "GIF image file format";
description "GIF image file format\3770,128,128";
uses
Draw;

View file

@ -1,7 +1,7 @@
#ifndef _plugin_gif_icpp_init_stub
#define _plugin_gif_icpp_init_stub
#include "Draw/init"
#define BLITZ_INDEX__ F0207BAB1E1E22D2A25B953A53828494C
#define BLITZ_INDEX__ F4B0EEED8D84A571AB8FDA03143B1B9CE
#include "gif.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,7 +1,7 @@
#ifndef _plugin_jpg_icpp_init_stub
#define _plugin_jpg_icpp_init_stub
#include "Draw/init"
#define BLITZ_INDEX__ F56D83EE246B85AC219DC308441603E8B
#define BLITZ_INDEX__ FCE5007ECA328A2C1D7B74D02BA609390
#include "jpgreg.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "JPEG image file format";
description "JPEG image file format\3770,128,128";
uses
Draw;

View file

@ -1,4 +1,4 @@
description "Disassembler (GPL license - used in TheIDE)";
description "Disassembler (GPL license - used in TheIDE)\3770,128,128";
uses
Core;

View file

@ -2,7 +2,7 @@
#define _plugin_png_icpp_init_stub
#include "Core/init"
#include "Draw/init"
#define BLITZ_INDEX__ F9A38A4CDA02AC861A35747162FC2BA11
#define BLITZ_INDEX__ F38D3ACD6D8DA64078EB0B2289CBE1F7F
#include "pngreg.icpp"
#undef BLITZ_INDEX__
#endif

View file

@ -1,4 +1,4 @@
description "PNG image file format U++ encapsulation";
description "PNG image file format U++ encapsulation\3770,128,128";
uses
Core,

View file

@ -1,4 +1,4 @@
description "zlib compressor/decompressor and its U++ encapsulation";
description "zlib compressor/decompressor and its U++ encapsulation\3770,128,128";
optimize_speed;