mirror of https://github.com/fltk/fltk
parent
f57b074378
commit
7161cad2c7
|
@ -634,24 +634,7 @@ void Fl_Code_Type::write_code1() {
|
|||
main_window->redraw(); // tell fluid to redraw; edits may affect tree's contents
|
||||
}
|
||||
|
||||
const char* c = name();
|
||||
if (!c) return;
|
||||
|
||||
const char *pch;
|
||||
const char *ind = indent();
|
||||
while( (pch=strchr(c,'\n')) )
|
||||
{
|
||||
int line_len = int(pch - c);
|
||||
if (line_len < 1)
|
||||
write_c("\n");
|
||||
else
|
||||
write_c("%s%.*s\n", ind, line_len, c);
|
||||
c = pch+1;
|
||||
}
|
||||
if (*c)
|
||||
write_c("%s%s\n", ind, c);
|
||||
else
|
||||
write_c("\n");
|
||||
write_c_indented(name(), 0, '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -228,7 +228,7 @@ void Fl_Menu_Item_Type::write_static() {
|
|||
write_c(", %s", ut);
|
||||
if (use_v) write_c(" v");
|
||||
write_c(") {\n");
|
||||
write_c_indented(callback());
|
||||
write_c_indented(callback(), 1, 0);
|
||||
if (*(d-1) != ';' && *(d-1) != '}') {
|
||||
const char *p = strrchr(callback(), '\n');
|
||||
if (p) p ++;
|
||||
|
|
|
@ -2067,7 +2067,7 @@ void Fl_Widget_Type::write_static() {
|
|||
write_c(", %s", ut);
|
||||
if (use_v) write_c(" v");
|
||||
write_c(") {\n");
|
||||
write_c_indented(callback());
|
||||
write_c_indented(callback(), 1, 0);
|
||||
if (*(d-1) != ';' && *(d-1) != '}') {
|
||||
const char *p = strrchr(callback(), '\n');
|
||||
if (p) p ++;
|
||||
|
|
|
@ -410,18 +410,35 @@ void write_hc(const char *indent, int n, const char* c, const char *com) {
|
|||
Write one or more lines of code, indenting each one of them.
|
||||
\param[in] textlines one or more lines of text, seperated by \\n
|
||||
*/
|
||||
void write_c_indented(const char *textlines) {
|
||||
void write_c_indented(const char *textlines, int inIndent, char inTrailwWith) {
|
||||
if (textlines) {
|
||||
indentation++;
|
||||
indentation += inIndent;
|
||||
for (;;) {
|
||||
int line_len;
|
||||
const char *newline = strchr(textlines, '\n');
|
||||
if (!newline) break;
|
||||
write_c("%s%.*s\n", indent(), (int)(newline-textlines), textlines);
|
||||
if (newline)
|
||||
line_len = (int)(newline-textlines);
|
||||
else
|
||||
line_len = strlen(textlines);
|
||||
if (textlines[0]=='\n') {
|
||||
// avoid trailing spaces
|
||||
} else if (textlines[0]=='#') {
|
||||
// don't indent preprocessor statments starting with '#'
|
||||
write_c("%.*s", (int)(newline-textlines), textlines);
|
||||
} else {
|
||||
// indent all other text lines
|
||||
write_c("%s%.*s", indent(), (int)(newline-textlines), textlines);
|
||||
}
|
||||
if (newline) {
|
||||
write_c("\n");
|
||||
} else {
|
||||
if (inTrailwWith)
|
||||
write_c("%c", inTrailwWith);
|
||||
break;
|
||||
}
|
||||
textlines = newline+1;
|
||||
}
|
||||
if (*textlines)
|
||||
write_c("%s%s", indent(), textlines);
|
||||
indentation--;
|
||||
indentation -= inIndent;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void write_c(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
|||
void write_cc(const char *, int, const char*, const char*);
|
||||
void write_h(const char*, ...) __fl_attr((__format__ (__printf__, 1, 2)));
|
||||
void write_hc(const char *, int, const char*, const char*);
|
||||
void write_c_indented(const char *textlines);
|
||||
void write_c_indented(const char *textlines, int inIndent, char inTrailwWith);
|
||||
int write_code(const char *cfile, const char *hfile);
|
||||
int write_strings(const char *sfile);
|
||||
void write_public(int state); // writes pubic:/private: as needed
|
||||
|
|
Loading…
Reference in New Issue