From bc7e8e0a1617eb26ec38b2a4e433efc9c7f85f6a Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Tue, 26 Oct 2004 14:58:49 +0000 Subject: cleanups cleanups --- NEWS | 7 ++++--- src/PSEditModel.H | 33 +++++++++++++++++++++++++++++++-- src/PSEditWidget.H | 27 ++++++++++++++++++++++++++- src/PSEditor.H | 11 ++++++++--- src/PSEditor.cxx | 14 +------------- src/Postscript.H | 24 +++++++++++++++++++++--- src/flpsed.cxx | 14 +++++++++----- 7 files changed, 100 insertions(+), 30 deletions(-) diff --git a/NEWS b/NEWS index 946468b..ae8fff9 100644 --- a/NEWS +++ b/NEWS @@ -2,12 +2,13 @@ flpsed ChangeLog ================= flpsed-0.3.0 - - Add support for tags (see README). + - Add support for tags (thanks to Reimar Bauer for his thoughts on this). - Add batch processing mode. - Load PostScript file given on the command line. + - Reduced flickering. flpsed-0.2.1 - - Fix segfault when reloading documents + - Fix segfault when reloading documents. flpsed-0.2 - Change internal format to allow for more compatible PostScript code. @@ -19,4 +20,4 @@ flpsed-0.2 - Add support for '\' character. flpsed-0.1 - - initial version + - Initial version. diff --git a/src/PSEditModel.H b/src/PSEditModel.H index fb43553..5f49f71 100644 --- a/src/PSEditModel.H +++ b/src/PSEditModel.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditModel.H,v 1.8 2004/10/26 16:41:40 hofmann Exp $" +// "$Id: PSEditModel.H,v 1.9 2004/10/26 16:58:49 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -27,43 +27,72 @@ #include "PSEditText.H" class PSEditModel { + PSEditText **text; + int max_pages; + int page; + PSEditText *cur_text; + float xdpi, ydpi; + int paper_x, paper_y; public: PSEditModel(int x1, int y1, float dx, float dy); + ~PSEditModel(); void clear(); + void new_text(int x1, int y1, const char *s, int size, int p); + void append_text(const char *s); + void move(int x1, int y1); + void rm_char(); + void set_size(int s); + int get_size(); + void set_page(int p); + int get_page(); + char *get_tag(); + int set_tag(const char *t); + int get_max_pages(); + int set_cur_text(int x1, int y1, int p); + int is_cur_text(PSEditText *t); + PSEditText *get_text(int p); + PSEditText *get_cur_text(); + int replace_tag(char* tag, char* text); + int dump_tags(); + int ps_to_display_x(int x1); + int ps_to_display_y(int y1); + int ps_x(int x1); + int ps_y(int y1); + int PSEditModel::load(FILE *fp); - int save(FILE *sfp, int tmp_fd); + int save(FILE *sfp, int tmp_fd); }; #endif diff --git a/src/PSEditWidget.H b/src/PSEditWidget.H index 1811972..6ad3704 100644 --- a/src/PSEditWidget.H +++ b/src/PSEditWidget.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditWidget.H,v 1.9 2004/10/23 19:57:14 hofmann Exp $" +// "$Id: PSEditWidget.H,v 1.10 2004/10/26 16:58:49 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -32,36 +32,61 @@ class PSText; class PSEditWidget : public GsWidget { private: int cur_size; + int show_tags; protected: PSEditModel *model; + int loaded; + int mod; + void clear_text(); + void draw(); public: PSEditWidget(int X,int Y,int W, int H); + int next(); + void new_text(int x1, int y1, const char *s, int p); + void new_text(int x1, int y1, const char *s); + int set_cur_text(int x1, int y1); + void append_text(const char *s); + void move(int x1, int y1, int last_x, int last_y); + void rm_char(); + int reload(); + void set_cur_size(int s); + void set_size(int s); + int get_size(); + int get_max_pages(); + char *get_tag(); + int set_tag(const char *t); + int get_show_tags(); + void set_show_tags(int s); + PSText * get_text(int p); + int modified(); + int file_loaded(); + int replace_tag(char* tag, char* text); }; diff --git a/src/PSEditor.H b/src/PSEditor.H index 10efd39..34873fe 100644 --- a/src/PSEditor.H +++ b/src/PSEditor.H @@ -1,5 +1,5 @@ // -// "$Id: PSEditor.H,v 1.6 2004/10/26 16:12:19 hofmann Exp $" +// "$Id: PSEditor.H,v 1.7 2004/10/26 16:58:49 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -29,18 +29,23 @@ class PSEditor : public PSEditWidget { private: int tmp_fd; + int ps_level; + int x_last, y_last; + int handle(int event); public: PSEditor(int X,int Y,int W, int H); + int load(FILE *fp); + int load(char *f); + int save(const char* savefile); + int import(char *f); - void set_ps_level(int l); - int get_ps_level(); }; diff --git a/src/PSEditor.cxx b/src/PSEditor.cxx index eee0712..caf3795 100644 --- a/src/PSEditor.cxx +++ b/src/PSEditor.cxx @@ -1,5 +1,5 @@ // -// "$Id: PSEditor.cxx,v 1.17 2004/10/26 16:12:19 hofmann Exp $" +// "$Id: PSEditor.cxx,v 1.18 2004/10/26 16:58:49 hofmann Exp $" // // PSEditor routines. // @@ -204,15 +204,3 @@ int PSEditor::import(char *f) { mod = 1; 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.H b/src/Postscript.H index d9c436f..735f72f 100644 --- a/src/Postscript.H +++ b/src/Postscript.H @@ -1,5 +1,5 @@ // -// "$Id: Postscript.H,v 1.4 2004/10/21 19:55:36 hofmann Exp $" +// "$Id: Postscript.H,v 1.5 2004/10/26 16:58:49 hofmann Exp $" // // X11 header file for the Fast Light Tool Kit (FLTK). // @@ -30,17 +30,21 @@ class PSParser { protected: PSEditModel *pse; + int cur_size; + int page; public: PSParser(PSEditModel *p); + virtual int parse(char *line); }; class PSParser_1 : public PSParser { public: PSParser_1(PSEditModel *p); + int parse(char *line); }; @@ -50,32 +54,46 @@ class PSParser_2 : public PSParser { public: PSParser_2(PSEditModel *p); + int parse(char *line); }; class PSWriter { protected: PSEditModel *pse; + char * pos_format; + 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, PSEditText *t); + virtual char *ps_header(); + virtual char *ps_trailer(); public: PSWriter(PSEditModel *p); + int write(FILE *in, FILE *out); }; class PSLevel1Writer : public PSWriter { protected: char *ps_header(); + char *ps_trailer(); + public: PSLevel1Writer(PSEditModel *p); }; @@ -83,11 +101,11 @@ class PSLevel1Writer : public PSWriter { class PSLevel2Writer : public PSWriter { protected: char *ps_header(); + char *ps_trailer(); + public: PSLevel2Writer(PSEditModel *p); }; - - #endif diff --git a/src/flpsed.cxx b/src/flpsed.cxx index 436f1ed..7b766f9 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -1,5 +1,5 @@ // -// "$Id: flpsed.cxx,v 1.21 2004/10/26 16:41:40 hofmann Exp $" +// "$Id: flpsed.cxx,v 1.22 2004/10/26 16:58:49 hofmann Exp $" // // flpsed program. // @@ -148,7 +148,6 @@ void size_cb(Fl_Widget *w, void *) { } void show_tags_cb(Fl_Widget* w, void*d) { - fprintf(stderr, "===> %d\n", ((int) d)); gsw_p->set_show_tags((int) d); } @@ -189,7 +188,7 @@ Fl_Menu_Item menuitems[] = { { 0 }, { "&Tags", 0, 0, 0, FL_SUBMENU }, - { "Sh&ow Tags", FL_CTRL + 'o', (Fl_Callback *)show_tags_cb, (void *)1, FL_MENU_RADIO|FL_MENU_VALUE}, + { "Show &Tags", FL_CTRL + 't', (Fl_Callback *)show_tags_cb, (void *)1, FL_MENU_RADIO|FL_MENU_VALUE}, { "&Hide Tags", FL_CTRL + 'h', (Fl_Callback *)show_tags_cb, (void *)0, FL_MENU_RADIO}, { "&Edit Tag", FL_CTRL + 'e', (Fl_Callback *)edit_tag_cb }, { 0 }, @@ -204,7 +203,8 @@ Fl_Menu_Item menuitems[] = { void usage() { fprintf(stderr, - "usage: flpsed [-d] [-b] [-t =] [] []\n" + "usage: flpsed [-hbd] [-t =] [] []\n" + " -h print this message\n" " -b batch mode (no gui)\n" " -d dump tags and values from a document\n" " to stdout (this implies -b)\n" @@ -228,8 +228,12 @@ int main(int argc, char** argv) { FILE *in_fp = NULL, *out_fp = NULL; err = 0; - while ((c = getopt(argc, argv, "dbt:")) != EOF) { + while ((c = getopt(argc, argv, "hdbt:")) != EOF) { switch (c) { + case 'h': + usage(); + exit(0); + break; case 'b': bflag = 1; break; -- cgit v1.2.3