[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Writing in gray with groff... possible?
From: |
baruchel |
Subject: |
Re: [Groff] Writing in gray with groff... possible? |
Date: |
Sun, 6 Aug 2000 13:04:30 +0200 |
User-agent: |
Mutt/1.2.5i |
Brest, le dimanche 6 août
Sorry for the ugly code of yesterday.
The new one is much more elegant, short, and efficace:
My new program is called M4T:
There is a set of macros called tmac.4t
(all the stuff is here. 'til now, there is only a filling-cell macro, but
the rest follows quickly).
and a small postprocessor (the m4t program)
The general syntax is:
tbl file | troff -m4t | m4t | grops > file.ps
The macros use what tbl does. That was my previous error: tbl makes a lot,
and I didn't care of it.
How to use it.
First, there is an init command, that must be just before the .TS
It is: .M4T
Then, after the .TE command, you can put as many m4t commands as you want
'Til now, there is only .m4tfc (fc if for fill-cell)
.m4tfc x y n
(for filling cell x,y with a n degree of gray).
It works great! Try it!
.M4T
.TS
tab(&);
c c c c.
a&b&c&d
a&b&c&d
a&b&c&d
.TE
.m4tfc 3 1 100
.m4tfc 2 2 240
And now, the code, much shorter than yesterday ;-)
2 files: tmac.4t
m4t
===tmac.4t==================================================
.de M4T
\\!m4t: init
..
.de m4tfc
.nr m4ti \\$1-1
.nr m4tj \\$2-1
.nr m4tk \\n[3cd\\n[m4ti]]+\\n(.o
.nr m4tl \\n[3cd\\$1]-\\n[3cd\\n[m4ti]]
.nr m4th \\n[3rt\\$2]-\\n[3rt\\n[m4tj]]
\\!m4t: H\\n[m4tk]
\\!m4t: V\\n[3rt\\n[m4tj]]
\\!m4t: Df \\$3 0
\\!m4t: DP \\n[m4tl] 0 0 \\n[m4th] -\\n[m4tl] 0 0 -\\n[m4th]
\\!m4t: Df 0 0
..
===m4t========================================================
#!/bin/sh
awk '
BEGIN { m = 0 }
{
if ((m == 0) && ($1 != "m4t:")) {
print $0
}
if ((m == 1) && ($1 != "m4t:")) {
n++
l[n] = $0
}
if ((m == 2) && ($1 != "m4t:")) {
m = 0
for (i=1; i<=n; i++) {
print l[i]
}
print $0
}
if ((m > 0) && ($1 == "m4t:")) {
m = 2
gsub("m4t: ","")
print $0
}
if ((m == 0) && ($0 == "m4t: init")) {
n = 0
m = 1
}
}
' $1