groff
[Top][All Lists]
Advanced

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

Re: [groff] Advice wanted on drawing a file tree with pic


From: G. Branden Robinson
Subject: Re: [groff] Advice wanted on drawing a file tree with pic
Date: Thu, 7 Jun 2018 13:37:09 -0400
User-agent: NeoMutt/20170113 (1.7.2)

[replying only to list]

Thank you, gentlemen!

At 2018-06-06T22:22:37+1000, John Gardner wrote:
> > I'm trying to help out another project (quilt) with some
> > non-portability in one of their man pages.  Right now they're
> > embedding raw UTF-8 codepoints into text to use line-drawing
> > characters to depict a file hierarchy.
> 
> Oh man, I'm so glad I'm not the only one who's tried doing that with
> tree(1) output...

Hmm, that suggests a good place to propose a patch for *roff-friendly
output.

> I actually found myself in Brandan's shoes, but then I learned mandoc
> doesn't do line-drawing, so I nuked the entire diagram.
> 
> Moral of the story: don't write manpages if your editor font has
> spiffy-looking box-drawing symbols that seamlessly connect, it never ends
> well for productivity. =(

Yeah, those fancy line-drawing symbols don't look so good when you -Tpdf
them.

The fixed-width font GMail uses for email bodies (if you insist on one)
also makes the line-drawing output look like forty miles of bad road.

At 2018-06-06T12:39:29+0100, Ralph Corderoy wrote:
> Hi Branden,
> 
> > I'm trying to help out another project (quilt) with some
> > non-portability in one of their man pages.  Right now they're
> > embedding raw UTF-8 codepoints into text to use line-drawing
> > characters to depict a file hierarchy.
> 
> https://manned.org/quilt.1#head7 shows
> 
>     work/
>     ├── patches/
>     │    ├── series         (list of patches to apply)
>     │    ├── patch1.diff    (one particular patch)
>     │    ├── patch2.diff
>     │    └── ...
>     ├── .pc/
>     │    ├── .quilt_patches (content of QUILT_PATCHES)
>     │    ├── .quilt_series  (content of QUILT_SERIES)
>     │    ├── patch1.diff/   (copy of patched files)
>     │    │    └── ...
>     │    ├── patch2.diff/
>     │    │    └── ...
>     │    └── ...
>     └── ...
> 
> Indentation alone would seem sufficient to expose the hierarchy,
> but if they are intent on drawing lines.

Those UTF-8 characters go all wrong when a troff rather than nroff
output device is used.

> > Therefore please critique the following PIC.
> 
> pic seems overkill.  It seems to me they need three strings defined that
> render to the same width.
> 
>     VER  |    │
> 
>     TEE  |--  ├──
> 
>     ELL  '--  └──
> 
> A replacement shows it covers their tree.
> 
>     work/
>     TEE patches/
>     VER  TEE series         (list of patches to apply)
>     VER  TEE patch1.diff    (one particular patch)
>     VER  TEE patch2.diff
>     VER  ELL ...
>     TEE .pc/
>     VER  TEE .quilt_patches (content of QUILT_PATCHES)
>     VER  TEE .quilt_series  (content of QUILT_SERIES)
>     VER  TEE patch1.diff/   (copy of patched files)
>     VER  VER  ELL ...
>     VER  TEE patch2.diff/
>     VER  VER  ELL ...
>     VER  ELL ...
>     ELL ...

Yes, thanks, and you're right.  I'll try this!

At 2018-06-06T19:41:11+0200, Tadziu Hoffmann wrote:
> 
> 
> > Therefore please critique the following PIC.  It looks okay
> > but I'm sure it could be improved in appearance and
> > (especially) general style.
> 
> Since this is structurally like a bulleted list, maybe doing
> this in pic is more complicated than necessary?  I'm thinking
> a simple approach with a few macros should do the trick.
> All that needs to be done is to remember the height of the
> previous items at each level, and then use the \D'l ...' escape
> to draw the lines instead of the list bullets, something like
> in the attached example.  (Most of the finicky stuff here is
> for treating the first entry differently.)
> The added bonus is that it also works nicely in nroff.

Thanks, Tadziu!  This is quite a bit fancier than what I had in mind.

I was planning on falling back on stupid .schar tricks for ASCII
substitute characters if the output device doesn't have the box-drawing
glyphs defined.

If I have problems with Ralph's patch (or if the quilt guys want
something sexier and more sophisticated), I'll revisit your approach.

> .\" ----------------------------------------------------------------
> .if n .nr EZ 12p \" display skip
> .if t .nr EZ  6p \" display skip
> .if n .nr ^^ 12p \" extra space between items
> .if t .nr ^^  4p \" extra space between items
> .nr >> 2n \" indent per level
> .\" ----------------------------------------------------------------
> .de <<
> .in +\\n(>>u+2n
> .nr ## +1
> .nr **\\n(## \\n(^^u+.5m
> ..
> .de >>
> .in -\\n(>>u+2n
> .nr ## -1
> ..
> .de ==
> .di <>
> .if !\\n(#1 .sp \\n(^^u
> .ie \\n(#1 \Z'\h'-1n'\v'-.5n'\D'l -\\n(>>u 0'\D'l -1n 0            '\v'.5n''\c
> .el        \Z'\h'-1n'\v'-.5n'\D'l -\\n(>>u 0'\D'l 0 -\\n[**\\n(##]u'\v'.5n''\c
> \&\\$*
> .br
> .di
> .nr **\\n(## \\n(dn
> .if \\n(#1 .nr **\\n(## +\\n(^^u
> .if \\n(##>1 .++ \\n(## \\n(dn
> .in 0
> .nf
> .<>
> .fi
> .in
> .nr #1 0
> ..
> .de ++
> .nr #= \\$1-1
> .nr **\\n(#= +\\$2
> .if \\n(#=>1 .++ \\n(#= \\$2
> ..
> .de EX
> .br
> .nr #1 1
> .nr ## 0
> .in +\\n(>>u+2n
> .di EY
> ..
> .de EE
> .di
> .ne \\n(dnu+.5v
> .sp \\n(EZu
> .nf
> .in 0
> .EY
> .sp \\n(EZu
> .in
> .in -\\n(>>u+2n
> .fi
> ..
> .\" ----------------------------------------------------------------
> .po 2.5c
> .ll 21c-5c
> .sp 3c
> .ps 10
> .vs 12
> Text text text text text text text text text text text text text text text 
> text
> text text text text text text text text text text text text text text text 
> text
> text text text text text text text text text text text text text text text 
> text.
> .EX
> .<<
> .== project\-1.2.3/
> .<<
> .== patches/
> .<<
> .== series
> .== patch1.diff
> .== patch2.diff
> .== foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar 
> foo bar foo bar foo bar foo bar foo bar foo bar foo bar
> .== .\ .\ .
> .>>
> .== .pc/
> .<<
> .== .quilt_patches
> .== .quilt_series
> .== .patch1.diff/
> .<<
> .== .\ .\ .
> .>>
> .== .patch2.diff/
> .<<
> .== .\ .\ .
> .>>
> .>>
> .>>
> .== project\-4.5.6/
> .== project\-7.8.9/
> .>>
> .EE
> Text text text text text text text text text text text text text text text 
> text
> text text text text text text text text text text text text text text text 
> text
> text text text text text text text text text text text text text text text 
> text.

-- 
Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

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