From 1e85c3949ce76b81aa8b89f634e30797ddc81cc8 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 2 Mar 2009 17:29:16 +0000 Subject: Noted lacking areas in mdocterm.1. Put styles into symtab (for real this time). --- mdocterm.1 | 23 +++++++++++++++++++++-- mdocterm.c | 53 +++++++++++++++++------------------------------------ term.c | 5 +++-- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/mdocterm.1 b/mdocterm.1 index f350c336..49250d59 100644 --- a/mdocterm.1 +++ b/mdocterm.1 @@ -1,4 +1,4 @@ -.\" $Id: mdocterm.1,v 1.8 2009/02/27 10:55:16 kristaps Exp $ +.\" $Id: mdocterm.1,v 1.9 2009/03/02 17:29:16 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -16,7 +16,7 @@ .\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR .\" PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: February 27 2009 $ +.Dd $Mdocdate: March 2 2009 $ .Dt mdocmterm 1 .Os .\" SECTION @@ -220,3 +220,22 @@ See .Xr mdoc 3 for a list of bugs, caveats, and incomplete macros regarding the document parse. +.Pp +The +.Nm +utility doesn't yet know how to display the following: +.Pp +.Bl -bullet -compact +.It +Only \-bullet , \-dash , \-enum , \-hyphen , \-tag and \-ohang +.Sq \&Bl +lists are supported. +.It +The \-literal and \-unfilled +.Sq \&Bd +displays only accept text contents. +.It +The +.Sq \&Xo/Xc +pair isn't supported (and never will be). +.El diff --git a/mdocterm.c b/mdocterm.c index 0e36fb30..f2f05dfa 100644 --- a/mdocterm.c +++ b/mdocterm.c @@ -1,4 +1,4 @@ -/* $Id: mdocterm.c,v 1.25 2009/03/02 17:14:46 kristaps Exp $ */ +/* $Id: mdocterm.c,v 1.26 2009/03/02 17:29:16 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -44,13 +44,13 @@ static void footer(struct termp *, static void pword(struct termp *, const char *, size_t); static void pescape(struct termp *, const char *, size_t *, size_t); -static void style(struct termp *, enum tstyle); static void nescape(struct termp *, const char *, size_t); static void chara(struct termp *, char); static void stringa(struct termp *, const char *, size_t); static void symbola(struct termp *, enum tsym); +static void stylea(struct termp *, enum tstyle); #ifdef __linux__ extern size_t strlcat(char *, const char *, size_t); @@ -729,37 +729,6 @@ nescape(struct termp *p, const char *word, size_t len) } -/* - * Apply a style to the output buffer. This is looked up by means of - * the styletab. - */ -static void -style(struct termp *p, enum tstyle esc) -{ - - if (p->col + 4 >= p->maxcols) - errx(1, "line overrun"); - - p->buf[(p->col)++] = 27; - p->buf[(p->col)++] = '['; - switch (esc) { - case (TERMSTYLE_CLEAR): - p->buf[(p->col)++] = '0'; - break; - case (TERMSTYLE_BOLD): - p->buf[(p->col)++] = '1'; - break; - case (TERMSTYLE_UNDER): - p->buf[(p->col)++] = '4'; - break; - default: - abort(); - /* NOTREACHED */ - } - p->buf[(p->col)++] = 'm'; -} - - /* * Handle an escape sequence: determine its length and pass it to the * escape-symbol look table. Note that we assume mdoc(3) has validated @@ -835,9 +804,9 @@ pword(struct termp *p, const char *word, size_t len) */ if (p->flags & TERMP_BOLD) - style(p, TERMSTYLE_BOLD); + stylea(p, TERMSTYLE_BOLD); if (p->flags & TERMP_UNDERLINE) - style(p, TERMSTYLE_UNDER); + stylea(p, TERMSTYLE_UNDER); for (i = 0; i < len; i++) { if ('\\' == word[i]) { @@ -849,7 +818,7 @@ pword(struct termp *p, const char *word, size_t len) if (p->flags & TERMP_BOLD || p->flags & TERMP_UNDERLINE) - style(p, TERMSTYLE_CLEAR); + stylea(p, TERMSTYLE_CLEAR); } @@ -865,6 +834,18 @@ symbola(struct termp *p, enum tsym sym) } +/* + * Add a style to the output line buffer. + */ +static void +stylea(struct termp *p, enum tstyle style) +{ + + assert(p->styletab[style].sym); + stringa(p, p->styletab[style].sym, p->styletab[style].sz); +} + + /* * Like chara() but for arbitrary-length buffers. Resize the buffer by * a factor of two (if the buffer is less than that) or the buffer's diff --git a/term.c b/term.c index 80962387..5181f9b0 100644 --- a/term.c +++ b/term.c @@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.35 2009/03/02 17:14:46 kristaps Exp $ */ +/* $Id: term.c,v 1.36 2009/03/02 17:29:16 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -30,7 +30,6 @@ * post-fix operations are defined here. */ -/* FIXME: indent/tab. */ /* FIXME: macro arguments can be escaped. */ #define TTYPE_PROG 0 @@ -59,6 +58,8 @@ * the same thing (like .Ex -std cmd and .Nm cmd). */ +/* TODO: abstract this into mdocterm.c. */ + const int ttypes[TTYPE_NMAX] = { TERMP_BOLD, /* TTYPE_PROG */ TERMP_BOLD, /* TTYPE_CMD_FLAG */ -- cgit v1.2.3-56-ge451