2 * Copyright (c) 2014 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992, 2002, 2007
5 * Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * groff is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
13 * groff is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
24 #include "eqn-config.h"
37 limit_box(box
*, box
*, box
*);
39 int compute_metrics(int);
45 box
*make_limit_box(box
*pp
, box
*qq
, box
*rr
)
47 return new limit_box(pp
, qq
, rr
);
50 limit_box::limit_box(box
*pp
, box
*qq
, box
*rr
)
51 : p(pp
), from(qq
), to(rr
)
53 spacing_type
= p
->spacing_type
;
56 limit_box::~limit_box()
63 int limit_box::compute_metrics(int style
)
65 printf(".nr " SIZE_FORMAT
" \\n[.ps]\n", uid
);
66 if (!(style
<= SCRIPT_STYLE
&& one_size_reduction_flag
))
68 printf(".nr " SMALL_SIZE_FORMAT
" \\n[.ps]\n", uid
);
72 res
= from
->compute_metrics(cramped_style(script_style(style
)));
77 int r
= to
->compute_metrics(script_style(style
));
79 error("multiple marks and lineups");
85 printf(".ps \\n[" SIZE_FORMAT
"]u\n", uid
);
86 int r
= p
->compute_metrics(style
);
87 p
->compute_subscript_kern();
89 error("multiple marks and lineups");
94 printf(".nr " LEFT_WIDTH_FORMAT
" "
95 "0\\n[" WIDTH_FORMAT
"]",
98 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
101 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
104 printf(".nr " WIDTH_FORMAT
" "
105 "0\\n[" WIDTH_FORMAT
"]",
108 printf(">?(-\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
111 printf(">?(\\n[" SUB_KERN_FORMAT
"]+\\n[" WIDTH_FORMAT
"])",
113 printf("/2+\\n[" LEFT_WIDTH_FORMAT
"]\n", uid
);
114 printf(".nr " WIDTH_FORMAT
" 0\\n[" WIDTH_FORMAT
"]", uid
, p
->uid
);
116 printf(">?\\n[" WIDTH_FORMAT
"]", to
->uid
);
118 printf(">?\\n[" WIDTH_FORMAT
"]", from
->uid
);
121 printf(".nr " MARK_REG
" +(\\n[" LEFT_WIDTH_FORMAT
"]"
122 "-(\\n[" WIDTH_FORMAT
"]/2))\n",
125 printf(".nr " SUP_RAISE_FORMAT
" %dM+\\n[" DEPTH_FORMAT
126 "]>?%dM+\\n[" HEIGHT_FORMAT
"]\n",
127 uid
, big_op_spacing1
, to
->uid
, big_op_spacing3
, p
->uid
);
128 printf(".nr " HEIGHT_FORMAT
" \\n[" SUP_RAISE_FORMAT
"]+\\n["
129 HEIGHT_FORMAT
"]+%dM\n",
130 uid
, uid
, to
->uid
, big_op_spacing5
);
133 printf(".nr " HEIGHT_FORMAT
" \\n[" HEIGHT_FORMAT
"]\n", uid
, p
->uid
);
135 printf(".nr " SUB_LOWER_FORMAT
" %dM+\\n[" HEIGHT_FORMAT
136 "]>?%dM+\\n[" DEPTH_FORMAT
"]\n",
137 uid
, big_op_spacing2
, from
->uid
, big_op_spacing4
, p
->uid
);
138 printf(".nr " DEPTH_FORMAT
" \\n[" SUB_LOWER_FORMAT
"]+\\n["
139 DEPTH_FORMAT
"]+%dM\n",
140 uid
, uid
, from
->uid
, big_op_spacing5
);
143 printf(".nr " DEPTH_FORMAT
" \\n[" DEPTH_FORMAT
"]\n", uid
, p
->uid
);
147 void limit_box::output()
149 if (output_format
== troff
) {
150 printf("\\s[\\n[" SMALL_SIZE_FORMAT
"]u]", uid
);
152 printf("\\Z" DELIMITER_CHAR
);
153 printf("\\v'-\\n[" SUP_RAISE_FORMAT
"]u'", uid
);
154 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
155 "+(-\\n[" WIDTH_FORMAT
"]u+\\n[" SUB_KERN_FORMAT
"]u/2u)'",
156 uid
, to
->uid
, p
->uid
);
158 printf(DELIMITER_CHAR
);
161 printf("\\Z" DELIMITER_CHAR
);
162 printf("\\v'\\n[" SUB_LOWER_FORMAT
"]u'", uid
);
163 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
164 "+(-\\n[" SUB_KERN_FORMAT
"]u-\\n[" WIDTH_FORMAT
"]u/2u)'",
165 uid
, p
->uid
, from
->uid
);
167 printf(DELIMITER_CHAR
);
169 printf("\\s[\\n[" SIZE_FORMAT
"]u]", uid
);
170 printf("\\Z" DELIMITER_CHAR
);
171 printf("\\h'\\n[" LEFT_WIDTH_FORMAT
"]u"
172 "-(\\n[" WIDTH_FORMAT
"]u/2u)'",
175 printf(DELIMITER_CHAR
);
176 printf("\\h'\\n[" WIDTH_FORMAT
"]u'", uid
);
178 else if (output_format
== mathml
) {
179 if (from
!= 0 && to
!= 0) {
180 printf("<munderover>");
184 printf("</munderover>");
186 else if (from
!= 0) {
201 void limit_box::debug_print()
203 fprintf(stderr
, "{ ");
205 fprintf(stderr
, " }");
207 fprintf(stderr
, " from { ");
209 fprintf(stderr
, " }");
212 fprintf(stderr
, " to { ");
214 fprintf(stderr
, " }");
218 void limit_box::check_tabs(int level
)
221 to
->check_tabs(level
+ 1);
223 from
->check_tabs(level
+ 1);
224 p
->check_tabs(level
+ 1);