summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-10-05 14:12:09 +0000
committerwlemb <wlemb>2001-10-05 14:12:09 +0000
commitd2b33439cf213ab60d62d6fe68b9cc9dead41995 (patch)
treef5758f60a78e70aa77063686652b32ff66381a3c /doc
parentaaef8f141239e392a0caa5f7937e377c97fe4a94 (diff)
downloadgroff-d2b33439cf213ab60d62d6fe68b9cc9dead41995.tar.gz
Implementing color support in troff, pic, grops, and grohtml. These
changes are based on a major patch provided by Gaius Mulley <gaius@glam.ac.uk>. New request: `defcolor', supporting rgb, cmy, cmyk, and gray definitions with both hex values and fractions. New escapes: \m and \M for drawing and background color, respectively. This corresponds to the troff output commands `m' and `DF'. groff and troff accept command line switch `-c' to disable color output (which is automatically disabled in compatibility mode). New scaling indicator `f' for fractions (1f = 65536u). New conditional operator `m' to test for defined colors with `if' and `ie'. New keywords `color' (or `colour', `colored', `coloured'), `outline' (or `outlined'), and `shaded' added to pic. * src/include/color.h: New file. * src/include/driver.h: Include it. * src/include/printer.h: Include color.h. (environment): New members `col' and `fill'. (printer): Remove `adjust_arc_center' member function. * src/include/Makefile.sub: Updated. * src/libs/libdriver/input.cc (do_file): Initialize `env.col' and `env.fill'. Handle `m' and `DF' troff commands. * src/libs/libgroff/color.cc: New file. * src/libs/libgroff/Makefile.sub: Updated. * src/preproc/html/pre-html.cc (IMAGE_BORDER_PIXELS): Set to 2. (stop): Removed. (createImage): Fix computation of `y2'. Use `pnmcrop' also. (buffer::write_file_html): Remove calls to `stop'. * src/preproc/pic/common.h (common_output): New abstract function members `set_color', `reset_color', `get_last_filled', and `get_outline_color'. * src/preproc/pic/object.h: Add `IS_SHADED' and `IS_OUTLINED'. (object_spec): Add members `shaded' and `outlined'. * src/preproc/pic/output.h (output): `command' is now abstract. New function members `set_color', `reset_color', `get_last_filled', and `get_outline_color'. * src/preproc/pic/lex.cc (lookup_keyword): Recognize `colo[u]r[ed]', `outline[d]', and `shaded'. * src/preproc/pic/object.cc (output::command): Removed. (output::set_location):Moved to output.h. (graphic_object): Add protected members `outline_color' and `color_fill'. Add member functions `set_outline_color', `get_outline_color', and `set_fill_color'. (closed_object): Add member function `set_fill_color'. Add member `color_fill'. (graphic_object::print_text): Use `out->set_color' and `out->reset_color'. (box_object::print, ellipse_object::print, circle_object::print, line_object::print, spline_object::print, arc_object::print): Ditto. (object_spec::make_object): Implement `IS_OUTLINED' and `IS_SHADED'. * src/preproc/pic/pic.y: Add tokens `COLORED', `OUTLINED', and `SHADED', making them `%left'. Add rules `object_spec [SHADED|COLORED|OUTLINED] text'. * src/preproc/pic/tex.cc (tex_output): New dummy function members `set_color', `reset_color', `get_last_filled', and `get_outline_color'. * src/preproc/pic/troff.cc (simple_output): New abstract function members `set_color', `reset_color', and `get_last_filled'. (simple_output::polygon, simple_output::circle, simple_output::ellipse): Use `get_last_filled'. (troff_output): New members `last_filled' and `last_outlined'. New function members `set_color', `reset_color', `get_last_filled', and `get_outline_color'. (troff_output::finish_picture): Use `reset_color'. (troff_output::set_fill): Test `last_filled'. * src/preproc/pic/pic.man: Updated. * src/roff/groff/groff.cc (main): Implement `-c' option. (synopsis, help): Updated. src/roff/groff/groff.man: Updated. * src/roff/troff/troff.h: Include color.h. (warning_type): Add WARN_COLOR. * src/roff/troff/env.h (environment): New members `{cur,prev}_{glyph,fill}_color'. New member functions `get_{prev_,}{glyph,fill}_color'. * src/roff/troff/env.cc: Initialize and implement them. * src/roff/troff/input.cc: New global variable `disable_color_flag'. Replace `NULL' with `0' everywhere for consistency. (lookup_color, default_black, do_glyph_color, do_fill_color, get_color_element, read_rgb, read_cmy, read_cmyk, read_gray, define_color): New functions. (token::next): Implement \M and \m escapes. (do_if_request): Implement `m' operator. (usage): Updated. (main): Implement `-c' option. (init_markup_requests): Add `defcolor' request. (warning_table): Add `color' warning. * src/roff/troff/node.h (glyph_color_node, fill_color_node): New classes. * src/roff/troff/node.cc (troff_output_file): New members `current_{page,glyph}color'. New member functions `put_hex', `glyph_color', and `fill_color'. (glyph_color_node::*, fill_color_node::*): Implement it. * src/roff/troff/number.cc (SCALE_INDICATOR_CHARS): Add `f'. (parse_term): Add support for `f'. * src/roff/troff/troff.man: Updated. * src/devices/grodvi/dvi.cc (draw_dvi_printer::draw): Add dummy entry for `F'. * src/devices/grolbp/lbp.cc (lbp_printer::draw): Ditto. * src/devices/grolj4/lj4.cc (lj4_printer::draw): Ditto. * src/devices/grohtml/html-text.h (HTML_TAG): Add COLOR_TAG. (tag_definition): Use `void *' for arg1. (html_text): New member functions `do_color' and `done_color'. Use `void *' for second parameter of `push_para' member function. New `push_para' member function with a single parameter. Use `char *' for parameter of `issue_table_begin' member funtion. New `issue_color_begin' member function. * src/devices/grohtml/html-text.cc (html_text::end_tag): Handle COLOR_TAG. (html_text::issue_color_begin): New function. (html_text::issue_table_begin): Use `char *' for parameter. (html_text::start_tag, html_text::shutdown, html_text::check_emit_text): Updated. (html_text::push_para): Use `void *' for second parameter. Add same function with only one parameter. (html_text::do_*): Updated. (html_text::do_color, html_text::done_color): New functions. * src/devices/grohtml/post-html.cc (style): New member `col'. Mew member `style' with 6 parameters. (style::style, style::operator==): Updated. (html_printer::do_font): Use it. (html_printer::draw): Add dummy entry for `F'. (html_printer::set_char): Updated. * src/devices/grohtml/grohtml.man: Updated. * src/devices/grops/ps.cc (ps_output::put_float): Use `%g' to have trailing zeroes removed. (ps_printer): New members `sbuf_color', `fill_color', and `output_color'. Removed member `fill'. New member function `set_color'. (ps_printer::ps_printer, ps_printer::set_char): Updated. (ps_printer::flush_sbuf, ps_printer::set_line_thickness, ps_printer::fill_path, ps_printer::draw): Use `set_color'. * tmac/color-html.tmac, tmac/color.tmac: New files. * tmac/troffrc: Include them. * tmac/www.tmac (URL, FTP, MAILTO): Use blue color. * tmac/Makefile.sub: Updated. * NEWS, doc/groff.texinfo, doc/pic.ms, man/groff_out.man, man/groff.man: Updated. * font/devps/prologue.ps: Define FC and CO functions. Fix incorrect cropping of images and incorrect handling of special characters. Fix handling of file names in \O. * src/include/geometry.h: New file. * src/libs/libgroff/geometry.cc: New file. * src/libs/libdriver/printer.cc (printer::adjust_arc_center): Moved to `geometry.cc'. * src/roff/troff/input.cc (get_delim_file_name): Fixed problem with initial spaces. (do_suppress): Updated. * src/roff/troff/node.cc: Include geometry.h. (troff_output_file::flush_tbuf): Fixed parameters to `check_output_limits'. (troff_output_file::check_charinfo): Ditto. (troff_output_file::determine_line_limits): Add support for `Da' and `Dl' commands. * src/devices/grohtml/post-html.cc (str_translate_to_html): Add new parameter `is_special' to decode special characters from escape sequences. (html_printer::do_title, html_printer::do_heading, html_printer::do_indentedparagraph, html_printer::translate_to_html, html_printer::special): Updated. * Makefile.sub (DISTCLEANFILES): Add stamp-h. Fix entry for config.h. * test-groff (GROFF_BIN_PATH): Add $builddir/roff/groff. * tmac/troffrc: Translate nonbreakable space character to `\~'. * src/preproc/eqn/eqn.man: Document -d command line option.
Diffstat (limited to 'doc')
-rw-r--r--doc/groff.texinfo111
-rw-r--r--doc/pic.ms49
2 files changed, 134 insertions, 26 deletions
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index 1255fbcf..3510c216 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -2466,6 +2466,7 @@ Users of macro packages may skip it if not interested in details.
* Diversions::
* Environments::
* Suppressing output::
+* Colors::
* I/O::
* Postprocessor Access::
* Miscellaneous::
@@ -2765,6 +2766,12 @@ Pica. Another typesetting measurement. 6@w{ }Picas to an inch (and
@cindex @code{z} unit
@cindex unit, @code{z}
@xref{Fractional Type Sizes}, for a discussion of these units.
+
+@item f
+@cindex @code{f} unit
+@cindex unit, @code{f}
+Fractions. Value is 65536.
+@xref{Colors}, for usage.
@end table
The other measurements understood by @code{gtroff} depend on
@@ -7012,6 +7019,9 @@ True if there is a number register named @var{xxx}.
@item d @var{xxx}
True if there is a string, macro, diversion, or request named @var{xxx}.
+@item m @var{xxx}
+True if there is a color named @var{xxx}.
+
@item c @var{ch}
True if there is a character @var{ch} available; @var{ch} is either an
@acronym{ASCII} character or a special character (@code{\(@var{ch}} or
@@ -7396,7 +7406,7 @@ The @code{als} request can make a macro have more than one name.
This would be called as
@Example
-.vl $Id: groff.texinfo,v 1.80 2001/09/11 21:40:36 wlemb Exp $
+.vl $Id: groff.texinfo,v 1.81 2001/10/05 14:12:11 wlemb Exp $
@endExample
@endDefesc
@@ -8272,7 +8282,7 @@ Copies the environment @var{env} into the current environment.
@c =====================================================================
-@node Suppressing output, I/O, Environments, gtroff Reference
+@node Suppressing output, Colors, Environments, gtroff Reference
@section Suppressing output
@cindex suppressing output (@code{\O})
@@ -8282,10 +8292,13 @@ Disables or enables output depending on the value of @var{num}:
@table @samp
@item \O0
-Disable any ditroff glyphs from being emitted to the device driver.
+Disable any ditroff glyphs from being emitted to the device driver,
+provided that the escape occurs at the outer level (see @code{\O3} and
+@code{\O4}).
@item \O1
-Enable output of glyphs.
+Enable output of glyphs, provided that the escape occurs at the outer
+level.
@end table
@vindex opminx
@@ -8297,25 +8310,97 @@ Enable output of glyphs.
@xref{Register Index}. These four registers mark the top left and
bottom right hand corners of a box which encompasses all written glyphs.
-The following two forms of @code{\O} are specific to @code{grohtml}.
-
@table @samp
@item \O2
-Disable any ditroff glyphs from being emitted to the device driver. Also
-write out to @code{stderr} the page number and four registers encompassing
-the glyphs previously written since the last call to @code{\O}.
+Provided that the escape occurs at the outer level, enable output of
+glyphs and also write out to @code{stderr} the page number and four
+registers encompassing the glyphs previously written since the last call
+to @code{\O}.
@item \O3
-Enable output of glyphs (the default). Also write out to @code{stderr}
-the page number and four registers encompassing the glyphs previously
-written since the last call to @code{\O}.
+Begin a nesting level.
+
+@item \O4
+End a nesting level.
+
+@item \O[5 filename]
+This escape is @code{grohtml} specific. Provided that this escape
+occurs at the outer nesting level write the filename to @code{stderr}.
+This filename will be associated with the production of the next inline
+image.
@end table
@endDefesc
@c =====================================================================
-@node I/O, Postprocessor Access, Suppressing output, gtroff Reference
+@node Colors, I/O, Suppressing output, gtroff Reference
+@section Colors
+
+@Defreq {defcolor, ident scheme color_components}
+Define color with name @var{ident}. @var{scheme} can be one of the
+following values: @code{rgb} (three components), @code{cym} (three
+components), @code{cmyk} (four components), and @code{gray} or
+@code{grey} (one component).
+
+Color components can be given either as a hexadecimal string or as
+positive decimal integers in the range 0--65535. A hexadecimal string
+contains all color components concatenated. It must start with either
+@code{#} or @code{##}; the former specifies hex values in the range
+0--255 (which are internally multiplied by@w{ }257), the latter in the
+range 0--65535. Examples: @code{#FFC0CB} (pink), @code{##ffff0000ffff}
+(magenta).
+
+@cindex @code{f} unit, and colors
+@cindex unit, @code{f}, and colors
+
+A new scaling indicator @code{f} has been introduced which multiplies
+its value by 65536; this makes it convenient to specify color components
+as fractions in the range 0 to@w{ }1 (1f equals 65536u). Example:
+
+@Example
+.defcolor darkgreen rgb 0.1f 0.5f 0.2f
+@endExample
+
+Note that @code{f} is the default scaling indicator for the
+@code{defcolor} request, thus the above statement is equivalent to
+
+@Example
+.defcolor darkgreen rgb 0.1 0.5 0.2
+@endExample
+@endDefreq
+
+@Defesc {\\m, , c, }
+@Defescx {\\m, @lparen{}, co, }
+@Defescx {\\m, @lbrack{}, color, @rbrack}
+Set drawing color. The following example shows how to turn the next four
+words red.
+
+@Example
+\m[red]these are in red\mP and these words are in black.
+@endExample
+
+The escape @code{\mP} returns to the previous color.
+@endDefesc
+
+@Defesc {\\M, , c, }
+@Defescx {\\M, @lparen{}, co, }
+@Defescx {\\M, @lbrack{}, color, @rbrack}
+Set background color for filled objects drawn with the
+@code{\D'@dots{}'} commands.
+
+A red ellipse can be created with the following code:
+
+@Example
+\M[red]\h'0.5i'\D'E 2i 1i'\Mp
+@endExample
+
+The escape @code{\MP} returns to the previous fill color.
+@endDefesc
+
+@c =====================================================================
+
+@node I/O, Postprocessor Access, Colors, gtroff Reference
@section I/O
@cindex i/o
@cindex input and output requests
diff --git a/doc/pic.ms b/doc/pic.ms
index 8b7b582d..14bd5413 100644
--- a/doc/pic.ms
+++ b/doc/pic.ms
@@ -10,7 +10,7 @@
.\" This document was written for free use and redistribution by
.\" Eric S. Raymond <esr@thyrsus.com> in August 1995.
.\"
-.\" $Id: pic.ms,v 1.7 2001/08/26 04:41:56 wlemb Exp $
+.\" $Id: pic.ms,v 1.8 2001/10/05 14:12:11 wlemb Exp $
.\"
.\" Set a proper TeX
.ie t .ds tx T\h'-.1667m'\v'.224m'E\v'-.224m'\h'-.125m'X
@@ -355,8 +355,7 @@ box width 3 "this text is far too long for a default box"
.PP
This modifier takes a dimension in inches. There is also a "height"
modifier that will change a box's height. The \fBwidth\fP keyword may
-be abbreviated to \fBewid\fP; the \fBheight\fP keyword to
-\fBheight\fP.
+be abbreviated to \fBwid\fP; the \fBheight\fP keyword to \fBht\fP.
.NH 2
Resizing Other Object Types
.PP
@@ -377,7 +376,7 @@ Ellipses are sized to fit in the rectangular box defined by their
axes, and can be resized with \fBwidth\fP and \fBheight\fP like boxes.
.PP
You can also change the radius of curvature of an arc with \fBrad\fP
-(which specifies the radius of the circle of which the arc is a segnmment).
+(which specifies the radius of the circle of which the arc is a segment).
Larger values yield flatter arcs.
.KS
.PS
@@ -566,7 +565,7 @@ box rad 0.2 "rad=0.2";
move;
box rad 0.25 "rad=0.25";
.PE
-.CE "3: \fBbox rad\fP with increasing radius values;"
+.CE "3: \fBbox rad\fP with increasing radius values"
.PP
Radius values higher than half the minimum box dimension are silently
truncated to that value.
@@ -642,7 +641,7 @@ values are darker; GNU \fBfillval\fP uses 0 for white and 1 for black.
.PS
circle fill; move; circle fill 0.4; move; circle fill 0.2;
.PE
-.CE "5: \fBcircle fill; move; circle fill 0.4; move; circle fill 0.9;\fB"
+.CE "5: \fBcircle fill; move; circle fill 0.4; move; circle fill 0.9;\fR"
.PP
GNU \fBgpic\fP makes some additional guarantees. A fill value greater
than 1 can also be used: this means fill with the shade of gray that
@@ -652,16 +651,37 @@ The invisible attribute does not affect the filling of objects. Any
text associated with a filled object will be added after the object
has been filled, so that the text will not be obscured by the filling.
.PP
-The closed-object modifier \fBsolid\fR is equivalent to \fBfill\fR
-with the darkest fill value (DWB \fBpic\fR had this capability but
+The closed-object modifier \fBsolid\fP is equivalent to \fBfill\fP
+with the darkest fill value (DWB \fBpic\fP had this capability but
mentioned it only in a reference section).
+.NH 2
+Colored Objects
+.PP
+As a GNU extension, three additional modifiers are available to specify
+colored objects. \fBoutline\fP sets the color of the outline, \fBshaded\fP
+the fill color, and \fBcolor\fP sets both. All three keywords expect a
+suffix specifying the color. Example:
+.KS
+.PS
+box color "yellow"; arrow color "cyan"; circle shaded "green" outline "black";
+.PE
+.CE "6: \fBbox color ""yellow""; arrow color ""cyan""; \
+circle shaded ""green"" outline ""black"";\fR"
+.PP
+Alternative spellings are \fBcolour\fP, \fBcolored\fP, \fBcoloured\fP,
+and \fBoutlined\fP.
+.PP
+Currently, color support is not available in \*(tx mode. Predefined color
+names for \fIgroff\fP(1) are in the file \f(CWcolor.tmac\fP; additional
+colors can be defined with the \f(CW.defcolor\fP request (see the manual
+page of GNU \fItroff\fP(1) for more details).
.NH 1
More About Text Placement
.PP
By default, text is centered at the geometric center of the object it is
-associated with. The modifier \fBljust\fR causes the left end to be
+associated with. The modifier \fBljust\fP causes the left end to be
at the specified point (which means that the text lies to the right of
-the specified place!), The modifier \fBrjust\fP puts the right end at
+the specified place!), the modifier \fBrjust\fP puts the right end at
the place. The modifiers \fBabove\fP and \fBbelow\fP center the text
one half line space in the given direction.
.PP
@@ -746,14 +766,14 @@ in the obvious way:
.PS
box; arrow; circle; down; arrow; ellipse
.PE
-.CE "3: \fBbox; arrow; circle; down; arrow; ellipse\fP
+.CE "3: \fBbox; arrow; circle; down; arrow; ellipse\fP"
.LP
You might have expected that program to yield this:
.KS
.PS
box; arrow; circle; move to last circle .s; down; arrow; ellipse
.PE
-.CE "4: More intuitive?
+.CE "4: More intuitive?"
.LP
But, in fact, to get Figure \*[SN]3 you have to do this:
.KS
@@ -956,7 +976,7 @@ the implied circle.
Locations Relative to Open Objects
.PP
Every open object (line, arrow, arc, or spline) has three named
-points; \fB.start\fP, \fB.center\fP, and \fB.end\fP. They can
+points: \fB.start\fP, \fB.center\fP, and \fB.end\fP. They can
also be used without leading dots in the \fBof\fP prefix form.
The center of an arc is the center of its circle, but the center of
a line, path, or spline is halfway between its endpoints.
@@ -2231,6 +2251,9 @@ on the block's bounding box.
invis \fR# Make primitive invisible\fP
solid \fR# Make closed figure solid\fP
fill <expr> \fR# Set fill density for figure\fP
+ colo[u]r[ed] <word> \fR# Set fill and outline color for figure\fP
+ outline[d] <word> \fR# Set outline color for figure\fP
+ shaded <word> \fR# Set fill color for figure\fP
same \fR# Copy size of previous object\fP
<text> <text> ... \fR# Text within object\fP
<expr> \fR# Motion in the current direction\fR