]> git.cameronkatri.com Git - mandoc.git/blob - term.h
Removed "regression" for OpenBSD (broken).
[mandoc.git] / term.h
1 /* $Id: term.h,v 1.20 2009/03/11 00:39:58 kristaps Exp $ */
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
24 #define INDENT 6
25
26 __BEGIN_DECLS
27
28 enum tsym {
29 TERMSYM_RBRACK = 0,
30 TERMSYM_LBRACK = 1,
31 TERMSYM_LARROW = 2,
32 TERMSYM_RARROW = 3,
33 TERMSYM_UARROW = 4,
34 TERMSYM_DARROW = 5,
35 TERMSYM_LSQUOTE = 6,
36 TERMSYM_RSQUOTE = 7,
37 TERMSYM_SQUOTE = 8,
38 TERMSYM_LDQUOTE = 9,
39 TERMSYM_RDQUOTE = 10,
40 TERMSYM_DQUOTE = 11,
41 TERMSYM_LT = 12,
42 TERMSYM_GT = 13,
43 TERMSYM_LE = 14,
44 TERMSYM_GE = 15,
45 TERMSYM_EQ = 16,
46 TERMSYM_NEQ = 17,
47 TERMSYM_ACUTE = 18,
48 TERMSYM_GRAVE = 19,
49 TERMSYM_PI = 20,
50 TERMSYM_PLUSMINUS = 21,
51 TERMSYM_INF = 22,
52 TERMSYM_INF2 = 23,
53 TERMSYM_NAN = 24,
54 TERMSYM_BAR = 25,
55 TERMSYM_BULLET = 26,
56 TERMSYM_AMP = 27,
57 TERMSYM_EM = 28,
58 TERMSYM_EN = 29,
59 TERMSYM_COPY = 30,
60 TERMSYM_ASTERISK = 31,
61 TERMSYM_SLASH = 32,
62 TERMSYM_HYPHEN = 33,
63 TERMSYM_SPACE = 34,
64 TERMSYM_PERIOD = 35,
65 TERMSYM_BREAK = 36,
66 TERMSYM_LANGLE = 37,
67 TERMSYM_RANGLE = 38,
68 TERMSYM_LBRACE = 39,
69 TERMSYM_RBRACE = 40
70 };
71
72
73 enum tstyle {
74 TERMSTYLE_CLEAR = 0,
75 TERMSTYLE_BOLD = 1,
76 TERMSTYLE_UNDER = 2,
77 TERMSTYLE_MAX = 3
78 };
79
80 struct termsym {
81 const char *sym;
82 size_t sz;
83 };
84
85 struct termp {
86 size_t rmargin;
87 size_t maxrmargin;
88 size_t maxcols;
89 size_t offset;
90 size_t col;
91 int flags;
92 #define TERMP_BOLD (1 << 0) /* Embolden words. */
93 #define TERMP_UNDERLINE (1 << 1) /* Underline words. */
94 #define TERMP_NOSPACE (1 << 2) /* No space before words. */
95 #define TERMP_NOLPAD (1 << 3) /* No leftpad before flush. */
96 #define TERMP_NOBREAK (1 << 4) /* No break after flush. */
97 #define TERMP_LITERAL (1 << 5) /* Literal words. */
98 #define TERMP_IGNDELIM (1 << 6) /* Delims like regulars. */
99 #define TERMP_NONOSPACE (1 << 7) /* No space (no autounset). */
100 #define TERMP_NONOBREAK (1 << 8)
101 char *buf;
102 struct termsym *symtab; /* Special-symbol table. */
103 struct termsym *styletab; /* Style table. */
104 };
105
106 struct termpair {
107 struct termpair *ppair;
108 int type;
109 #define TERMPAIR_FLAG (1 << 0)
110 int flag;
111 size_t offset;
112 size_t rmargin;
113 int count;
114 };
115
116 #define TERMPAIR_SETFLAG(termp, p, fl) \
117 do { \
118 assert(! (TERMPAIR_FLAG & (p)->type)); \
119 (termp)->flags |= (fl); \
120 (p)->flag = (fl); \
121 (p)->type |= TERMPAIR_FLAG; \
122 } while (0)
123
124 struct termact {
125 int (*pre)(struct termp *,
126 struct termpair *,
127 const struct mdoc_meta *,
128 const struct mdoc_node *);
129 void (*post)(struct termp *,
130 struct termpair *,
131 const struct mdoc_meta *,
132 const struct mdoc_node *);
133 };
134
135 void newln(struct termp *);
136 void vspace(struct termp *);
137 void word(struct termp *, const char *);
138 void flushln(struct termp *);
139 void transcode(struct termp *,
140 const char *, size_t);
141 void subtree(struct termp *,
142 const struct mdoc_meta *,
143 const struct mdoc_node *);
144
145
146 const struct termact *termacts;
147
148 __END_DECLS
149
150 #endif /*!TERM_H*/