]> git.cameronkatri.com Git - mandoc.git/blob - term.h
Added new old escape sequence \*[nn].
[mandoc.git] / term.h
1 /* $Id: term.h,v 1.14 2009/03/02 17:14:46 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 };
58
59
60 enum tstyle {
61 TERMSTYLE_CLEAR = 0,
62 TERMSTYLE_BOLD = 1,
63 TERMSTYLE_UNDER = 2,
64 TERMSTYLE_MAX = 3
65 };
66
67 struct termsym {
68 const char *sym;
69 size_t sz;
70 };
71
72 struct termp {
73 size_t rmargin;
74 size_t maxrmargin;
75 size_t maxcols;
76 size_t offset;
77 size_t col;
78 int flags;
79 #define TERMP_BOLD (1 << 0) /* Embolden words. */
80 #define TERMP_UNDERLINE (1 << 1) /* Underline words. */
81 #define TERMP_NOSPACE (1 << 2) /* No space before words. */
82 #define TERMP_NOLPAD (1 << 3) /* No leftpad before flush. */
83 #define TERMP_NOBREAK (1 << 4) /* No break after flush. */
84 #define TERMP_LITERAL (1 << 5) /* Literal words. */
85 #define TERMP_IGNDELIM (1 << 6) /* Delims like regulars. */
86 #define TERMP_NONOSPACE (1 << 7) /* No space (no autounset). */
87 char *buf;
88 struct termsym *symtab; /* Special-symbol table. */
89 struct termsym *styletab; /* Style table. */
90 };
91
92 struct termpair {
93 struct termpair *ppair;
94 int type;
95 #define TERMPAIR_FLAG (1 << 0)
96 int flag;
97 size_t offset;
98 size_t rmargin;
99 int count;
100 };
101
102 #define TERMPAIR_SETFLAG(termp, p, fl) \
103 do { \
104 assert(! (TERMPAIR_FLAG & (p)->type)); \
105 (termp)->flags |= (fl); \
106 (p)->flag = (fl); \
107 (p)->type |= TERMPAIR_FLAG; \
108 } while (0)
109
110 struct termact {
111 int (*pre)(struct termp *,
112 struct termpair *,
113 const struct mdoc_meta *,
114 const struct mdoc_node *);
115 void (*post)(struct termp *,
116 struct termpair *,
117 const struct mdoc_meta *,
118 const struct mdoc_node *);
119 };
120
121 void newln(struct termp *);
122 void vspace(struct termp *);
123 void word(struct termp *, const char *);
124 void flushln(struct termp *);
125 void transcode(struct termp *,
126 const char *, size_t);
127 void subtree(struct termp *,
128 const struct mdoc_meta *,
129 const struct mdoc_node *);
130
131
132 const struct termact *termacts;
133
134 __END_DECLS
135
136 #endif /*!TERM_H*/