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