=================================================================== RCS file: /cvs/mandoc/term.c,v retrieving revision 1.146 retrieving revision 1.150 diff -u -p -r1.146 -r1.150 --- mandoc/term.c 2010/06/08 15:00:17 1.146 +++ mandoc/term.c 2010/06/26 15:36:37 1.150 @@ -1,6 +1,6 @@ -/* $Id: term.c,v 1.146 2010/06/08 15:00:17 kristaps Exp $ */ +/* $Id: term.c,v 1.150 2010/06/26 15:36:37 kristaps Exp $ */ /* - * Copyright (c) 2008, 2009 Kristaps Dzonsons + * Copyright (c) 2008, 2009 Kristaps Dzonsons * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -31,8 +31,6 @@ #include "chars.h" #include "out.h" #include "term.h" -#include "man.h" -#include "mdoc.h" #include "main.h" static void spec(struct termp *, const char *, size_t); @@ -87,9 +85,7 @@ term_alloc(enum termenc enc) exit(EXIT_FAILURE); } - p->tabwidth = 5; p->enc = enc; - p->defrmargin = 78; return(p); } @@ -603,12 +599,9 @@ encode(struct termp *p, const char *word, size_t sz) * character by character. */ - if (TERMTYPE_PS == p->type) { + if (TERMFONT_NONE == (f = term_fonttop(p))) { buffera(p, word, sz); return; - } else if (TERMFONT_NONE == (f = term_fonttop(p))) { - buffera(p, word, sz); - return; } for (i = 0; i < (int)sz; i++) { @@ -629,8 +622,28 @@ encode(struct termp *p, const char *word, size_t sz) size_t -term_vspan(const struct roffsu *su) +term_len(const struct termp *p, size_t sz) { + + return((*p->width)(p, ' ') * sz); +} + + +size_t +term_strlen(const struct termp *p, const char *cp) +{ + size_t sz; + + for (sz = 0; *cp; cp++) + sz += (*p->width)(p, *cp); + + return(sz); +} + + +size_t +term_vspan(const struct termp *p, const struct roffsu *su) +{ double r; switch (su->unit) { @@ -665,7 +678,7 @@ term_vspan(const struct roffsu *su) size_t -term_hspan(const struct roffsu *su) +term_hspan(const struct termp *p, const struct roffsu *su) { double r;