-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoc.h
114 lines (90 loc) · 2.27 KB
/
doc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef _DOC_H
#define _DOC_H
#include <stddef.h>
#define EPARAGRAPH_INITIAL_CAPACITY 256
/* document node config */
typedef enum {
AJUSTIFY,
ALEFT,
ACENTER,
ARIGHT
} align_t;
typedef struct {
align_t align;
int indent;
int columns;
} docentry_format_t;
/* Document node type */
typedef enum {
ENULL,
EPARAGRAPH,
EFIGURE, /* preformat */
ESTRUCTURE,
ETITLEPAGE,
EPAGEBREAK,
ETABLEOFCONTENTS,
ELIST,
ETABLE
} entrytype_t;
extern const char *entrytype_names[];
/* Document tree node */
typedef struct docentry_s {
entrytype_t type;
docentry_format_t efmt;
int page, line, width, height;
char *data;
size_t size, capacity;
struct docentry_s *n;
} docentry_t;
typedef enum {
SPART,
SCHAPTER,
SSECTION,
SSUBSECTION,
SSUBSUBSECTION
} structuretype_t;
extern const char *structuretype_names[];
typedef struct {
structuretype_t type;
const char *heading;
} docentry_structure_t;
typedef struct {
const char *caption;
const char *predata;
} docentry_figure_t;
typedef enum {
LITEMIZE,
LENUMERATE
} list_type_t;
typedef struct {
int size, capacity;
char *content;
} docentry_list_item_t;
typedef struct {
list_type_t type;
const char *caption;
size_t count;
docentry_list_item_t *items;
} docentry_list_t;
typedef struct {
const char *caption;
int ncols, nrows, has_header, has_interhbars;
char **cells; /* r*W + c */
int *col_widths, *row_heights;
} docentry_table_t;
docentry_t *doc_new();
docentry_t *doc_insert_null(docentry_t *e);
docentry_t *doc_insert_paragraph(docentry_t *e, docentry_format_t *efmt);
docentry_t *doc_insert_titlepage(docentry_t *e);
docentry_t *doc_insert_structure(docentry_t *e, structuretype_t type,
const char *heading);
docentry_t *doc_insert_pagebreak(docentry_t *e);
docentry_t *doc_insert_tableofcontents(docentry_t *e);
docentry_t *doc_insert_figure(docentry_t *e, const docentry_format_t *efmt,
const char *caption);
docentry_t *doc_insert_list(docentry_t *e, const docentry_format_t *efmt,
list_type_t type, const char *caption);
void doc_list_insert(docentry_t *e);
docentry_t *doc_insert_table(docentry_t *e, const docentry_format_t *efmt,
const char *caption);
#endif /* _DOC_H */