Think Tank Workspaces

pic(1) and troff

The commands are:

pic test.ms | troff | page
pic tets.ms | troff > blah.pdf

Create a file test.ms with the following:L

.PS
circle
.PE

This will create a circle

Here are the base objects

.PS
circle
ellipse
box
line
arrow
spline
arc
.PE

Now let's add text to each object.

.PS
circle "circle"
ellipse "ellipse"
box "box"
line "line"
arrow "arrow"
spline "spline"
arc "arc"
.PE

But thing will overlap if the text is too long

.PS
circle "circle text is too long"
ellipse "ellipse"
box "box"
line "line"
arrow "arrow"
spline "spline"
arc "arc"
.PE

To add new lines just add new quotes:

.PS
circle "circle text is too long" "this is" "cool"
ellipse "ellipse"
box "box"
line "line"
arrow "arrow"
spline "spline"
arc "arc"
.PE

Increase the circle rad 1

.PS
circle "circle text is too long" "this is" "cool" rad 1
ellipse "ellipse"
box "box"
line "line"
arrow "arrow"
spline "spline"
arc "arc"
.PE

Increase height (ht) and with (wid) by 1 also add comments with "#"

.PS
circle "circle text is too long" "this is" "cool" rad 1
ellipse "ellipse" ht 1 wid 1
box "box" ht 1 wid 1
#line "line"
#arrow "arrow"
#spline "spline"
#arc "arc"
.PE

Lets space things out and add a scale of 3 at the top

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
.PE

Lets draw from last object to next

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
arrow from last ellipse to last box
arc from last ellipse to last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
.PE

draw from certain boxes

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
box "box" ht 1 wid 1 at (4, -3)
box "box" ht 5 wid 1 at (4, -11)
arrow from last ellipse to last box
arc from last ellipse to 2nd box
arc from last box to 3rd last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
.PE

Draw objects from target names A: and B: they must be in caps so you could have BOX1: FOO2:

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
B: box "box" ht 1 wid 1 at (4, -3)
#	arrow from last ellipse to last box
#	arc from last ellipse to 2nd box
#	arc from last box to 3rd last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
A: box "box" ht 5 wid 1 at (4, -11)
arc from A to B
.PE

Position of the line w for (west) nw for (north west)

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
B: box "box" ht 1 wid 1 at (4, -3)
#	arrow from last ellipse to last box
#	arc from last ellipse to 2nd box
#	arc from last box to 3rd last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
A: box "box" ht 5 wid 1 at (4, -11)
arc from A.w to B.nw
.PE

Additional line in box B and the arch

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
#B: box "box" ht 1 wid 1 at (4, -3)
B: box "box" ht 1 wid 1 at last box.n
#	arrow from last ellipse to last box
#	arc from last ellipse to 2nd box
#	arc from last box to 3rd last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
A: box "box" ht 5 wid 1 at (4, -11)
arc from A.w to B.nw
.PE

My arch was reversed I changed out from A to B not sure if left worke or not

.PS 3
circle "circle text is too long" "this is" "cool" rad 1 at (-4, 0)
ellipse "ellipse" ht 1 wid 1 at (0, 0)
box "box" ht 1 wid 1 at (4,  0)
#B: box "box" ht 1 wid 1 at (4, -3)
B: box "box" ht 1 wid 1 at last box.n
#	arrow from last ellipse to last box
#	arc from last ellipse to 2nd box
#	arc from last box to 3rd last box
#	line "line"
#	arrow "arrow"
#	spline "spline"
#	arc "arc"
A: box "box" ht 5 wid 1 at (4, -11)
arc left from B.w to A.nw
.PE

Other interesting stuff

Because troff, not pic, actually handles the text, pic doesn’t really try to fit a label inside an object. You must determine the amount of text that will fit. The pic program ignores lines beginning with a period, permitting you to use troff requests to change the point size, font, or typeface. It is best to avoid spacing requests, and be sure to reset any change in point size.

When you specify a single text label with a line, pic centers it on the line. For instance, inline troff requests can be used to print a label in 14-point italic (i.e., 4 points larger than the current point size).

.PS
line "\fI\s14pic\s10\fR"
.PE

It produces:

images

Because the standard placement of labels is not always useful, you can specify the attributes above or below. In the following example, the point size is specified using the following .ps request:

.ps +2

line "\fIPIC\fR" above .ps -2 It produces:

images

If you supply two quoted arguments with line, the first will be printed above the line and the second printed below. You can also select a line or box that is dotted or dashed, as you can see in the next example:

box dotted "\f(CWbox
dotted\fP" above

https://www.oreilly.com/library/view/unix-text-processing/9780810462915/Chapter10.html


Quoth william@thinktankworkspaces.com:

I would like to have it open in acme and click put or sam and :w or and see it change quickly.

% cat /mnt/acme/log | awk '{ if($2 == "put") system("command goes here") }

You can run that in acme to run arbitrary commands whenever a file is saved. File name is available as $3 in that awk script, so it can also be limited to specific files.

I have hooks to automatically run go fmt when a Go file is saved, for instance.


% cat /mnt/acme/log | awk '{ if($2 == "put") system("command goes here") }

Nice. (Although, what did that cat ever do to you?) I would probable do it in rc: </mnt/acme/log while(line = {read}) if(~ $line(2) put) { … }

I probably mentioned already but the sam version is:

!fn w{echo w; command}

Then ^w writes and runs command.

umbraticus


To post a comment you need to login first.