Adapt src/pre-eqn (src/preproc/eqn)
[s-roff.git] / src / pre-eqn / mark.cpp
blob94168a0e6bc0350e3bf5cfdcb5919a53825e64ce
1 /*@
2 * Copyright (c) 2014 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
4 * Copyright (C) 1989 - 1992 Free Software Foundation, Inc.
5 * Written by James Clark (jjc@jclark.com)
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
10 * 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
15 * for more details.
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, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "config.h"
23 #include "eqn-config.h"
25 #include "eqn.h"
26 #include "pbox.h"
28 class mark_box
29 : public pointer_box
31 public:
32 mark_box(box *);
33 int compute_metrics(int);
34 void output();
35 void debug_print();
38 // we push down marks so that they don't interfere with spacing
40 box *make_mark_box(box *p)
42 list_box *b = p->to_list_box();
43 if (b != 0) {
44 b->list.p[0] = make_mark_box(b->list.p[0]);
45 return b;
47 else
48 return new mark_box(p);
51 mark_box::mark_box(box *pp) : pointer_box(pp)
55 void mark_box::output()
57 p->output();
60 int mark_box::compute_metrics(int style)
62 int res = p->compute_metrics(style);
63 if (res)
64 error("multiple marks and lineups");
65 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
66 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
67 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
68 printf(".nr " MARK_REG " 0\n");
69 return FOUND_MARK;
72 void mark_box::debug_print()
74 fprintf(stderr, "mark { ");
75 p->debug_print();
76 fprintf(stderr, " }");
79 class lineup_box
80 : public pointer_box
82 public:
83 lineup_box(box *);
84 void output();
85 int compute_metrics(int style);
86 void debug_print();
89 // we push down lineups so that they don't interfere with spacing
91 box *make_lineup_box(box *p)
93 list_box *b = p->to_list_box();
94 if (b != 0) {
95 b->list.p[0] = make_lineup_box(b->list.p[0]);
96 return b;
98 else
99 return new lineup_box(p);
102 lineup_box::lineup_box(box *pp) : pointer_box(pp)
106 void lineup_box::output()
108 p->output();
111 int lineup_box::compute_metrics(int style)
113 int res = p->compute_metrics(style);
114 if (res)
115 error("multiple marks and lineups");
116 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
117 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
118 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
119 printf(".nr " MARK_REG " 0\n");
120 return FOUND_LINEUP;
123 void lineup_box::debug_print()
125 fprintf(stderr, "lineup { ");
126 p->debug_print();
127 fprintf(stderr, " }");
130 // s-it2-mode