[BACK]Return to out.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/out.h, Revision 1.25

1.25    ! schwarze    1: /* $OpenBSD: out.h,v 1.24 2018/08/18 20:17:58 schwarze Exp $ */
1.1       schwarze    2: /*
1.7       schwarze    3:  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.24      schwarze    4:  * Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
1.1       schwarze    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.
1.25    ! schwarze   17:  *
        !            18:  * Utilities for use by multiple mandoc(1) formatters.
1.1       schwarze   19:  */
1.17      schwarze   20:
1.1       schwarze   21: enum   roffscale {
1.10      schwarze   22:        SCALE_CM, /* centimeters (c) */
                     23:        SCALE_IN, /* inches (i) */
                     24:        SCALE_PC, /* pica (P) */
                     25:        SCALE_PT, /* points (p) */
                     26:        SCALE_EM, /* ems (m) */
                     27:        SCALE_MM, /* mini-ems (M) */
                     28:        SCALE_EN, /* ens (n) */
                     29:        SCALE_BU, /* default horizontal (u) */
                     30:        SCALE_VS, /* default vertical (v) */
                     31:        SCALE_FS, /* syn. for u (f) */
1.1       schwarze   32:        SCALE_MAX
                     33: };
                     34:
1.10      schwarze   35: struct roffcol {
                     36:        size_t           width; /* width of cell */
1.24      schwarze   37:        size_t           nwidth; /* max. width of number in cell */
1.10      schwarze   38:        size_t           decimal; /* decimal position in cell */
1.22      schwarze   39:        size_t           spacing; /* spacing after the column */
1.15      schwarze   40:        int              flags; /* layout flags, see tbl_cell */
1.10      schwarze   41: };
                     42:
1.1       schwarze   43: struct roffsu {
                     44:        enum roffscale    unit;
                     45:        double            scale;
                     46: };
                     47:
1.20      schwarze   48: typedef        size_t  (*tbl_sulen)(const struct roffsu *, void *);
1.10      schwarze   49: typedef        size_t  (*tbl_strlen)(const char *, void *);
                     50: typedef        size_t  (*tbl_len)(size_t, void *);
                     51:
                     52: struct rofftbl {
1.20      schwarze   53:        tbl_sulen        sulen; /* calculate scaling unit length */
1.10      schwarze   54:        tbl_strlen       slen; /* calculate string length */
                     55:        tbl_len          len; /* produce width of empty space */
                     56:        struct roffcol  *cols; /* master column specifiers */
1.20      schwarze   57:        void            *arg; /* passed to sulen, slen, and len */
1.10      schwarze   58: };
1.3       schwarze   59:
1.1       schwarze   60: #define        SCALE_HS_INIT(p, v) \
1.14      schwarze   61:        do { (p)->unit = SCALE_EN; \
1.5       schwarze   62:             (p)->scale = (v); } \
1.3       schwarze   63:        while (/* CONSTCOND */ 0)
1.17      schwarze   64:
                     65:
                     66: struct tbl_span;
1.1       schwarze   67:
1.19      schwarze   68: const char      *a2roffsu(const char *, struct roffsu *, enum roffscale);
1.25    ! schwarze   69: void             tblcalc(struct rofftbl *,
1.21      schwarze   70:                        const struct tbl_span *, size_t, size_t);