summaryrefslogtreecommitdiff
path: root/fluid/code.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2005-03-09 21:26:53 +0000
committerMatthias Melcher <fltk@matthiasm.com>2005-03-09 21:26:53 +0000
commitfc1a4cf809de316d356672a834b7f2f797032d98 (patch)
tree7702d3ae290313a22261baf06892ac148aaa1243 /fluid/code.cxx
parent2bbee87dc306d6beeb8f0a0a4bd3b6092eb6eee5 (diff)
Added a new Type to fluid called 'Comment' to be used for standardized Copyright notices and other comments throughout the source code.
- simply add the 'Comment' type from the 'New' menu or the Widget Bin - comments in the very first position will be added at the very beginning of the source file or header. Comments at the end are at the very end in source and headers as well. - if the users enters simple text, FLUID will add '// ' in front of every line. If a line already starts with '//' or a block starts with '/*', the text will be copied verbatim. - text can be loaded from files - text can be stored in a database and quickly retrieved later via a pulldown menu. The pulldown menu is customizable. Enjoy! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4092 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/code.cxx')
-rw-r--r--fluid/code.cxx24
1 files changed, 21 insertions, 3 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx
index b07c9675c..f8fd58e6e 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -246,7 +246,9 @@ int write_number;
// recursively dump code, putting children between the two parts
// of the parent code:
static Fl_Type* write_code(Fl_Type* p) {
- p->write_code1();
+ // don't write the last comment until the very end
+ if (!(p==Fl_Type::last && p->is_comment()))
+ p->write_code1();
Fl_Type* q;
for (q = p->next; q && q->level > p->level;) q = write_code(q);
p->write_code2();
@@ -271,6 +273,15 @@ int write_code(const char *s, const char *t) {
if (!f) {fclose(code_file); return 0;}
header_file = f;
}
+ // if the first entry in the Type tree is a comment, then it is probably
+ // a copyright notice. We print that before anything else in the file!
+ Fl_Type* first_type = Fl_Type::first;
+ if (first_type && first_type->is_comment()) {
+ // this is ok, because comments have no children or code2 blocks
+ first_type->write_code1();
+ first_type = first_type->next;
+ }
+
const char *hdr = "\
// generated by Fast Light User Interface Designer (fluid) version %.4f\n\n";
fprintf(header_file, hdr, FL_VERSION);
@@ -311,7 +322,7 @@ int write_code(const char *s, const char *t) {
write_c("#include \"%s\"\n", t);
}
}
- for (Fl_Type* p = Fl_Type::first; p;) {
+ for (Fl_Type* p = first_type; p;) {
// write all static data for this & all children first
p->write_static();
for (Fl_Type* q = p->next; q && q->level > p->level; q = q->next)
@@ -323,9 +334,16 @@ int write_code(const char *s, const char *t) {
delete included_root; included_root = 0;
if (!s) return 1;
+
+ fprintf(header_file, "#endif\n");
+
+ Fl_Type* last_type = Fl_Type::last;
+ if (last_type && last_type->is_comment()) {
+ last_type->write_code1();
+ }
+
int x = fclose(code_file);
code_file = 0;
- fprintf(header_file, "#endif\n");
int y = fclose(header_file);
header_file = 0;
return x >= 0 && y >= 0;