diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-14 01:31:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2017-06-14 01:31:26 +0000 |
commit | 078c4f79913f5f296b88db4a9fed67f1ea124c86 (patch) | |
tree | deafb282df1e0b025b4322b763df47080a885828 /term.c | |
parent | 3352a8e9bd0f6a0666c5dcb84ccdb5536471d280 (diff) | |
download | mandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.tar.gz mandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.tar.zst mandoc-078c4f79913f5f296b88db4a9fed67f1ea124c86.zip |
implement the roff(7) \p (break output line) escape sequence
Diffstat (limited to 'term.c')
-rw-r--r-- | term.c | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: term.c,v 1.269 2017/06/12 19:05:47 schwarze Exp $ */ +/* $Id: term.c,v 1.270 2017/06/14 01:31:27 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org> @@ -116,6 +116,7 @@ term_flushln(struct termp *p) size_t jhy; /* last hyph before overflow w/r/t j */ size_t maxvis; /* output position of visible boundary */ int ntab; /* number of tabs to prepend */ + int breakline; /* after this word */ vbl = (p->flags & TERMP_NOPAD) || p->tcol->offset < p->viscol ? 0 : p->tcol->offset - p->viscol; @@ -155,7 +156,13 @@ term_flushln(struct termp *p) */ jhy = 0; + breakline = 0; for (j = p->tcol->col; j < p->tcol->lastcol; j++) { + if (p->tcol->buf[j] == '\n') { + if ((p->flags & TERMP_BRIND) == 0) + breakline = 1; + continue; + } if (p->tcol->buf[j] == ' ' || p->tcol->buf[j] == '\t') break; @@ -221,6 +228,8 @@ term_flushln(struct termp *p) for ( ; p->tcol->col < p->tcol->lastcol; p->tcol->col++) { if (vend > bp && jhy > 0 && p->tcol->col > jhy) break; + if (p->tcol->buf[p->tcol->col] == '\n') + continue; if (p->tcol->buf[p->tcol->col] == '\t') break; if (p->tcol->buf[p->tcol->col] == ' ') { @@ -260,6 +269,26 @@ term_flushln(struct termp *p) p->tcol->buf[p->tcol->col]); } vis = vend; + + if (breakline == 0) + continue; + + /* Explicitly requested output line break. */ + + if (p->flags & TERMP_MULTICOL) + return; + + endline(p); + breakline = 0; + vis = vend = 0; + + /* Re-establish indentation. */ + + vbl = p->tcol->offset; + maxvis = p->tcol->rmargin > vbl ? + p->tcol->rmargin - vbl : 0; + bp = !(p->flags & TERMP_NOBREAK) ? maxvis : + p->maxrmargin > vbl ? p->maxrmargin - vbl : 0; } /* @@ -487,6 +516,9 @@ term_word(struct termp *p, const char *word) case ESCAPE_FONTPREV: term_fontlast(p); continue; + case ESCAPE_BREAK: + bufferc(p, '\n'); + continue; case ESCAPE_NOSPACE: if (p->flags & TERMP_BACKAFTER) p->flags &= ~TERMP_BACKAFTER; |