No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / preproc / eqn / special.cpp
blob5b9a148bf1766f19927db8f98981c4be2e65758a
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 #define STRING_FORMAT PREFIX "str%d"
28 #define SPECIAL_STRING "0s"
29 #define SPECIAL_WIDTH_REG "0w"
30 #define SPECIAL_HEIGHT_REG "0h"
31 #define SPECIAL_DEPTH_REG "0d"
32 #define SPECIAL_SUB_KERN_REG "0skern"
33 #define SPECIAL_SKEW_REG "0skew"
36 For example:
38 .de Cl
39 .ds 0s \Z'\\*[0s]'\v'\\n(0du'\D'l \\n(0wu -\\n(0hu-\\n(0du'\v'\\n(0hu'
41 .EQ
42 define cancel 'special Cl'
43 .EN
47 class special_box : public pointer_box {
48 char *macro_name;
49 public:
50 special_box(char *, box *);
51 ~special_box();
52 int compute_metrics(int);
53 void compute_subscript_kern();
54 void compute_skew();
55 void output();
56 void debug_print();
59 box *make_special_box(char *s, box *p)
61 return new special_box(s, p);
64 special_box::special_box(char *s, box *pp) : pointer_box(pp), macro_name(s)
68 special_box::~special_box()
70 a_delete macro_name;
73 int special_box::compute_metrics(int style)
75 int r = p->compute_metrics(style);
76 p->compute_subscript_kern();
77 p->compute_skew();
78 printf(".ds " SPECIAL_STRING " \"");
79 p->output();
80 printf("\n");
81 printf(".nr " SPECIAL_WIDTH_REG " 0\\n[" WIDTH_FORMAT "]\n", p->uid);
82 printf(".nr " SPECIAL_HEIGHT_REG " \\n[" HEIGHT_FORMAT "]\n", p->uid);
83 printf(".nr " SPECIAL_DEPTH_REG " \\n[" DEPTH_FORMAT "]\n", p->uid);
84 printf(".nr " SPECIAL_SUB_KERN_REG " \\n[" SUB_KERN_FORMAT "]\n", p->uid);
85 printf(".nr " SPECIAL_SKEW_REG " 0\\n[" SKEW_FORMAT "]\n", p->uid);
86 printf(".%s\n", macro_name);
87 printf(".rn " SPECIAL_STRING " " STRING_FORMAT "\n", uid);
88 printf(".nr " WIDTH_FORMAT " 0\\n[" SPECIAL_WIDTH_REG "]\n", uid);
89 printf(".nr " HEIGHT_FORMAT " 0>?\\n[" SPECIAL_HEIGHT_REG "]\n", uid);
90 printf(".nr " DEPTH_FORMAT " 0>?\\n[" SPECIAL_DEPTH_REG "]\n", uid);
91 printf(".nr " SUB_KERN_FORMAT " 0>?\\n[" SPECIAL_SUB_KERN_REG "]\n", uid);
92 printf(".nr " SKEW_FORMAT " 0\\n[" SPECIAL_SKEW_REG "]\n", uid);
93 // User will have to change MARK_REG if appropriate.
94 return r;
97 void special_box::compute_subscript_kern()
99 // Already computed in compute_metrics(), so do nothing.
102 void special_box::compute_skew()
104 // Already computed in compute_metrics(), so do nothing.
107 void special_box::output()
109 printf("\\*[" STRING_FORMAT "]", uid);
112 void special_box::debug_print()
114 fprintf(stderr, "special %s { ", macro_name);
115 p->debug_print();
116 fprintf(stderr, " }");