diff options
author | 2009-10-18 13:34:16 +0000 | |
---|---|---|
committer | 2009-10-18 13:34:16 +0000 | |
commit | fed65dbd741c3ee7e0a61c1acc0ac5d42f6d811a (patch) | |
tree | 7a2aa789e646a658bd043cc66005a38c9f84367b /term.c | |
parent | d5d132e7675ed3a3f6510e8d903e87537bb72285 (diff) | |
download | mandoc-fed65dbd741c3ee7e0a61c1acc0ac5d42f6d811a.tar.gz mandoc-fed65dbd741c3ee7e0a61c1acc0ac5d42f6d811a.tar.zst mandoc-fed65dbd741c3ee7e0a61c1acc0ac5d42f6d811a.zip |
Arbitrary horizontal and vertical scaling widths now handled by -mdoc -Tascii.
Terminal scaling backend pushed into term.c.
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 85 |
1 files changed, 84 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.105 2009/10/13 10:57:25 kristaps Exp $ */ +/* $Id: term.c,v 1.106 2009/10/18 13:34:17 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se> * @@ -25,6 +25,7 @@ #include "man.h" #include "mdoc.h" #include "main.h" +#include "out.h" /* FIXME: accomodate non-breaking, non-collapsing white-space. */ /* FIXME: accomodate non-breaking, collapsing white-space. */ @@ -558,3 +559,85 @@ encode(struct termp *p, char c) } buffer(p, c); } + + +int +a2height(const char *p) +{ + struct roffsu su; + double r; + + if ( ! a2roffsu(p, &su)) + return(-1); + + switch (su.unit) { + case (SCALE_CM): + r = su.scale * 2; + break; + case (SCALE_IN): + r = su.scale * 6; + break; + case (SCALE_PC): + r = su.scale; + break; + case (SCALE_PT): + r = su.scale / 8; + break; + case (SCALE_MM): + r = su.scale / 1000; + break; + case (SCALE_VS): + r = su.scale; + break; + default: + r = su.scale - 1; + break; + } + + if (r < 0.0) + r = 0.0; + return(/* LINTED */(int) + r); +} + + +int +a2width(const char *p) +{ + struct roffsu su; + double r; + + if ( ! a2roffsu(p, &su)) + return(-1); + + switch (su.unit) { + case (SCALE_CM): + r = (4 * su.scale) + 2; /* FIXME: double-check. */ + break; + case (SCALE_IN): + r = (10 * su.scale) + 2; /* FIXME: double-check. */ + break; + case (SCALE_PC): + r = (10 * su.scale) / 6; /* FIXME: double-check. */ + break; + case (SCALE_PT): + r = (10 * su.scale) / 72; /* FIXME: double-check. */ + break; + case (SCALE_MM): + r = su.scale / 1000; /* FIXME: double-check. */ + break; + case (SCALE_VS): + r = su.scale * 2 - 1; /* FIXME: double-check. */ + break; + default: + r = su.scale + 2; + break; + } + + if (r < 0.0) + r = 0.0; + return((int)/* LINTED */ + r); +} + + |