Annotation of mandoc/tbl.h, Revision 1.3
1.3 ! schwarze 1: /* $Id: tbl.h,v 1.2 2021/08/10 12:55:04 schwarze Exp $ */
1.1 schwarze 2: /*
3: * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
1.2 schwarze 4: * Copyright (c) 2014,2015,2017,2018,2021 Ingo Schwarze <schwarze@openbsd.org>
1.1 schwarze 5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: struct tbl_opts {
20: int opts;
21: #define TBL_OPT_ALLBOX (1 << 0) /* Option "allbox". */
22: #define TBL_OPT_BOX (1 << 1) /* Option "box". */
23: #define TBL_OPT_CENTRE (1 << 2) /* Option "center". */
24: #define TBL_OPT_DBOX (1 << 3) /* Option "doublebox". */
25: #define TBL_OPT_EXPAND (1 << 4) /* Option "expand". */
26: #define TBL_OPT_NOKEEP (1 << 5) /* Option "nokeep". */
27: #define TBL_OPT_NOSPACE (1 << 6) /* Option "nospaces". */
28: #define TBL_OPT_NOWARN (1 << 7) /* Option "nowarn". */
29: int cols; /* Number of columns. */
30: int lvert; /* Width of left vertical line. */
31: int rvert; /* Width of right vertical line. */
32: char tab; /* Option "tab": cell separator. */
33: char decimal; /* Option "decimalpoint". */
34: };
35:
36: enum tbl_cellt {
37: TBL_CELL_CENTRE, /* c, C */
38: TBL_CELL_RIGHT, /* r, R */
39: TBL_CELL_LEFT, /* l, L */
40: TBL_CELL_NUMBER, /* n, N */
41: TBL_CELL_SPAN, /* s, S */
42: TBL_CELL_LONG, /* a, A */
43: TBL_CELL_DOWN, /* ^ */
44: TBL_CELL_HORIZ, /* _, - */
45: TBL_CELL_DHORIZ, /* = */
46: TBL_CELL_MAX
47: };
48:
49: /*
50: * A cell in a layout row.
51: */
52: struct tbl_cell {
53: struct tbl_cell *next; /* Layout cell to the right. */
54: size_t width; /* Minimum column width. */
55: size_t spacing; /* To the right of the column. */
56: int vert; /* Width of subsequent vertical line. */
57: int col; /* Column number, starting from 0. */
58: int flags;
59: #define TBL_CELL_TALIGN (1 << 2) /* t, T */
60: #define TBL_CELL_UP (1 << 3) /* u, U */
61: #define TBL_CELL_BALIGN (1 << 4) /* d, D */
62: #define TBL_CELL_WIGN (1 << 5) /* z, Z */
63: #define TBL_CELL_EQUAL (1 << 6) /* e, E */
64: #define TBL_CELL_WMAX (1 << 7) /* x, X */
1.2 schwarze 65: enum mandoc_esc font;
1.1 schwarze 66: enum tbl_cellt pos;
67: };
68:
69: /*
70: * A layout row.
71: */
72: struct tbl_row {
73: struct tbl_row *next; /* Layout row below. */
74: struct tbl_cell *first; /* Leftmost layout cell. */
75: struct tbl_cell *last; /* Rightmost layout cell. */
76: int vert; /* Width of left vertical line. */
77: };
78:
79: enum tbl_datt {
80: TBL_DATA_NONE, /* Uninitialized row. */
81: TBL_DATA_DATA, /* Contains data rather than a line. */
82: TBL_DATA_HORIZ, /* _: connecting horizontal line. */
83: TBL_DATA_DHORIZ, /* =: connecting double horizontal line. */
84: TBL_DATA_NHORIZ, /* \_: isolated horizontal line. */
85: TBL_DATA_NDHORIZ /* \=: isolated double horizontal line. */
86: };
87:
88: /*
89: * A cell within a row of data. The "string" field contains the
90: * actual string value that's in the cell. The rest is layout.
91: */
92: struct tbl_dat {
93: struct tbl_dat *next; /* Data cell to the right. */
94: struct tbl_cell *layout; /* Associated layout cell. */
95: char *string; /* Data, or NULL if not TBL_DATA_DATA. */
96: int hspans; /* How many horizontal spans follow. */
97: int vspans; /* How many vertical spans follow. */
98: int block; /* T{ text block T} */
99: enum tbl_datt pos;
100: };
101:
102: enum tbl_spant {
103: TBL_SPAN_DATA, /* Contains data rather than a line. */
104: TBL_SPAN_HORIZ, /* _: horizontal line. */
105: TBL_SPAN_DHORIZ /* =: double horizontal line. */
106: };
107:
108: /*
109: * A row of data in a table.
110: */
111: struct tbl_span {
112: struct tbl_opts *opts; /* Options for the table as a whole. */
113: struct tbl_span *prev; /* Data row above. */
114: struct tbl_span *next; /* Data row below. */
115: struct tbl_row *layout; /* Associated layout row. */
116: struct tbl_dat *first; /* Leftmost data cell. */
117: struct tbl_dat *last; /* Rightmost data cell. */
118: int line; /* Input file line number. */
119: enum tbl_spant pos;
120: };
CVSweb