diff options
-rw-r--r-- | src/PSEditWidget.cxx | 8 | ||||
-rw-r--r-- | src/Postscript.H | 3 | ||||
-rw-r--r-- | src/Postscript.cxx | 13 | ||||
-rw-r--r-- | src/flpsed.cxx | 13 |
4 files changed, 27 insertions, 10 deletions
diff --git a/src/PSEditWidget.cxx b/src/PSEditWidget.cxx index f6de76d..c10d550 100644 --- a/src/PSEditWidget.cxx +++ b/src/PSEditWidget.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditWidget.cxx,v 1.16 2004/10/12 20:52:23 hofmann Exp $" +// "$Id: PSEditWidget.cxx,v 1.17 2004/10/13 18:03:08 hofmann Exp $" // // PSEditWidget routines. // @@ -311,7 +311,11 @@ int PSText::set_tag(const char *t) { if (tag) { free(tag); } - tag = strdup(t); + if (t) { + tag = strdup(t); + } else { + tag = NULL; + } gsew->redraw(); return 0; } diff --git a/src/Postscript.H b/src/Postscript.H index bd4b4c2..72c4492 100644 --- a/src/Postscript.H +++ b/src/Postscript.H @@ -1,5 +1,5 @@ // -// "$Id: Postscript.H,v 1.2 2004/07/09 21:27:00 hofmann Exp $" +// "$Id: Postscript.H,v 1.3 2004/10/13 18:03:08 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -59,6 +59,7 @@ class PSWriter { char * size_format; char * text_format; char * glyph_format; + char * tag_format; void write_string(FILE *out, char *s); void write_internal_format(FILE *out); int write_text(FILE *out, PSText *t); diff --git a/src/Postscript.cxx b/src/Postscript.cxx index 7fdabcc..5461483 100644 --- a/src/Postscript.cxx +++ b/src/Postscript.cxx @@ -1,5 +1,5 @@ // -// "$Id: Postscript.cxx,v 1.8 2004/10/12 17:14:16 hofmann Exp $" +// "$Id: Postscript.cxx,v 1.9 2004/10/13 18:03:08 hofmann Exp $" // // Postscript handling routines. // @@ -28,6 +28,7 @@ #define PS_SIZE_FORMAT "/HelveticaNeue-Roman findfont %d scalefont setfont"\ " %% PSEditWidget\n" #define PS_GLYPH_FORMAT "/%s glyphshow %% PSEditWidget\n" +#define PS_TAG_FORMAT "" // // PSEditWidget internal format as PostScript comments @@ -42,6 +43,7 @@ #define PSEDIT_TEXT_FORMAT_SCAN "%% PSEditWidget: TEXT (%[^)])\n" #define PSEDIT_SIZE_FORMAT "%% PSEditWidget: SIZE %d\n" #define PSEDIT_GLYPH_FORMAT "%% PSEditWidget: GLYPH %s\n" +#define PSEDIT_TAG_FORMAT "%% PSEditWidget: TAG %s\n" // // Marker to set page number. This is necessary for viewers like ghostview @@ -166,6 +168,9 @@ int PSParser_2::parse(char *line) { } else if (inside && sscanf(line, PSEDIT_TEXT_FORMAT_SCAN, buf) == 1) { pse->append_text(buf); return 1; + } else if (inside && sscanf(line, PSEDIT_TAG_FORMAT, buf) == 1) { + pse->set_tag(buf); + return 1; } else if (inside) { return 1; } else if (sscanf(line, PSEDIT_PAGE_MARKER, &dummy) == 1) { @@ -204,6 +209,7 @@ int PSWriter::write(FILE *in, FILE *out) { size_format = PS_SIZE_FORMAT; text_format = PS_TEXT_FORMAT; glyph_format = PS_GLYPH_FORMAT; + tag_format = PS_TAG_FORMAT; fprintf(out, "\n"); fprintf(out, ps_header()); @@ -237,6 +243,7 @@ void PSWriter::write_internal_format(FILE *out) { size_format = PSEDIT_SIZE_FORMAT; text_format = PSEDIT_TEXT_FORMAT_PRINT; glyph_format = PSEDIT_GLYPH_FORMAT; + tag_format = PSEDIT_TAG_FORMAT; for (int i=1;i<pse->get_max_pages();i++) { if (pse->get_text(i)) { @@ -285,6 +292,10 @@ int PSWriter::write_text(FILE *out, PSText *t) { fprintf(out, pos_format, pse->ps_x(t->get_x()), pse->ps_y(t->get_y())); + if (t->get_tag()) { + fprintf(out, tag_format, t->get_tag()); + } + write_string(out, s); } diff --git a/src/flpsed.cxx b/src/flpsed.cxx index be72d7d..eb85736 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -1,5 +1,5 @@ // -// "$Id: flpsed.cxx,v 1.15 2004/10/12 20:52:23 hofmann Exp $" +// "$Id: flpsed.cxx,v 1.16 2004/10/13 18:03:08 hofmann Exp $" // // flpsed program. // @@ -139,7 +139,6 @@ void about_cb() { "PostScript is a registered trademark of Adobe Systems"); } - void size_cb(Fl_Widget *w, void *) { Fl_Menu_* mw = (Fl_Menu_*)w; const Fl_Menu_Item* m = mw->mvalue(); @@ -157,10 +156,12 @@ void edit_tag_cb() { char *tag = gsw_p->get_tag(); const char *new_tag; new_tag = fl_input("Tag Name", tag?tag:""); - if (strcmp(new_tag, "") != 0) { - gsw_p->set_tag(new_tag); - } else { - gsw_p->set_tag(NULL); + if (new_tag) { + if (strcmp(new_tag, "") != 0) { + gsw_p->set_tag(new_tag); + } else { + gsw_p->set_tag(NULL); + } } } |