diff options
author | Johannes Hofmann <johannes.hofmann@gmx.de> | 2004-07-18 18:49:43 +0000 |
---|---|---|
committer | Johannes Hofmann <johannes.hofmann@gmx.de> | 2004-07-18 18:49:43 +0000 |
commit | 5d8a189660934ba57e60860ccaa5205e4b982bbf (patch) | |
tree | 8c798c05a0b41291b6b2d975c74de6d1731bc0d9 | |
parent | 86d53fee2ecfad9a143bae0e5e17498207afecac (diff) |
fixes
fixes
-rw-r--r-- | src/PSEditor.H | 7 | ||||
-rw-r--r-- | src/PSEditor.cxx | 23 | ||||
-rw-r--r-- | src/Postscript.cxx | 66 |
3 files changed, 63 insertions, 33 deletions
diff --git a/src/PSEditor.H b/src/PSEditor.H index 3c6c8f5..5484ced 100644 --- a/src/PSEditor.H +++ b/src/PSEditor.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditor.H,v 1.1 2004/07/09 17:22:55 hofmann Exp $" +// "$Id: PSEditor.H,v 1.2 2004/07/18 20:49:43 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -31,7 +31,8 @@ class PSEditor : public PSEditWidget { int mark_x, mark_y; int loaded; int mod; - int tmp_fd; + int tmp_fd; + int ps_level; int handle(int event); @@ -41,6 +42,8 @@ public: int save(const char* savefile); int modified(); int file_loaded(); + void set_ps_level(int l); + int get_ps_level(); }; diff --git a/src/PSEditor.cxx b/src/PSEditor.cxx index bc50b59..20e9de2 100644 --- a/src/PSEditor.cxx +++ b/src/PSEditor.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditor.cxx,v 1.4 2004/07/09 22:51:39 hofmann Exp $" +// "$Id: PSEditor.cxx,v 1.5 2004/07/18 20:49:43 hofmann Exp $" // // PSEditor routines. // @@ -29,6 +29,7 @@ PSEditor::PSEditor(int X,int Y,int W, int H) : PSEditWidget(X, Y, W, H) { loaded = 0; mod = 0; + ps_level = 1; } int PSEditor::handle(int event) { @@ -137,7 +138,13 @@ int PSEditor::save(const char* savefile) { FILE *fp = fdopen(tmp_fd, "r"); rewind(fp); FILE *sfp = fopen(savefile, "w"); - PSWriter *pw = new PSLevel2Writer(this); + PSWriter *pw; + + if (ps_level == 2) { + pw = new PSLevel2Writer(this); + } else { + pw = new PSLevel1Writer(this); + } pw->write(fp, sfp); @@ -147,3 +154,15 @@ int PSEditor::save(const char* savefile) { mod = 0; return 0; } + +int PSEditor::get_ps_level() { + return ps_level; +} + +void PSEditor::set_ps_level(int l) { + if (l == 2) { + ps_level = 2; + } else { + ps_level = 1; + } +} diff --git a/src/Postscript.cxx b/src/Postscript.cxx index bb15312..6429863 100644 --- a/src/Postscript.cxx +++ b/src/Postscript.cxx @@ -1,5 +1,5 @@ // -// "$Id: Postscript.cxx,v 1.5 2004/07/09 22:51:39 hofmann Exp $" +// "$Id: Postscript.cxx,v 1.6 2004/07/18 20:49:43 hofmann Exp $" // // Postscript handling routines. // @@ -23,41 +23,47 @@ #include "Postscript.H" -#define PS_POS_FORMAT "newpath %d %d moveto %% PSEditWidget\n" -#define PS_TEXT_FORMAT "(%s) show %% PSEditWidget\n" -#define PS_SIZE_FORMAT "/HelveticaNeue-Roman findfont %d scalefont setfont %% PSEditWidget\n" -#define PS_GLYPH_FORMAT "/%s glyphshow %% PSEditWidget\n" +#define PS_POS_FORMAT "newpath %d %d moveto %% PSEditWidget\n" +#define PS_TEXT_FORMAT "(%s) show %% PSEditWidget\n" +#define PS_SIZE_FORMAT "/HelveticaNeue-Roman findfont %d scalefont setfont"\ + " %% PSEditWidget\n" +#define PS_GLYPH_FORMAT "/%s glyphshow %% PSEditWidget\n" // // PSEditWidget internal format as PostScript comments // -#define PSEDIT_BEGIN "%% PSEditWidget Begin\n" -#define PSEDIT_END "%% PSEditWidget End\n" +#define PSEDIT_BEGIN "% PSEditWidget Begin\n" +#define PSEDIT_END "% PSEditWidget End\n" -#define PSEDIT_PAGE_FORMAT "%% PSEditWidget: PAGE %d\n" -#define PSEDIT_POS_FORMAT "%% PSEditWidget: POS %d %d\n" +#define PSEDIT_PAGE_FORMAT "%% PSEditWidget: PAGE %d\n" +#define PSEDIT_POS_FORMAT "%% PSEditWidget: POS %d %d\n" #define PSEDIT_TEXT_FORMAT_PRINT "%% PSEditWidget: TEXT (%s)\n" #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_SIZE_FORMAT "%% PSEditWidget: SIZE %d\n" +#define PSEDIT_GLYPH_FORMAT "%% PSEditWidget: GLYPH %s\n" -#define PSEDIT_PAGE_MARKER "/PSEditWidgetPageCount %d def %% PSEditWidget\n" +// +// Marker to set page number. This is necessary for viewers like ghostview +// to display single pages properly. +// +#define PSEDIT_PAGE_MARKER "/PSEditWidgetPageCount %d def %% PSEditWidget\n" static struct { const char *glyph; const char *c; } glyph_char[] = { - {"adieresis", "ä"}, - {"Adieresis", "Ä"}, - {"odieresis", "ö"}, - {"Odieresis", "Ö"}, - {"udieresis", "ü"}, - {"Udieresis", "Ü"}, + {"adieresis", "ä"}, + {"Adieresis", "Ä"}, + {"odieresis", "ö"}, + {"Odieresis", "Ö"}, + {"udieresis", "ü"}, + {"Udieresis", "Ü"}, {"germandbls", "ß"}, - {"parenleft", "("}, + {"parenleft", "("}, {"parenright", ")"}, - {"backslash", "\\"}, + {"percent", "%"}, + {"backslash", "\\"}, {NULL, NULL}}; static const char * glyph_to_char(char *glyph) { @@ -184,7 +190,9 @@ int PSWriter::write(FILE *in, FILE *out) { int done=0, page = 1; while (fgets(linebuf, 1024, in) != NULL) { - if (!done && strncmp(linebuf, "%%EndSetup", 10) == 0) { + if (!done && + (strncmp(linebuf, "%%EndSetup", 10) == 0 || + strncmp(linebuf, "%%EndProlog", 10) == 0)) { done++; fprintf(out, "\n"); @@ -296,10 +304,10 @@ char * PSWriter::ps_trailer() { PSLevel1Writer::PSLevel1Writer(PSEditWidget *p) : PSWriter(p) {}; char * PSLevel1Writer::ps_header() { - return \ - "/PSEditWidgetPageCount 0 def\n" \ - "/PSEditWidgetPC 0 def\n" \ - "/PSEditWidgetshowpage /showpage load def\n" \ + return \ + "/PSEditWidgetPageCount 0 def\n" \ + "/PSEditWidgetPC 0 def\n" \ + "/PSEditWidgetshowpage /showpage load def\n" \ "/showpage {\n" \ "gsave initgraphics\n" \ "PSEditWidgetPageCount 0 eq { \n" \ @@ -317,12 +325,12 @@ char * PSLevel1Writer::ps_trailer() { PSLevel2Writer::PSLevel2Writer(PSEditWidget *p) : PSWriter(p) {}; char * PSLevel2Writer::ps_header() { - return \ - "/PSEditWidgetPageCount 0 def\n" \ - "<< /EndPage {\n" \ + return \ + "/PSEditWidgetPageCount 0 def\n" \ + "<< /EndPage {\n" \ "gsave initgraphics\n" \ "pop\n" \ - "PSEditWidgetPageCount 0 eq { \n" \ + "PSEditWidgetPageCount 0 eq { \n" \ "1 add %% use showpage counter instead.\n" \ "} {\n" \ "PSEditWidgetPageCount\n" \ |