[BACK]Return to term.h CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/term.h, Revision 1.25

1.25    ! kristaps    1: /* $Id: term.h,v 1.24 2009/03/15 10:34:11 kristaps Exp $ */
1.1       kristaps    2: /*
                      3:  * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
                      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
                      7:  * above copyright notice and this permission notice appear in all
                      8:  * copies.
                      9:  *
                     10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
                     11:  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
                     12:  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
                     13:  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
                     14:  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
                     15:  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
                     16:  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
                     17:  * PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19: #ifndef TERM_H
                     20: #define TERM_H
                     21:
                     22: #include "mdoc.h"
                     23:
1.25    ! kristaps   24: /* XXX - clean up tabs. */
        !            25:
1.13      kristaps   26: #define        INDENT            6
                     27:
1.1       kristaps   28: __BEGIN_DECLS
                     29:
                     30: struct termp {
                     31:        size_t            rmargin;
                     32:        size_t            maxrmargin;
                     33:        size_t            maxcols;
                     34:        size_t            offset;
                     35:        size_t            col;
1.23      kristaps   36:        int               iflags;
                     37: #define        TERMP_NOPUNT     (1 << 0)
1.1       kristaps   38:        int               flags;
1.22      kristaps   39: #define        TERMP_NOSPACE    (1 << 0)       /* No space before words. */
                     40: #define        TERMP_NOLPAD     (1 << 1)       /* No leftpad before flush. */
                     41: #define        TERMP_NOBREAK    (1 << 2)       /* No break after flush. */
                     42: #define        TERMP_LITERAL    (1 << 3)       /* Literal words. */
                     43: #define        TERMP_IGNDELIM   (1 << 4)       /* Delims like regulars. */
                     44: #define        TERMP_NONOSPACE  (1 << 5)       /* No space (no autounset). */
                     45: #define        TERMP_NONOBREAK  (1 << 7)       /* Don't newln NOBREAK. */
1.24      kristaps   46: #define        TERMP_STYLE      0x0300         /* Style mask. */
1.22      kristaps   47: #define        TERMP_BOLD       (1 << 8)       /* Styles... */
                     48: #define        TERMP_UNDER      (1 << 9)
1.1       kristaps   49:        char             *buf;
1.25    ! kristaps   50:        void             *symtab;
1.1       kristaps   51: };
                     52:
1.25    ! kristaps   53: /* XXX - clean this up. */
        !            54:
1.6       kristaps   55: struct termpair {
1.9       kristaps   56:        struct termpair  *ppair;
1.6       kristaps   57:        int               type;
                     58: #define        TERMPAIR_FLAG    (1 << 0)
1.7       kristaps   59:        int               flag;
                     60:        size_t            offset;
1.8       kristaps   61:        size_t            rmargin;
1.9       kristaps   62:        int               count;
1.6       kristaps   63: };
                     64:
1.12      kristaps   65: #define        TERMPAIR_SETFLAG(termp, p, fl) \
1.6       kristaps   66:        do { \
1.7       kristaps   67:                assert(! (TERMPAIR_FLAG & (p)->type)); \
1.12      kristaps   68:                (termp)->flags |= (fl); \
1.7       kristaps   69:                (p)->flag = (fl); \
                     70:                (p)->type |= TERMPAIR_FLAG; \
1.6       kristaps   71:        } while (0)
                     72:
1.1       kristaps   73: struct termact {
1.25    ! kristaps   74:        int     (*pre)(struct termp *, struct termpair *,
        !            75:                        const struct mdoc_meta *,
        !            76:                        const struct mdoc_node *);
        !            77:        void    (*post)(struct termp *, struct termpair *,
        !            78:                        const struct mdoc_meta *,
        !            79:                        const struct mdoc_node *);
1.1       kristaps   80: };
                     81:
1.25    ! kristaps   82: void            *ascii2htab(void);
        !            83: const char      *a2ascii(void *, const char *, size_t, size_t *);
1.5       kristaps   84:
1.25    ! kristaps   85: void             newln(struct termp *);
        !            86: void             vspace(struct termp *);
        !            87: void             word(struct termp *, const char *);
        !            88: void             flushln(struct termp *);
        !            89: void             transcode(struct termp *, const char *, size_t);
        !            90: void             subtree(struct termp *, const struct mdoc_meta *,
        !            91:                        const struct mdoc_node *);
1.14      kristaps   92:
1.1       kristaps   93: const  struct termact   *termacts;
                     94:
                     95: __END_DECLS
                     96:
                     97: #endif /*!TERM_H*/

CVSweb