diff options
Diffstat (limited to 'src/PSEditModel.cxx')
-rw-r--r-- | src/PSEditModel.cxx | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/PSEditModel.cxx b/src/PSEditModel.cxx index 81e2bf4..a7542f2 100644 --- a/src/PSEditModel.cxx +++ b/src/PSEditModel.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditModel.cxx,v 1.2 2004/10/21 20:12:36 hofmann Exp $" +// "$Id: PSEditModel.cxx,v 1.3 2004/10/21 21:02:05 hofmann Exp $" // // PSEditWidget routines. // @@ -37,6 +37,7 @@ PSEditModel::PSEditModel(int x1, int y1, float dx, float dy) { xdpi = dx; ydpi = dy; max_pages = 32; + page = 0; text = (PSEditText**) malloc(sizeof(PSEditText*) * max_pages); if (!text) { perror("malloc"); @@ -45,15 +46,16 @@ PSEditModel::PSEditModel(int x1, int y1, float dx, float dy) { for (int i = 0; i < max_pages; i++) { text[i] = NULL; } + cur_text = NULL; } void PSEditModel::set_page(int p) { int old_max_pages; - old_max_pages = max_pages; - if (p >= max_pages) { + old_max_pages = max_pages; + max_pages = p + max_pages; text = (PSEditText**) realloc(text, sizeof(PSEditText*) * max_pages); if (!text) { @@ -81,6 +83,8 @@ void PSEditModel::clear() { } void PSEditModel::new_text(int x1, int y1, const char *s, int size, int p) { + set_page(p); + cur_text = new PSEditText(x1, y1, s, size); if (text[p]) { text[p]->append(cur_text); @@ -163,6 +167,24 @@ char *PSEditModel::get_tag() { } } +int PSEditModel::replace_tag(char *tag, char *txt) { + PSEditText *t; + int p, ret = 0; + fprintf(stderr, "%s => %s\n", tag, txt); + for (p = 0; p < max_pages; p++) { + t = get_text(p); + while (t) { + if (t->get_tag() && strcmp(t->get_tag(), tag) == 0) { + t->set_text(txt); + ret++; + } + t = t->get_next(); + } + } + + return ret; +} + PSEditText *PSEditModel::get_text(int p) { if (p >= max_pages) { return 0; |