xref: /titanic_50/usr/src/cmd/mandoc/out.h (revision 75614fd9696d97522ed7ed8009a66eb3544d61ad)
1 /*	$Id: out.h,v 1.26 2014/12/01 08:05:52 schwarze Exp $ */
2 /*
3  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 enum	roffscale {
19 	SCALE_CM, /* centimeters (c) */
20 	SCALE_IN, /* inches (i) */
21 	SCALE_PC, /* pica (P) */
22 	SCALE_PT, /* points (p) */
23 	SCALE_EM, /* ems (m) */
24 	SCALE_MM, /* mini-ems (M) */
25 	SCALE_EN, /* ens (n) */
26 	SCALE_BU, /* default horizontal (u) */
27 	SCALE_VS, /* default vertical (v) */
28 	SCALE_FS, /* syn. for u (f) */
29 	SCALE_MAX
30 };
31 
32 struct	roffcol {
33 	size_t		 width; /* width of cell */
34 	size_t		 decimal; /* decimal position in cell */
35 	int		 flags; /* layout flags, see tbl_cell */
36 };
37 
38 struct	roffsu {
39 	enum roffscale	  unit;
40 	double		  scale;
41 };
42 
43 typedef	size_t	(*tbl_strlen)(const char *, void *);
44 typedef	size_t	(*tbl_len)(size_t, void *);
45 
46 struct	rofftbl {
47 	tbl_strlen	 slen; /* calculate string length */
48 	tbl_len		 len; /* produce width of empty space */
49 	struct roffcol	*cols; /* master column specifiers */
50 	void		*arg; /* passed to slen and len */
51 };
52 
53 #define	SCALE_VS_INIT(p, v) \
54 	do { (p)->unit = SCALE_VS; \
55 	     (p)->scale = (v); } \
56 	while (/* CONSTCOND */ 0)
57 
58 #define	SCALE_HS_INIT(p, v) \
59 	do { (p)->unit = SCALE_EN; \
60 	     (p)->scale = (v); } \
61 	while (/* CONSTCOND */ 0)
62 
63 __BEGIN_DECLS
64 
65 struct	tbl_span;
66 
67 int		  a2roffsu(const char *, struct roffsu *, enum roffscale);
68 void		  tblcalc(struct rofftbl *tbl,
69 			const struct tbl_span *, size_t);
70 
71 __END_DECLS
72