2 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3 Written by James Clark (jjc@jclark.com)
5 This file is part of groff.
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License along
18 with groff; see the file COPYING. If not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24 class limit_box
: public box
{
30 limit_box(box
*, box
*, box
*);
32 int compute_metrics(int);
38 box
*make_limit_box(box
*pp
, box
*qq
, box
*rr
)
40 return new limit_box(pp
, qq
, rr
);
43 limit_box::limit_box(box
*pp
, box
*qq
, box
*rr
)
44 : p(pp
), from(qq
), to(rr
)
46 spacing_type
= p
->spacing_type
;
49 limit_box::~limit_box()
56 int limit_box::compute_metrics(int style
)
58 printf(".nr " SIZE_FORMAT
" \\n[.s]\n", uid
);
59 if (!(style
<= SCRIPT_STYLE
&& one_size_reduction_flag
))
61 printf(".nr " SMALL_SIZE_FORMAT
" \\n[.s]\n", uid
);
65 res
= from
->compute_metrics(cramped_style(script_style(style
)));
70 int r
= to
->compute_metrics(script_style(style
));
72 error("multiple marks and lineups");
78 printf(".ps \\n[" SIZE_FORMAT
"]\n", uid
);
79 int r
= p
->compute_metrics(style
);
80 p
->compute_subscript_kern();
82 error("multiple marks and lineups");
87 printf(".nr " LEFT_WIDTH_FORMAT
" "
88 "0\\n[" WIDTH_FORMAT
"]",
91 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
94 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
97 printf(".nr " WIDTH_FORMAT
" "
98 "0\\n[" WIDTH_FORMAT
"]",
101 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
104 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
106 printf("/2+\\n[" LEFT_WIDTH_FORMAT
"]\n", uid
);
107 printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]", uid
, p
->uid
);
109 printf(">?\\n[" WIDTH_FORMAT
"]", to
->uid
);
111 printf(">?\\n[" WIDTH_FORMAT
"]", from
->uid
);
114 printf(".nr " MARK_REG
" +(\\n[" LEFT_WIDTH_FORMAT
"]"
115 "-(\\n[" WIDTH_FORMAT
"]/2))\n",
118 printf(".nr " SUP_RAISE_FORMAT
" %dM+\\n[" DEPTH_FORMAT
119 "]>?%dM+\\n[" HEIGHT_FORMAT
"]\n",
120 uid
, big_op_spacing1
, to
->uid
, big_op_spacing3
, p
->uid
);
121 printf(".nr " HEIGHT_FORMAT
" \\n[" SUP_RAISE_FORMAT
"]+\\n["
122 HEIGHT_FORMAT
"]+%dM\n",
123 uid
, uid
, to
->uid
, big_op_spacing5
);
126 printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
128 printf(".nr " SUB_LOWER_FORMAT
" %dM+\\n[" HEIGHT_FORMAT
129 "]>?%dM+\\n[" DEPTH_FORMAT
"]\n",
130 uid
, big_op_spacing2
, from
->uid
, big_op_spacing4
, p
->uid
);
131 printf(".nr " DEPTH_FORMAT
" \\n[" SUB_LOWER_FORMAT
"]+\\n["
132 DEPTH_FORMAT
"]+%dM\n",
133 uid
, uid
, from
->uid
, big_op_spacing5
);
136 printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
140 void limit_box::output()
142 printf("\\s[\\n[" SMALL_SIZE_FORMAT
"]]", uid
);
144 printf("\\Z" DELIMITER_CHAR
);
145 printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
146 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
147 "+(-\\n[" WIDTH_FORMAT
"]u+\\n[" SUB_KERN_FORMAT
"]u/2u)'",
148 uid
, to
->uid
, p
->uid
);
150 printf(DELIMITER_CHAR
);
153 printf("\\Z" DELIMITER_CHAR
);
154 printf("\\v'\\n[" SUB_LOWER_FORMAT
"]u'", uid
);
155 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
156 "+(-\\n[" SUB_KERN_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u)'",
157 uid
, p
->uid
, from
->uid
);
159 printf(DELIMITER_CHAR
);
161 printf("\\s[\\n[" SIZE_FORMAT
"]]", uid
);
162 printf("\\Z" DELIMITER_CHAR
);
163 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
164 "-(\\n[" WIDTH_FORMAT
"]u/2u)'",
167 printf(DELIMITER_CHAR
);
168 printf("\\h'\\n[" WIDTH_FORMAT
"]u'", uid
);
171 void limit_box::debug_print()
173 fprintf(stderr
, "{ ");
175 fprintf(stderr
, " }");
177 fprintf(stderr
, " from { ");
179 fprintf(stderr
, " }");
182 fprintf(stderr
, " to { ");
184 fprintf(stderr
, " }");
188 void limit_box::check_tabs(int level
)
191 to
->check_tabs(level
+ 1);
193 from
->check_tabs(level
+ 1);
194 p
->check_tabs(level
+ 1);