Imported Upstream version 1.23.0
[platform/upstream/groff.git] / contrib / sboxes / sboxes.tmac
1 .ig
2
3 sboxes.tmac
4
5 Copyright (C) 2021 Free Software Foundation, Inc.
6      Written by Deri James (deri@chuzzlewit.myzen.co.uk)
7
8 This file is part of groff.
9
10 groff is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation, either version 3 of the License, or (at your
13 option) any later version.
14
15 groff is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18 for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 ..
23 .if !\n(.g \{\
24 .  tm sboxes.tmac: macros require groff extensions; not loading
25 .  nx
26 .\}
27 .
28 .if \n(.C \{\
29 .  tm sboxes.tmac: macros do not work in compatibility mode; not loading
30 .  nx
31 .\}
32 .
33 .\" Define a string for use in diagnostic messages.
34 .ds bx*name sboxes.tmac\"
35 .
36 .if !r GS \
37 .  ab \*[bx*name]: ms macros must be loaded first; aborting
38 .
39 .if (\n[.x]\n[.y] < 123) \{\
40 .  ds bx*msg \*[bx*name]: groff 1.23 or later is required,\"
41 .  as bx*msg " but found groff \n[.x].\n[.y]; not loading\"
42 .  tm \*[bx*msg]
43 .  nx
44 .\}
45 .
46 .\" See if already loaded.
47 .if r GSBOX .nx
48 .
49 .\" GSBOX is defined if the package is loaded, and true if it will work.
50 .nr GSBOX 0
51 .if '\*[.T]'pdf' \
52 .  nr GSBOX 1
53 .
54 .nr bx*stack 0
55 .
56 .de bx*error
57 .  tm \*[bx*name]:\\n[.F]:\\n[.c]: error: \\$*
58 ..
59 .
60 .\" Define dummy macro if we're not formatting for the pdf device.
61 .if !\n[GSBOX] \{\
62 .  de pdfbackground
63 .  .
64 .\}
65 .
66 .\" Link into ms macros to trap footnote growth
67 .am fn@print-sep
68 .  nr bx*pb \\n[nl]u-2p
69 .  nop \!x X pdf: background footnote \\n[bx*pb]z
70 .  rr bx*pb
71 ..
72 .\" Has PD been actioned?
73 .am par*start
74 .  nr bx*PD \\n[PD]
75 ..
76 .
77 .de BOXSTART
78 .  fl
79 .  nr bx*stack \\n[bx*stack]+1u
80 .  nr bx*shad 0
81 .  nr bx*outl 0
82 .  nr bx*ind 1P
83 .  ds bx*wt 0
84 .  ds bx*type "\"
85 .  while \\n[.$] \{\
86 .    ie 'SHADED'\\$1' \{\
87 .       nop \\M[\\$2]\c
88 .       nr bx*shad 1
89 .       as bx*type "fill\"
90 .       shift 2
91 .    \}
92 .    el \{\
93 .     ie 'OUTLINED'\\$1' \{\
94 .       nop \\m[\\$2]\c
95 .       nr bx*outl 1
96 .       as bx*type "box\"
97 .       shift 2
98 .     \}
99 .     el \{\
100 .       ie 'WEIGHT'\\$1' \{\
101 .         ds bx*wt \\$2
102 .         shift 2
103 .       \}
104 .       el \{\
105 .         ie 'INDENT'\\$1' \{\
106 .           nr bx*ind \\$2
107 .           shift 2
108 .         \}
109 .         el \{\
110 .           bx*error ignoring unrecognized BOXSTART parameter '\\$1'
111 .           shift
112 .         \}
113 .       \}
114 .     \}
115 .    \}
116 .  \}
117 .
118 .  if '\\*[bx*type]'' .ds bx*type "fill"
119 .  nr bx*l \\n[\\n[.ev]:li]s+\\n[.o]s-\\n[bx*ind]u
120 .  nr bx*r \\n[bx*l]u+\\n[.l]-\\n[\\n[.ev]:li]+(\\n[bx*ind]u*2u)
121 .  nr bx*gap \\n[.v]-\\n[.ps]+\\*[bx*wt]
122 .  nr bx*bot \\n[.p]u-\\n[FM]u+\\n[bx*ind]u+\\n[.ps]u
123 .  nr bx*top \\n[HM]-\\n[bx*ind]u+\\n[bx*gap]u
124 .  ne \\n[bx*ind]u+2v+\\*[bx*wt]
125 .  sp -(2v-(\\n[bx*PD]u*2u))u
126 .  pdfbackground \\*[bx*type] \\n[bx*l]z \\n[bx*top]z \
127                               \\n[bx*r]z \\n[bx*bot]z \
128                               \\*[bx*wt]
129 .  sp (\\n[bx*ind]u-1v)u
130 .  if (\\n[bx*shad]=1) .nop \\M[]\c
131 .  if (\\n[bx*outl]=1) .nop \\m[]\c
132 .  ds bx*ind\\n[bx*stack] \\n[bx*ind]
133 .  rr bx*shad bx*outl bx*ind bx*bot bx*top bx*l bx*r
134 .  rm wt type
135 .  sp -(\\n[bx*gap]u)
136 .  nr bx*PD 0
137 ..
138 .de BOXSTOP
139 .  sp \\*[bx*ind\\n[bx*stack]]u-\\n[.psr]u
140 .  pdfbackground off
141 .  nr bx*stack \\n[bx*stack]-1u
142 ..
143 .\" Local Variables:
144 .\" mode: nroff
145 .\" fill-column: 72
146 .\" End:
147 .\" vim: set expandtab filetype=groff textwidth=72: