Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / groff / src / preproc / eqn / mark.cpp
blob51b669a44c4b58ca27c989cb62f07657291d5152
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23 #include "eqn.h"
24 #include "pbox.h"
26 class mark_box : public pointer_box {
27 public:
28 mark_box(box *);
29 int compute_metrics(int);
30 void output();
31 void debug_print();
34 // we push down marks so that they don't interfere with spacing
36 box *make_mark_box(box *p)
38 list_box *b = p->to_list_box();
39 if (b != 0) {
40 b->list.p[0] = make_mark_box(b->list.p[0]);
41 return b;
43 else
44 return new mark_box(p);
47 mark_box::mark_box(box *pp) : pointer_box(pp)
51 void mark_box::output()
53 p->output();
56 int mark_box::compute_metrics(int style)
58 int res = p->compute_metrics(style);
59 if (res)
60 error("multiple marks and lineups");
61 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
62 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
63 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
64 printf(".nr " MARK_REG " 0\n");
65 return FOUND_MARK;
68 void mark_box::debug_print()
70 fprintf(stderr, "mark { ");
71 p->debug_print();
72 fprintf(stderr, " }");
76 class lineup_box : public pointer_box {
77 public:
78 lineup_box(box *);
79 void output();
80 int compute_metrics(int style);
81 void debug_print();
84 // we push down lineups so that they don't interfere with spacing
86 box *make_lineup_box(box *p)
88 list_box *b = p->to_list_box();
89 if (b != 0) {
90 b->list.p[0] = make_lineup_box(b->list.p[0]);
91 return b;
93 else
94 return new lineup_box(p);
97 lineup_box::lineup_box(box *pp) : pointer_box(pp)
101 void lineup_box::output()
103 p->output();
106 int lineup_box::compute_metrics(int style)
108 int res = p->compute_metrics(style);
109 if (res)
110 error("multiple marks and lineups");
111 printf(".nr " WIDTH_FORMAT " 0\\n[" WIDTH_FORMAT "]\n", uid, p->uid);
112 printf(".nr " HEIGHT_FORMAT " \\n[" HEIGHT_FORMAT "]\n", uid, p->uid);
113 printf(".nr " DEPTH_FORMAT " \\n[" DEPTH_FORMAT "]\n", uid, p->uid);
114 printf(".nr " MARK_REG " 0\n");
115 return FOUND_LINEUP;
118 void lineup_box::debug_print()
120 fprintf(stderr, "lineup { ");
121 p->debug_print();
122 fprintf(stderr, " }");