tbl_term.c revision 95c635efb7c3b86efc493e0447eaec7aecca3f0f
/* $Id: tbl_term.c,v 1.21 2011/09/20 23:05:49 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mandoc.h"
#include "out.h"
#include "term.h"
static size_t term_tbl_strlen(const char *, void *);
const struct tbl_dat *,
const struct roffcol *);
const struct roffcol *);
const struct tbl_dat *,
const struct roffcol *);
static size_t
term_tbl_strlen(const char *p, void *arg)
{
}
static size_t
{
}
void
{
int spans;
/* Inhibit printing of spaces: we do padding ourselves. */
/*
* The first time we're invoked for a given table block,
* calculate the table widths and decimal positions.
*/
}
/* Horizontal frame at the start of boxed tables. */
}
/* Vertical frame at the start of each row. */
/*
* Now print the actual data itself depending on the span type.
* Spanner spans get a horizontal rule; data spanners have their
* data printed by matching data to header.
*/
case (TBL_SPAN_HORIZ):
/* FALLTHROUGH */
case (TBL_SPAN_DHORIZ):
break;
case (TBL_SPAN_DATA):
/* Iterate over template headers. */
spans = 0;
/*
* If the current data header is invoked during
* a spanner ("spans" > 0), don't emit anything
* at all.
*/
case (TBL_HEAD_VERT):
/* FALLTHROUGH */
case (TBL_HEAD_DVERT):
if (spans <= 0)
continue;
case (TBL_HEAD_DATA):
break;
}
if (--spans >= 0)
continue;
/*
* All cells get a leading blank, except the
* first one and those after double rulers.
*/
/* No trailing blanks. */
break;
/*
* Add another blank between cells,
* or two when there is no vertical ruler.
*/
/*
* Go to the next data cell and assign the
* number of subsequent spans, if applicable.
*/
if (dp) {
}
}
break;
}
/* Vertical frame at the end of each row. */
/*
* If we're the last row, clean up after ourselves: clear the
* existing table configuration and set it to NULL.
*/
}
}
/*
* Horizontal rules extend across the entire table.
* Calculate the width by iterating over columns.
*/
static size_t
{
/* Account for leading blanks. */
width++;
/* Account for trailing blanks. */
width++;
width++;
}
return(width);
}
/*
* Rules inside the table can be single or double
* and have crossings with vertical rules marked with pluses.
*/
static void
{
char c;
c = '-';
c = '=';
}
/*
* Rules above and below the table are always single
* and have an additional plus at the beginning and end.
* For double frames, this function is called twice,
* and the outer one does not have crossings.
*/
static void
{
}
static void
{
return;
}
case (TBL_DATA_NONE):
return;
case (TBL_DATA_HORIZ):
/* FALLTHROUGH */
case (TBL_DATA_NHORIZ):
return;
case (TBL_DATA_NDHORIZ):
/* FALLTHROUGH */
case (TBL_DATA_DHORIZ):
return;
default:
break;
}
case (TBL_CELL_HORIZ):
break;
case (TBL_CELL_DHORIZ):
break;
case (TBL_CELL_LONG):
/* FALLTHROUGH */
case (TBL_CELL_CENTRE):
/* FALLTHROUGH */
case (TBL_CELL_LEFT):
/* FALLTHROUGH */
case (TBL_CELL_RIGHT):
break;
case (TBL_CELL_NUMBER):
break;
case (TBL_CELL_DOWN):
break;
default:
abort();
/* NOTREACHED */
}
}
static void
{
case (TBL_HEAD_VERT):
break;
case (TBL_HEAD_DVERT):
break;
default:
break;
}
}
static void
{
char cp[2];
cp[0] = c;
}
static void
{
padl = 0;
case (TBL_CELL_LONG):
break;
case (TBL_CELL_CENTRE):
if (2 > padr)
break;
break;
case (TBL_CELL_RIGHT):
padr = 0;
break;
default:
break;
}
}
static void
{
char *cp;
char buf[2];
int i;
/*
* See calc_data_number(). Left-pad by taking the offset of our
* and the maximum decimal; right-pad by the remaining amount.
*/
}
} else
}