Changed .tpp format to be more svn firendly; groups that need to be included must be now marked includeable

git-svn-id: svn://ultimatepp.org/upp/trunk@345 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2008-08-16 17:13:10 +00:00
parent b37215c5ad
commit fb11d7ab00
12 changed files with 238 additions and 152 deletions

View file

@ -1,135 +1,43 @@
TOPIC("ColorPopUp$en-us")
#include "ColorPopUp$en-us.tpp"
END_TOPIC
TOPIC("Switch$en-us")
#include "Switch$en-us.tpp"
END_TOPIC
TOPIC("LabelBase$en-us")
#include "LabelBase$en-us.tpp"
END_TOPIC
TOPIC("Pusher$en-us")
#include "Pusher$en-us.tpp"
END_TOPIC
TOPIC("Button$en-us")
#include "Button$en-us.tpp"
END_TOPIC
TOPIC("Option$en-us")
#include "Option$en-us.tpp"
END_TOPIC
TOPIC("DataPusher$en-us")
#include "DataPusher$en-us.tpp"
END_TOPIC
TOPIC("HeaderCtrl$en-us")
#include "HeaderCtrl$en-us.tpp"
END_TOPIC
TOPIC("index$en-us")
#include "index$en-us.tpp"
END_TOPIC
TOPIC("StatusBar$en-us")
#include "StatusBar$en-us.tpp"
TOPIC("ColorPopUp$en-us")
#include "ColorPopUp$en-us.tpp"
END_TOPIC
TOPIC("ArrayCtrl$en-us")
#include "ArrayCtrl$en-us.tpp"
END_TOPIC
TOPIC("Progress$en-us")
#include "Progress$en-us.tpp"
END_TOPIC
TOPIC("ButtonOption$en-us")
#include "ButtonOption$en-us.tpp"
END_TOPIC
TOPIC("TabCtrl$en-us")
#include "TabCtrl$en-us.tpp"
END_TOPIC
TOPIC("TabDlg$en-us")
#include "TabDlg$en-us.tpp"
END_TOPIC
TOPIC("EditField$en-us")
#include "EditField$en-us.tpp"
END_TOPIC
TOPIC("ValueEditors$en-us")
#include "ValueEditors$en-us.tpp"
END_TOPIC
TOPIC("Splitter$en-us")
#include "Splitter$en-us.tpp"
END_TOPIC
TOPIC("Slider$en-us")
#include "Slider$en-us.tpp"
END_TOPIC
TOPIC("ProgressInd$en-us")
#include "ProgressInd$en-us.tpp"
END_TOPIC
TOPIC("Progress$en-us")
#include "Progress$en-us.tpp"
TOPIC("StatusBar$en-us")
#include "StatusBar$en-us.tpp"
END_TOPIC
TOPIC("TextCtrl$en-us")
#include "TextCtrl$en-us.tpp"
END_TOPIC
TOPIC("DocEdit$en-us")
#include "DocEdit$en-us.tpp"
END_TOPIC
TOPIC("SplitterFrame$en-us")
#include "SplitterFrame$en-us.tpp"
END_TOPIC
TOPIC("LineEdit$en-us")
#include "LineEdit$en-us.tpp"
END_TOPIC
TOPIC("DropList$en-us")
#include "DropList$en-us.tpp"
TOPIC("Button$en-us")
#include "Button$en-us.tpp"
END_TOPIC
TOPIC("WithDropChoice$en-us")
#include "WithDropChoice$en-us.tpp"
END_TOPIC
TOPIC("ColumnList$en-us")
#include "ColumnList$en-us.tpp"
END_TOPIC
TOPIC("FileList$en-us")
#include "FileList$en-us.tpp"
END_TOPIC
TOPIC("FileSel$en-us")
#include "FileSel$en-us.tpp"
END_TOPIC
TOPIC("Bar$en-us")
#include "Bar$en-us.tpp"
END_TOPIC
TOPIC("BarCtrl$en-us")
#include "BarCtrl$en-us.tpp"
END_TOPIC
TOPIC("MenuBar$en-us")
#include "MenuBar$en-us.tpp"
END_TOPIC
TOPIC("ToolBar$en-us")
#include "ToolBar$en-us.tpp"
END_TOPIC
TOPIC("TreeCtrl$en-us")
#include "TreeCtrl$en-us.tpp"
END_TOPIC
@ -138,7 +46,99 @@ TOPIC("OptionTree$en-us")
#include "OptionTree$en-us.tpp"
END_TOPIC
TOPIC("BarCtrl$en-us")
#include "BarCtrl$en-us.tpp"
END_TOPIC
TOPIC("ColumnList$en-us")
#include "ColumnList$en-us.tpp"
END_TOPIC
TOPIC("TabCtrl$en-us")
#include "TabCtrl$en-us.tpp"
END_TOPIC
TOPIC("TabDlg$en-us")
#include "TabDlg$en-us.tpp"
END_TOPIC
TOPIC("DataPusher$en-us")
#include "DataPusher$en-us.tpp"
END_TOPIC
TOPIC("DropList$en-us")
#include "DropList$en-us.tpp"
END_TOPIC
TOPIC("ToolBar$en-us")
#include "ToolBar$en-us.tpp"
END_TOPIC
TOPIC("Bar$en-us")
#include "Bar$en-us.tpp"
END_TOPIC
TOPIC("Pusher$en-us")
#include "Pusher$en-us.tpp"
END_TOPIC
TOPIC("ValueEditors$en-us")
#include "ValueEditors$en-us.tpp"
END_TOPIC
TOPIC("index$en-us")
#include "index$en-us.tpp"
END_TOPIC
TOPIC("Option$en-us")
#include "Option$en-us.tpp"
END_TOPIC
TOPIC("LabelBase$en-us")
#include "LabelBase$en-us.tpp"
END_TOPIC
TOPIC("DocEdit$en-us")
#include "DocEdit$en-us.tpp"
END_TOPIC
TOPIC("FileList$en-us")
#include "FileList$en-us.tpp"
END_TOPIC
TOPIC("HeaderCtrl$en-us")
#include "HeaderCtrl$en-us.tpp"
END_TOPIC
TOPIC("SplitterFrame$en-us")
#include "SplitterFrame$en-us.tpp"
END_TOPIC
TOPIC("Slider$en-us")
#include "Slider$en-us.tpp"
END_TOPIC
TOPIC("FileSel$en-us")
#include "FileSel$en-us.tpp"
END_TOPIC
TOPIC("Static$en-us")
#include "Static$en-us.tpp"
END_TOPIC
TOPIC("MenuBar$en-us")
#include "MenuBar$en-us.tpp"
END_TOPIC
TOPIC("EditField$en-us")
#include "EditField$en-us.tpp"
END_TOPIC
TOPIC("LineEdit$en-us")
#include "LineEdit$en-us.tpp"
END_TOPIC
TOPIC("ProgressInd$en-us")
#include "ProgressInd$en-us.tpp"
END_TOPIC

