aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/term.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-25 18:53:14 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-25 18:53:14 +0000
commitd7293bc22cd91ff63e04800adfed0982252d8574 (patch)
tree74bc47d73e12087b65abc5914862898a9dc96a12 /term.c
parenteb93fb04842bea580dd14f70d9688486882b69fe (diff)
downloadmandoc-d7293bc22cd91ff63e04800adfed0982252d8574.tar.gz
mandoc-d7293bc22cd91ff63e04800adfed0982252d8574.tar.zst
mandoc-d7293bc22cd91ff63e04800adfed0982252d8574.zip
Initial chunks for variable-width fonts. Pushes all width calculations
in mdoc_term.c and man_term.c down into term.c. This is still not implemented in term.c, although stubs for width calculations are in place. From now on, offset, rmargin, and other layout variables are abstract screen widths. They will resolve to the the familiar values for -Tascii but -Tps will eventually use points instead of chars.
Diffstat (limited to 'term.c')
-rw-r--r--term.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/term.c b/term.c
index 1801ef93..bd557395 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.148 2010/06/19 20:46:28 kristaps Exp $ */
+/* $Id: term.c,v 1.149 2010/06/25 18:53:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -87,9 +87,7 @@ term_alloc(enum termenc enc)
exit(EXIT_FAILURE);
}
- p->tabwidth = 5;
p->enc = enc;
- p->defrmargin = 78;
return(p);
}
@@ -626,7 +624,27 @@ 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;
@@ -662,7 +680,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;