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