View file

@ -254,12 +254,17 @@ bool ParseTopicFileName(const String& fn, String& topic, int& lang);
Topic ReadTopic(const char *text);
Vector<String> GatherLabels(const RichText& text);
String WriteTopic(const char *title, const RichText& text);
String WriteTopicI(const char *title, const RichText& text);
void LoadTopics(FileList& topic, const String& dir);
TopicLink ParseTopicFilePath(const String& path);
String TopicFilePath(const TopicLink& tl);
void SaveGroupInc(const String& grouppath);
void SetTopicGroupIncludeable(const char *path, bool set);
struct StyleDlg;
class TopicEditor : public IdeDesigner, public Ctrl {

View file

@ -21,6 +21,12 @@ Topic ReadTopic(const char *text)
Topic topic;
CParser p(text);
try {
if(p.Id("topic")) {
topic.title = p.ReadString();
p.Char(';');
topic.text = p.GetPtr();
return topic;
}
while(!p.IsEof()) {
if(p.Id("TITLE")) {
p.PassChar('(');
@ -73,6 +79,14 @@ Vector<String> GatherLabels(const RichText& text)
}
String WriteTopic(const char *title, const RichText& text)
{
StringBuffer r;
r << "topic " << AsCString(title) << ';';
r << AsQTF(text, CHARSET_UTF8, QTF_BODY|QTF_ALL_STYLES|QTF_CRLF);
return r;
}
String WriteTopicI(const char *title, const RichText& text)
{
StringBuffer r;
r << "TITLE(" << AsCString(title) << ")\r\n";
@ -95,3 +109,52 @@ String WriteTopic(const char *title, const RichText& text)
r << "\r\n\r\n";
return r;
}
void SaveGroupInc(const String& grouppath)
{
String packagedir = GetFileFolder(grouppath);
String group = GetFileTitle(grouppath);
if(IsNull(packagedir) || IsNull(group))
return;
String gh;
FindFile ff(AppendFileName(grouppath, "*.tppi"));
while(ff) {
if(ff.IsFile()) {
gh << "TOPIC(" << AsCString(GetFileTitle(ff.GetName())) << ")\r\n";
gh << "#include \"" << ff.GetName() << "\"\r\n";
gh << "END_TOPIC\r\n\r\n";
}
ff.Next();
}
String fn = AppendFileName(AppendFileName(packagedir, group + ".tpp"), "all.i");
if(LoadFile(fn) != gh)
if(IsNull(gh))
DeleteFile(fn);
else
SaveFile(fn, gh);
}
void SetTopicGroupIncludeable(const char *path, bool set)
{
FindFile ff(AppendFileName(path, "*.tpp"));
while(ff) {
if(GetFileExt(ff.GetName()) == ".tpp") {
String s = AppendFileName(path, ff.GetName());
String t = AppendFileName(path, ForceExt(ff.GetName(), ".tppi"));
if(set) {
Topic p = ReadTopic(LoadFile(s));
SaveFile(t, WriteTopicI(p.title, ParseQTF(p.text)));
}
else {
// Topic p = ReadTopic(LoadFile(s)); _DBG_ // only to convert
// SaveFile(s, WriteTopic(p.title, ParseQTF(p.text)));
FileDelete(t);
}
}
ff.Next();
}
if(set)
SaveGroupInc(path);
else
FileDelete(AppendFileName(path, "all.i"));
}

View file

@ -19,7 +19,7 @@ void LoadTopics(FileList& topic, const String& grouppath)
topic.Clear();
FindFile ff(AppendFileName(grouppath, "*.tpp"));
while(ff) {
if(ff.IsFile())
if(ff.IsFile() && GetFileExt(ff.GetName()) == ".tpp")
topic.Add(GetFileTitle(ff.GetName()), TopicImg::Topic());
ff.Next();
}
@ -143,6 +143,8 @@ void TopicEditor::SaveTopic()
if(LoadFile(topicpath) != r) {
sSerial++;
SaveFile(topicpath, r);
if(FileExists(AppendFileName(grouppath, "all.i")))
SaveFile(ForceExt(topicpath, ".tppi"), WriteTopicI((String)~title, editor.Get()));
TopicLink tl = ParseTopicFilePath(topicpath);
if(tl)
SyncTopicFile(editor.Get(), TopicLinkString(tl), topicpath, ~title);
@ -163,30 +165,7 @@ void TopicEditor::Flush()
void TopicEditor::SaveInc()
{
String packagedir = GetFileFolder(grouppath);
String group = GetFileTitle(grouppath);
if(IsNull(packagedir) || IsNull(group))
return;
String gh;
FindFile ff(AppendFileName(AppendFileName(packagedir, group + ".tpp"), "*.tpp"));
while(ff) {
if(ff.IsFile()) {
gh << "TOPIC(" << AsCString(GetFileTitle(ff.GetName())) << ")\r\n";
gh << "#include \"" << ff.GetName() << "\"\r\n";
gh << "END_TOPIC\r\n\r\n";
}
ff.Next();
}
String fn = AppendFileName(AppendFileName(packagedir, group + ".tpp"), "all.i");
if(LoadFile(fn) != gh)
if(IsNull(gh))
DeleteFile(fn);
else
SaveFile(fn, gh);
SaveGroupInc(grouppath);
}
TopicLink ParseTopicFilePath(const String& path)

View file

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

View file

@ -259,7 +259,7 @@ void TopicEditor::NewTopic()
}
lasttemplate = ~d.tmpl;
lastlang = ~d.lang;
CreateTopic(fn, ~d.lang, ~d.tmpl);
CreateTopic(fn, ~d.lang, ReadTopic((String)~d.tmpl).text);
Flush();
Open(grouppath);
Load(fn);
@ -326,7 +326,8 @@ void TopicEditor::SaveAsTemplate()
d.nest.GoBegin();
if(d.Execute() != IDOK || IsNull(~d.nest))
return;
SaveFile(AppendFileName(AppendFileName(~d.nest, "$.tpp"), d.GetName()), editor.GetQTF());
SaveFile(AppendFileName(AppendFileName(~d.nest, "$.tpp"), d.GetName()),
WriteTopic((String)~title, editor.Get()));
}
void TopicEditor::SetBar()

View file

@ -174,6 +174,7 @@ struct WorkspaceWork {
String GetActivePackage() const { return package.GetCurrentName(); }
String GetActiveFileName() const;
String GetActiveFilePath() const;
bool IsActiveFile() const;
Package::File& ActiveFile();
String FileName(int i) const;
@ -196,6 +197,7 @@ struct WorkspaceWork {
void DelFile();
void RenameFile();
void ToggleFileSpeed();
void ToggleIncludeable();
void AddNormalUses();
void AddAnyUses();

View file

@ -148,8 +148,9 @@ void WorkspaceWork::LoadActualPackage()
else
if(open) {
Color uln = Null;
String p = SourcePath(GetActivePackage(), f);
if(showtime) {
FindFile ff(SourcePath(GetActivePackage(), f));
FindFile ff(p);
if(ff) {
Time ftm = Time(ff.GetLastWriteTime());
if(ftm > utime) {
@ -162,7 +163,13 @@ void WorkspaceWork::LoadActualPackage()
}
}
}
filelist.Add(f, IdeFileImage(f, f.optimize_speed), ListFont(), SColorText, false, 0,
Image m = IdeFileImage(f, f.optimize_speed);
if(GetFileExt(p) == ".tpp" && IsFolder(p))
if(FileExists(AppendFileName(p, "all.i")))
m = TopicImg::IGroup();
else
m = TopicImg::Group();
filelist.Add(f, m, ListFont(), SColorText, false, 0,
Null, SColorMark, Null, Null, Null, uln);
fileindex.Add(i);
}
@ -228,6 +235,11 @@ String WorkspaceWork::GetActiveFileName() const
return FileName(filelist.GetCursor());
}
String WorkspaceWork::GetActiveFilePath() const
{
return SourcePath(GetActivePackage(), GetActiveFileName());
}
bool WorkspaceWork::IsActiveFile() const
{
int i = filelist.GetCursor();
@ -359,6 +371,11 @@ void WorkspaceWork::AddTopicGroup()
dlg.Load(PackageDirectory(package));
if(dlg.Run() != IDOK) return;
String g = dlg.GetName();
if(g == "app.tpp") {
String h = SourcePath(package, g);
RealizeDirectory(h);
SaveFile(AppendFileName(h, "all.i"), "");
}
if(g.GetCount())
AddItem(g, false, false);
}
@ -386,7 +403,7 @@ void WorkspaceWork::RemoveFile()
void WorkspaceWork::DelFile()
{
if(!filelist.IsCursor() || filelist[filelist.GetCursor()].isdir) return;
String file = SourcePath(GetActivePackage(), GetActiveFileName());
String file = GetActiveFilePath();
if(IsFolder(file)) {
if(!PromptYesNo("Remove the topic group and discard ALL topics?")) return;
RemoveFile();
@ -404,7 +421,7 @@ void WorkspaceWork::RenameFile()
if(!filelist.IsCursor()) return;
String n = GetActiveFileName();
if(!EditText(n, "Rename file", "New name")) return;
String spath = SourcePath(GetActivePackage(), GetActiveFileName());
String spath = GetActiveFilePath();
String dpath = SourcePath(GetActivePackage(), n);
if(!filelist[filelist.GetCursor()].isdir && GetFileLength(spath) >= 0) {
if(!::MoveFile(spath, dpath)) {
@ -569,9 +586,16 @@ void WorkspaceWork::FileMenu(Bar& menu)
THISBACK1(MoveFile, 1))
.Key(organizer ? K_CTRL_DOWN : K_SHIFT_CTRL_DOWN)
.Help("Move current file one position towards package end");
if(IsActiveFile()) {
menu.Separator();
menu.Add(IsActiveFile(), "Optimize for speed", THISBACK(ToggleFileSpeed))
.Check(IsActiveFile() && ActiveFile().optimize_speed);
String p = GetActiveFilePath();
if(GetFileExt(p) == ".tpp" && IsFolder(p))
menu.Add("Includeable", THISBACK(ToggleIncludeable))
.Check(FileExists(AppendFileName(p, "all.i")));
else
menu.Add("Optimize for speed", THISBACK(ToggleFileSpeed))
.Check(ActiveFile().optimize_speed);
}
FilePropertiesMenu(menu);
}
@ -583,6 +607,15 @@ void WorkspaceWork::ToggleFileSpeed()
}
}
void WorkspaceWork::ToggleIncludeable()
{
if(IsActiveFile()) {
String p = GetActiveFilePath();
SetTopicGroupIncludeable(p, !FileExists(AppendFileName(p, "all.i")));
SaveLoadPackageNS();
}
}
void WorkspaceWork::AddNormalUses()
{
String p = SelectPackage("Select package");

View file

@ -69,8 +69,7 @@ bool Ide::CanToggleReadOnly()
{
FindFile ff(editfile);
if(ff && ff.IsReadOnly()) return false;
return NormalizePath(SourcePath(GetActivePackage(), GetActiveFileName())) ==
NormalizePath(editfile);
return NormalizePath(GetActiveFilePath()) == NormalizePath(editfile);
}
void Ide::ToggleReadOnly()

View file

@ -61,8 +61,8 @@ file
Debug.cpp,
Valgrind.cpp,
Export.cpp,
ide.iml,
Resources readonly separator,
ide.iml,
ide.lay,
app.tpp,
ide.rc

View file

@ -69,7 +69,7 @@ void Ide::FileCursor()
}
String p = GetActiveFileName();
if(p != HELPNAME)
p = SourcePath(GetActivePackage(), GetActiveFileName());
p = GetActiveFilePath();
EditFile0(p, f.charset ? f.charset : actual.charset ? actual.charset : default_charset,
false, headername);
}

View file

@ -465,7 +465,7 @@ String ExportTr(const Vector<TFile>& tfile, int& cs)
void Ide::SyncT(int kind)
{
console.Clear();
String filepath = SourcePath(GetActivePackage(), GetActiveFileName());
String filepath = GetActiveFilePath();
SaveFile();
TFile repository;