diff options
author | ru <ru@FreeBSD.org> | 2002-10-11 08:52:17 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2002-10-11 08:52:17 +0000 |
commit | 127e61728bacf1fb90edd8be1b0c406619e78bc8 (patch) | |
tree | 8c45b0385e4d4d3172ddd7926de65d06c5b2e88b /contrib/groff/src/preproc/pic/troff.cc | |
parent | 737a9b93ec94c55fd85de176c9de9302f1a9f95f (diff) | |
download | FreeBSD-src-127e61728bacf1fb90edd8be1b0c406619e78bc8.zip FreeBSD-src-127e61728bacf1fb90edd8be1b0c406619e78bc8.tar.gz |
Virgin import of FSF groff v1.18.1
Diffstat (limited to 'contrib/groff/src/preproc/pic/troff.cc')
-rw-r--r-- | contrib/groff/src/preproc/pic/troff.cc | 83 |
1 files changed, 70 insertions, 13 deletions
diff --git a/contrib/groff/src/preproc/pic/troff.cc b/contrib/groff/src/preproc/pic/troff.cc index 62fe540..7ee7293 100644 --- a/contrib/groff/src/preproc/pic/troff.cc +++ b/contrib/groff/src/preproc/pic/troff.cc @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -21,7 +21,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "pic.h" #include "common.h" -#include "htmlindicate.h" const double RELATIVE_THICKNESS = -1.0; @@ -37,6 +36,9 @@ class simple_output : public common_output { virtual void simple_polygon(int, const position *, int) = 0; virtual void line_thickness(double) = 0; virtual void set_fill(double) = 0; + virtual void set_color(char *, char *) = 0; + virtual void reset_color() = 0; + virtual char *get_last_filled() = 0; void dot(const position &, const line_type &) = 0; public: void start_picture(double sc, const position &ll, const position &ur) = 0; @@ -140,11 +142,10 @@ void simple_output::spline(const position &start, const position *v, int n, void simple_output::polygon(const position *v, int n, const line_type <, double fill) { - if (driver_extension_flag) { - if (fill >= 0.0) { + if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) { + if (get_last_filled() == 0) set_fill(fill); - simple_polygon(1, v, n); - } + simple_polygon(1, v, n); } if (lt.type == line_type::solid && driver_extension_flag) { line_thickness(lt.thickness); @@ -159,8 +160,9 @@ void simple_output::polygon(const position *v, int n, void simple_output::circle(const position ¢, double rad, const line_type <, double fill) { - if (driver_extension_flag && fill >= 0.0) { - set_fill(fill); + if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) { + if (get_last_filled() == 0) + set_fill(fill); simple_circle(1, cent, rad); } line_thickness(lt.thickness); @@ -184,8 +186,9 @@ void simple_output::circle(const position ¢, double rad, void simple_output::ellipse(const position ¢, const distance &dim, const line_type <, double fill) { - if (driver_extension_flag && fill >= 0.0) { - set_fill(fill); + if (driver_extension_flag && ((fill >= 0.0) || (get_last_filled() != 0))) { + if (get_last_filled() == 0) + set_fill(fill); simple_ellipse(1, cent, dim); } if (lt.type != line_type::invisible) @@ -212,6 +215,8 @@ class troff_output : public simple_output { double scale; double last_line_thickness; double last_fill; + char *last_filled; // color + char *last_outlined; // color public: troff_output(); ~troff_output(); @@ -229,6 +234,10 @@ public: void simple_polygon(int, const position *, int); void line_thickness(double p); void set_fill(double); + void set_color(char *, char *); + void reset_color(); + char *get_last_filled(); + char *get_outline_color(); position transform(const position &); }; @@ -238,7 +247,8 @@ output *make_troff_output() } troff_output::troff_output() -: last_filename(0), last_line_thickness(BAD_THICKNESS), last_fill(-1.0) +: last_filename(0), last_line_thickness(BAD_THICKNESS), + last_fill(-1.0), last_filled(0), last_outlined(0) { } @@ -269,7 +279,6 @@ void troff_output::start_picture(double sc, scale = compute_scale(sc, ll, ur); height = (ur.y - ll.y)/scale; double width = (ur.x - ll.x)/scale; - graphic_start(0); printf(".PS %.3fi %.3fi", height, width); if (args) printf(" %s\n", args); @@ -288,6 +297,7 @@ void troff_output::finish_picture() { line_thickness(BAD_THICKNESS); last_fill = -1.0; // force it to be reset for each picture + reset_color(); if (!flyback_flag) printf(".sp %.3fi+1\n", height); printf(".if \\n(" FILL_REG " .fi\n"); @@ -296,7 +306,6 @@ void troff_output::finish_picture() // this is a little gross set_location(current_filename, current_lineno); fputs(flyback_flag ? ".PF\n" : ".PE\n", stdout); - graphic_end(); } void troff_output::command(const char *s, @@ -472,6 +481,54 @@ void troff_output::set_fill(double f) printf("\\D'f %du'\\h'%du'\n.sp -1\n", int(f*FILL_MAX), -int(f*FILL_MAX)); last_fill = f; } + if (last_filled) { + free(last_filled); + last_filled = 0; + printf("\\M[]\n.sp -1\n"); + } +} + +void troff_output::set_color(char *color_fill, char *color_outlined) +{ + if (driver_extension_flag) { + if (last_filled || last_outlined) { + reset_color(); + } + if (color_fill) { + printf("\\M[%s]\n.sp -1\n", color_fill); + last_filled = strdup(color_fill); + } + if (color_outlined) { + printf("\\m[%s]\n.sp -1\n", color_outlined); + last_outlined = strdup(color_outlined); + } + } +} + +void troff_output::reset_color() +{ + if (driver_extension_flag) { + if (last_filled) { + printf("\\M[]\n.sp -1\n"); + free(last_filled); + last_filled = 0; + } + if (last_outlined) { + printf("\\m[]\n.sp -1\n"); + free(last_outlined); + last_outlined = 0; + } + } +} + +char *troff_output::get_last_filled() +{ + return last_filled; +} + +char *troff_output::get_outline_color() +{ + return last_outlined; } const double DOT_AXIS = .044; |