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

Annotation of mandoc/term.h, Revision 1.27

1.27    ! kristaps    1: /* $Id: term.h,v 1.26 2009/03/17 13:35:46 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.27    ! kristaps   24: /* FIXME - clean up tabs. */
1.25      kristaps   25:
1.13      kristaps   26: #define        INDENT            6
                     27:
1.1       kristaps   28: __BEGIN_DECLS
                     29:
                     30: struct termp {
1.27    ! kristaps   31:        size_t            rmargin;      /* Current right margin. */
        !            32:        size_t            maxrmargin;   /* Max right margin. */
        !            33:        size_t            maxcols;      /* Max size of buf. */
        !            34:        size_t            offset;       /* Margin offest. */
        !            35:        size_t            col;          /* Bytes in buf. */
1.1       kristaps   36:        int               flags;
1.22      kristaps   37: #define        TERMP_NOSPACE    (1 << 0)       /* No space before words. */
                     38: #define        TERMP_NOLPAD     (1 << 1)       /* No leftpad before flush. */
                     39: #define        TERMP_NOBREAK    (1 << 2)       /* No break after flush. */
                     40: #define        TERMP_LITERAL    (1 << 3)       /* Literal words. */
                     41: #define        TERMP_IGNDELIM   (1 << 4)       /* Delims like regulars. */
                     42: #define        TERMP_NONOSPACE  (1 << 5)       /* No space (no autounset). */
                     43: #define        TERMP_NONOBREAK  (1 << 7)       /* Don't newln NOBREAK. */
1.27    ! kristaps   44: #define        TERMP_STYLE       0x0300        /* Style mask. */
1.22      kristaps   45: #define        TERMP_BOLD       (1 << 8)       /* Styles... */
                     46: #define        TERMP_UNDER      (1 << 9)
1.27    ! kristaps   47:        char             *buf;          /* Output buffer. */
        !            48:        void             *symtab;       /* Encoded-symbol table. */
1.1       kristaps   49: };
                     50:
1.25      kristaps   51: /* XXX - clean this up. */
                     52:
1.6       kristaps   53: struct termpair {
1.9       kristaps   54:        struct termpair  *ppair;
1.6       kristaps   55:        int               type;
                     56: #define        TERMPAIR_FLAG    (1 << 0)
1.7       kristaps   57:        int               flag;
                     58:        size_t            offset;
1.8       kristaps   59:        size_t            rmargin;
1.9       kristaps   60:        int               count;
1.6       kristaps   61: };
                     62:
1.12      kristaps   63: #define        TERMPAIR_SETFLAG(termp, p, fl) \
1.6       kristaps   64:        do { \
1.7       kristaps   65:                assert(! (TERMPAIR_FLAG & (p)->type)); \
1.12      kristaps   66:                (termp)->flags |= (fl); \
1.7       kristaps   67:                (p)->flag = (fl); \
                     68:                (p)->type |= TERMPAIR_FLAG; \
1.6       kristaps   69:        } while (0)
                     70:
1.1       kristaps   71: struct termact {
1.25      kristaps   72:        int     (*pre)(struct termp *, struct termpair *,
                     73:                        const struct mdoc_meta *,
                     74:                        const struct mdoc_node *);
                     75:        void    (*post)(struct termp *, struct termpair *,
                     76:                        const struct mdoc_meta *,
                     77:                        const struct mdoc_node *);
1.1       kristaps   78: };
                     79:
1.25      kristaps   80: void            *ascii2htab(void);
                     81: const char      *a2ascii(void *, const char *, size_t, size_t *);
1.26      kristaps   82: void             asciifree(void *);
1.5       kristaps   83:
1.25      kristaps   84: void             newln(struct termp *);
                     85: void             vspace(struct termp *);
                     86: void             word(struct termp *, const char *);
                     87: void             flushln(struct termp *);
                     88: void             transcode(struct termp *, const char *, size_t);
                     89: void             subtree(struct termp *, const struct mdoc_meta *,
                     90:                        const struct mdoc_node *);
1.14      kristaps   91:
1.1       kristaps   92: const  struct termact   *termacts;
                     93:
                     94: __END_DECLS
                     95:
                     96: #endif /*!TERM_H*/

CVSweb