struct table_item *subtable;
}
u;
+
+ size_t n_footnotes;
+ char **footnotes;
};
static const struct table_class tab_table_class;
table_set_nr (&t->table, nr);
t->title = NULL;
+ t->caption = NULL;
t->cf = nc;
t->cc = pool_calloc (t->container, nr * nc, sizeof *t->cc);
t->ct = pool_malloc (t->container, nr * nc);
j->d[TABLE_VERT][0] = y1 + table->row_ofs;
j->d[TABLE_HORZ][1] = ++x2 + table->col_ofs;
j->d[TABLE_VERT][1] = ++y2 + table->row_ofs;
+ j->n_footnotes = 0;
+ j->footnotes = NULL;
{
void **cc = &table->cc[x1 + y1 * table->cf];
add_joined_cell (table, x1, y1, x2, y2, opt)->u.text = s;
}
+void
+tab_footnote (struct tab_table *table, int x, int y, const char *format, ...)
+{
+ int index = x + y * table->cf;
+ unsigned char opt = table->ct[index];
+ struct tab_joined_cell *j;
+ va_list args;
+
+ if (opt & TAB_JOIN)
+ j = table->cc[index];
+ else
+ {
+ char *text = table->cc[index];
+
+ j = add_joined_cell (table, x, y, x, y, table->ct[index]);
+ j->u.text = text ? text : xstrdup ("");
+ }
+
+ j->footnotes = xrealloc (j->footnotes,
+ (j->n_footnotes + 1) * sizeof *j->footnotes);
+
+ va_start (args, format);
+ j->footnotes[j->n_footnotes++] = pool_vasprintf (table->container, format, args);
+ va_end (args);
+}
+
static void
subtable_unref (void *subtable)
{
va_end (args);
}
+/* Set the caption of table T to CAPTION, which is formatted as if
+ passed to printf(). */
+void
+tab_caption (struct tab_table *t, const char *caption, ...)
+{
+ va_list args;
+
+ free (t->caption);
+ va_start (args, caption);
+ t->caption = xvasprintf (caption, args);
+ va_end (args);
+}
+
/* Easy, type-safe way to submit a tab table to som. */
void
tab_submit (struct tab_table *t)
{
- table_item_submit (table_item_create (&t->table, t->title));
+ table_item_submit (table_item_create (&t->table, t->title, t->caption));
}
\f
/* Editing. */
struct tab_table *t = tab_cast (table);
free (t->title);
t->title = NULL;
+ free (t->caption);
+ t->caption = NULL;
pool_destroy (t->container);
}
cell->inline_contents.options = opt;
cell->inline_contents.table = NULL;
+ cell->inline_contents.n_footnotes = 0;
cell->destructor = NULL;
if (opt & TAB_JOIN)
cell->inline_contents.text = jc->u.text;
}
+ cell->inline_contents.footnotes = jc->footnotes;
+ cell->inline_contents.n_footnotes = jc->n_footnotes;
+
cell->d[TABLE_HORZ][0] = jc->d[TABLE_HORZ][0];
cell->d[TABLE_HORZ][1] = jc->d[TABLE_HORZ][1];
cell->d[TABLE_VERT][0] = jc->d[TABLE_VERT][0];