xref: /netbsd-src/external/gpl2/groff/dist/src/preproc/eqn/mark.cpp (revision 89a07cf815a29524268025a1139fac4c5190f765)
1 /*	$NetBSD: mark.cpp,v 1.1.1.1 2016/01/13 18:41:49 christos Exp $	*/
2 
3 // -*- C++ -*-
4 /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
5      Written by James Clark (jjc@jclark.com)
6 
7 This file is part of groff.
8 
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.
13 
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.
18 
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. */
22 
23 #include "eqn.h"
24 #include "pbox.h"
25 
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();
32 };
33 
34 // we push down marks so that they don't interfere with spacing
35 
make_mark_box(box * p)36 box *make_mark_box(box *p)
37 {
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;
42   }
43   else
44     return new mark_box(p);
45 }
46 
mark_box(box * pp)47 mark_box::mark_box(box *pp) : pointer_box(pp)
48 {
49 }
50 
output()51 void mark_box::output()
52 {
53   p->output();
54 }
55 
compute_metrics(int style)56 int mark_box::compute_metrics(int style)
57 {
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;
66 }
67 
debug_print()68 void mark_box::debug_print()
69 {
70   fprintf(stderr, "mark { ");
71   p->debug_print();
72   fprintf(stderr, " }");
73 }
74 
75 
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();
82 };
83 
84 // we push down lineups so that they don't interfere with spacing
85 
make_lineup_box(box * p)86 box *make_lineup_box(box *p)
87 {
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;
92   }
93   else
94     return new lineup_box(p);
95 }
96 
lineup_box(box * pp)97 lineup_box::lineup_box(box *pp) : pointer_box(pp)
98 {
99 }
100 
output()101 void lineup_box::output()
102 {
103   p->output();
104 }
105 
compute_metrics(int style)106 int lineup_box::compute_metrics(int style)
107 {
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;
116 }
117 
debug_print()118 void lineup_box::debug_print()
119 {
120   fprintf(stderr, "lineup { ");
121   p->debug_print();
122   fprintf(stderr, " }");
123 }
124