2 /* Copyright (C) 1989-2018 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 3 of the License, or
10 (at your option) any later version.
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
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 class limit_box : public box {
29 limit_box(box *, box *, box *);
31 int compute_metrics(int);
37 box *make_limit_box(box *pp, box *qq, box *rr)
39 return new limit_box(pp, qq, rr);
42 limit_box::limit_box(box *pp, box *qq, box *rr)
43 : p(pp), from(qq), to(rr)
45 spacing_type = p->spacing_type;
48 limit_box::~limit_box()
55 int limit_box::compute_metrics(int style)
57 printf(".nr " SIZE_FORMAT " \\n[.ps]\n", uid);
58 if (!(style <= SCRIPT_STYLE && one_size_reduction_flag))
60 printf(".nr " SMALL_SIZE_FORMAT " \\n[.ps]\n", uid);
64 res = from->compute_metrics(cramped_style(script_style(style)));
69 int r = to->compute_metrics(script_style(style));
71 error("multiple marks and lineups");
77 printf(".ps \\n[" SIZE_FORMAT "]u\n", uid);
78 int r = p->compute_metrics(style);
79 p->compute_subscript_kern();
81 error("multiple marks and lineups");
86 printf(".nr " LEFT_WIDTH_FORMAT " "
87 "0\\n[" WIDTH_FORMAT "]",
90 printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
93 printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
96 printf(".nr " WIDTH_FORMAT " "
97 "0\\n[" WIDTH_FORMAT "]",
100 printf(">?(-\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
103 printf(">?(\\n[" SUB_KERN_FORMAT "]+\\n[" WIDTH_FORMAT "])",
105 printf("/2+\\n[" LEFT_WIDTH_FORMAT "]\n", uid);
106 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]", uid, p->uid);
108 printf(">?\\n[" WIDTH_FORMAT "]", to->uid);
110 printf(">?\\n[" WIDTH_FORMAT "]", from->uid);
113 printf(".nr " MARK_REG " +(\\n[" LEFT_WIDTH_FORMAT "]"
114 "-(\\n[" WIDTH_FORMAT "]/2))\n",
117 printf(".nr " SUP_RAISE_FORMAT " %dM+\\n[" DEPTH_FORMAT
118 "]>?%dM+\\n[" HEIGHT_FORMAT "]\n",
119 uid, big_op_spacing1, to->uid, big_op_spacing3, p->uid);
120 printf(".nr " HEIGHT_FORMAT " \\n[" SUP_RAISE_FORMAT "]+\\n["
121 HEIGHT_FORMAT "]+%dM\n",
122 uid, uid, to->uid, big_op_spacing5);
125 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
127 printf(".nr " SUB_LOWER_FORMAT " %dM+\\n[" HEIGHT_FORMAT
128 "]>?%dM+\\n[" DEPTH_FORMAT "]\n",
129 uid, big_op_spacing2, from->uid, big_op_spacing4, p->uid);
130 printf(".nr " DEPTH_FORMAT " \\n[" SUB_LOWER_FORMAT "]+\\n["
131 DEPTH_FORMAT "]+%dM\n",
132 uid, uid, from->uid, big_op_spacing5);
135 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
139 void limit_box::output()
141 if (output_format == troff) {
142 printf("\\s[\\n[" SMALL_SIZE_FORMAT "]u]", 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 "]u]", 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);
170 else if (output_format == mathml) {
171 if (from != 0 && to != 0) {
172 printf("<munderover>");
176 printf("</munderover>");
178 else if (from != 0) {
193 void limit_box::debug_print()
195 fprintf(stderr, "{ ");
197 fprintf(stderr, " }");
199 fprintf(stderr, " from { ");
201 fprintf(stderr, " }");
204 fprintf(stderr, " to { ");
206 fprintf(stderr, " }");
210 void limit_box::check_tabs(int level)
213 to->check_tabs(level + 1);
215 from->check_tabs(level + 1);
216 p->check_tabs(level + 1);