From 259ef5d144dd7022bb8e8fa2221f773277fd72e7 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 20 Jan 2006 17:15:17 +0100 Subject: remove NULL check after strdup() --- src/flpsed.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/flpsed.cxx b/src/flpsed.cxx index dae4677..05dcee5 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -394,10 +394,6 @@ int main(int argc, char** argv) { break; case 't': tmp = strdup(optarg); - if (!tmp) { - perror("strdup"); - exit(1); - } sep = strchr(tmp, '='); if (!sep) { fprintf(stderr, "Cannot parse %s\n", optarg); -- cgit v1.2.3 From 87270613d16f082361537fbc1a80131a646756cf Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 20 Jan 2006 17:32:49 +0100 Subject: add support for some FLTK standard options like -geometry --- src/flpsed.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/flpsed.cxx b/src/flpsed.cxx index 05dcee5..f7014e8 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -365,7 +365,12 @@ void usage() { " optional input file; in batch mode if no\n" " input file is given, input is read from stdin\n" " optional output file for batch mode; if no\n" - " output file is given, output is written to stdout\n"); + " output file is given, output is written to stdout\n\n" + "additionally flpsed supports the following FLTK standard options:\n" + " -geometry WxH+X+Y\n" + " -iconic\n" + " -scheme string\n" + ); } #define TV_LEN 256 @@ -373,6 +378,7 @@ void usage() { int main(int argc, char** argv) { char *sep, *tmp, **my_argv; int c, err, bflag = 0, dflag = 0; + int i, n; Fl_Window *win; Fl_Menu_Bar *m; struct {char *tag; char *value;} tv[TV_LEN]; @@ -380,7 +386,7 @@ int main(int argc, char** argv) { FILE *in_fp = NULL, *out_fp = NULL; err = 0; - while ((c = getopt(argc, argv, "hdbt:")) != -1) { + while ((c = getopt(argc, argv, "hdbt:g:d:f:i:s:")) != -1) { switch (c) { case 'h': usage(); @@ -413,7 +419,13 @@ int main(int argc, char** argv) { free(tmp); break; default: - err++; + i = optind -1; + n = Fl::arg(argc, argv, i); + if (n == 0) { + err++; + } else { + optind = i; + } } } -- cgit v1.2.3 From e441405925865fe4d789040925aea20000d36f21 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 20 Jan 2006 17:44:30 +0100 Subject: add support for -z (zoom) option --- src/GsWidget.cxx | 16 ++++++++-------- src/flpsed.cxx | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/GsWidget.cxx b/src/GsWidget.cxx index dc134d2..1bb2e53 100644 --- a/src/GsWidget.cxx +++ b/src/GsWidget.cxx @@ -238,15 +238,15 @@ int GsWidget::zoom(int p) { zoom_percent = p; kill_gs(); - - // Clear widget - fl_begin_offscreen(offscreen); - fl_color(FL_WHITE); - fl_rectf(0, 0, w(), h()); - fl_end_offscreen(); - redraw(); - + if (offscreen) { + // Clear widget with current size + fl_begin_offscreen(offscreen); + fl_color(FL_WHITE); + fl_rectf(0, 0, w(), h()); + fl_end_offscreen(); + redraw(); + fl_delete_offscreen(offscreen); offscreen = 0; } diff --git a/src/flpsed.cxx b/src/flpsed.cxx index f7014e8..b9f879f 100644 --- a/src/flpsed.cxx +++ b/src/flpsed.cxx @@ -356,11 +356,12 @@ Fl_Menu_Item size_menu[] = { void usage() { fprintf(stderr, - "usage: flpsed [-hbd] [-t =] [] []\n" + "usage: flpsed [-hbdz] [-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" + " -z set the zoom percentage (e.g. 200)\n" " -t = set text to where tag is \n" " optional input file; in batch mode if no\n" " input file is given, input is read from stdin\n" @@ -384,9 +385,10 @@ int main(int argc, char** argv) { struct {char *tag; char *value;} tv[TV_LEN]; int tv_idx = 0, my_argc; FILE *in_fp = NULL, *out_fp = NULL; + int zoom_val = 0; err = 0; - while ((c = getopt(argc, argv, "hdbt:g:d:f:i:s:")) != -1) { + while ((c = getopt(argc, argv, "hdbt:z:g:d:f:i:s:")) != -1) { switch (c) { case 'h': usage(); @@ -418,6 +420,9 @@ int main(int argc, char** argv) { } free(tmp); break; + case 'z': + zoom_val = atoi(optarg); + break; default: i = optind -1; n = Fl::arg(argc, argv, i); @@ -524,6 +529,7 @@ int main(int argc, char** argv) { psed_p = new PSEditor(0, 0, 700, 900); psed_p->property_changed_callback(property_changed_cb); scroll->end(); + fl_open_display(); Fl::add_handler(xev_handler); @@ -533,7 +539,12 @@ int main(int argc, char** argv) { win->end(); win->callback((Fl_Callback *)quit_cb); win->show(1, argv); - + + + if (zoom_val) { + psed_p->zoom(zoom_val); + } + if (in_fp) { sleep(1); // this seems to be necessary on fast systems to make the // GHOSTVIEW property available to ghostsscript. -- cgit v1.2.3 From 594930da192bfb929ba4d293ba57597ead644dab Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 20 Jan 2006 17:48:06 +0100 Subject: 0.3.6-pre1 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 28df23a..2ffb66e 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.59) -AC_INIT(flpsed, 0.3.5, Johannes.Hofmann@gmx.de) +AC_INIT(flpsed, 0.3.6-pre1, Johannes.Hofmann@gmx.de) AM_INIT_AUTOMAKE AC_CONFIG_SRCDIR([src/GsWidget.H]) AC_CONFIG_HEADER(config.h) -- cgit v1.2.3 -- cgit v1.2.3