groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Graph in a man page


From: Ted Harding
Subject: Re: [Groff] Graph in a man page
Date: Fri, 20 Aug 2010 10:24:10 +0100 (BST)

On 20-Aug-10 08:30:33, Andre Majorel wrote:
> On 2010-08-20 09:37 +0200, Werner LEMBERG wrote:
>> 
>> > I'd like to include a simple diagram in a man page, something
>> > like this :
>> >
>> >             _____       _____        _____
>> >            |     |  A  |     |   C  |     |
>> >            |  X  |---->|  Y  |----->|  Z  |
>> >            |     |<----|     |<-----|     |
>> >            |_____|  B  |_____|   D  |_____|
>> >
>> > I suppose I could use tbl or switch to a fixed-spacing font and
>> > use .nf. What would you recommend ?
>> 
>> The advantage of tbl is that you get a real graphics with non-TTy
>> output devices.
> 
> But for the boxes, not for the arrows, if I'm not mistaken.
> 
>> > It must work both in print and in a terminal and not depend on
>> > Groff.
>> 
>> `Must not depend on groff'?  What does this mean?
> 
> Simply that it must work with any nroff & troff, not just Groff.
> -- 
> André Majorel http://www.teaser.fr/~amajorel/

I almost never have occasion to use groff for "terminal" ouput,
so was not aware of the apparent problems I note below.

First, however, the following will produce terminal output
similar to what André wants -- EXCEPT that I cannot get it to
put ">" or "<" at the ends of the lines to make them into arrows.

1. File "picboxes.tr"
=====================
.LP
I'd like to include a simple diagram in a man page, 
.br 
something like this :
.sp
.PS
bwd=0.75  # Width of each box
bht=1.0   # Height of each box
bsp=0.75  # Spacing between boxes
lsp=0.2   # Half of spacing between "arrows"
box wid bwd ht bht 1 "X"
define border {
line from last box.sw to last box.se \
to last box.ne to last box.nw to last box.sw
}
border
line -> right bsp from last box.e + (0,lsp) "A" " "
box wid bwd ht bht with .w at last box.e + (bsp,0) "Y"
border
line -> right bsp from last box.e + (0,lsp) "C" " "
line -> left  bsp from last box.w - (0,lsp) " " "B"
box wid bwd ht bht with .w at last box.e + (bsp,0) "Z"
border
line -> left  bsp from last box.w - (0,lsp) " " "D"
.PE
.sp
I suppose I could use tbl or switch to a fixed-spacing
.br
font and use .nf. What would you recommend ?


2. groff command (in terminal):
===============================
groff -Tlatin1 -p -ms picboxes.tr | less

3. What you see when you run the above:
=======================================
I'd like to include a simple diagram in a man page,
something like this :


           +------+       +------+       +------+
           |      |   A   |      |   C   |      |
           |      +-------|      +-------|      |
           |  X   |       |  Y   |       |  Z   |
           |      |-------+      |-------+      |
           |      |   B   |      |   D   |      |
           +------+       +------+       +------+


I suppose I could use tbl or switch to a fixed-spacing
font and use .nf. What would you recommend ?

COMMENTS:
=========
Note that the lines, while they have their starting points
indicated ("+"), do not have ">" or "<" at the ends for arrows,
despite being coded as "line ->" or "line <-" which certainly
work for PostScript output.

ALSO, note the presence in the pic code of "define border {...}",
followed by invocations of the macro "border" subsequent to each box.
I had to put this in because, with "-Tascii" or "-Tlatin1",
the 'box' command on its own draws no lines, so you don't see
the boxes. Hence I put in the macro "border" to draw the borders
of the boxes using explicit "line" commands.

These problems would not arise with PostScript output, but I am
puzzled as to why they should occur with ASCII otuput to a terminal.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Aug-10                                       Time: 10:24:07
------------------------------ XFMail ------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]