diff options
author | 2014-10-13 23:31:26 +0000 | |
---|---|---|
committer | 2014-10-13 23:31:26 +0000 | |
commit | fd1e7ec9fdfc39ef3dea8f1158c3c1825d717327 (patch) | |
tree | aeb4f7b914af2876440c6696574323d2bac397d6 | |
parent | disable pagezero thread on hppa, until failure gets diagnosed, ok miod kettenis (diff) | |
download | wireguard-openbsd-fd1e7ec9fdfc39ef3dea8f1158c3c1825d717327.tar.xz wireguard-openbsd-fd1e7ec9fdfc39ef3dea8f1158c3c1825d717327.zip |
implement font modifiers in table layouts
-rw-r--r-- | regress/usr.bin/mandoc/tbl/Makefile | 4 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/fonts.in | 14 | ||||
-rw-r--r-- | regress/usr.bin/mandoc/tbl/fonts.out_ascii | 19 | ||||
-rw-r--r-- | share/man/man7/tbl.7 | 49 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_term.c | 24 |
5 files changed, 81 insertions, 29 deletions
diff --git a/regress/usr.bin/mandoc/tbl/Makefile b/regress/usr.bin/mandoc/tbl/Makefile index 872c90cd8d8..ce88001b7c0 100644 --- a/regress/usr.bin/mandoc/tbl/Makefile +++ b/regress/usr.bin/mandoc/tbl/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.3 2014/08/14 01:58:51 schwarze Exp $ +# $OpenBSD: Makefile,v 1.4 2014/10/13 23:31:26 schwarze Exp $ -REGRESS_TARGETS = center numbers span vert +REGRESS_TARGETS = center fonts numbers span vert SKIP_TMAN ?= ALL TBL = /usr/local/bin/tbl diff --git a/regress/usr.bin/mandoc/tbl/fonts.in b/regress/usr.bin/mandoc/tbl/fonts.in new file mode 100644 index 00000000000..50984d815f3 --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/fonts.in @@ -0,0 +1,14 @@ +.TH TBL-FONTS 1 2014-10-14 OpenBSD +.SH NAME +tbl-fonts \- font modifiers in table layouts +.SH DESCRIPTION +normal text +.TS +box tab(:); +cb | c | ci +cFI | c | cFB . +bold:roman:italic +_ +italic:roman:bold +and:so:on +.TE diff --git a/regress/usr.bin/mandoc/tbl/fonts.out_ascii b/regress/usr.bin/mandoc/tbl/fonts.out_ascii new file mode 100644 index 00000000000..092f1b1fd0b --- /dev/null +++ b/regress/usr.bin/mandoc/tbl/fonts.out_ascii @@ -0,0 +1,19 @@ +TBL-FONTS(1) General Commands Manual TBL-FONTS(1) + + + +NNAAMMEE + tbl-fonts - font modifiers in table layouts + +DDEESSCCRRIIPPTTIIOONN + normal text + + +-------+-------+--------+ + | bboolldd | roman | _i_t_a_l_i_c | + +-------+-------+--------+ + |_i_t_a_l_i_c | roman | bboolldd | + | _a_n_d | so | oonn | + +-------+-------+--------+ + + +OpenBSD 2014-10-14 TBL-FONTS(1) diff --git a/share/man/man7/tbl.7 b/share/man/man7/tbl.7 index 04e8d3dd6d8..082a399d6c6 100644 --- a/share/man/man7/tbl.7 +++ b/share/man/man7/tbl.7 @@ -1,6 +1,7 @@ -.\" $OpenBSD: tbl.7,v 1.5 2013/07/13 19:27:47 schwarze Exp $ +.\" $OpenBSD: tbl.7,v 1.6 2014/10/13 23:31:26 schwarze Exp $ .\" .\" Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> +.\" Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org> .\" .\" Permission to use, copy, modify, and distribute this software for any .\" purpose with or without fee is hereby granted, provided that the above @@ -14,7 +15,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: July 13 2013 $ +.Dd $Mdocdate: October 13 2014 $ .Dt TBL 7 .Os .Sh NAME @@ -195,7 +196,7 @@ Each layout line corresponds to a line of data; the last layout line applies to all remaining data lines. Layout lines may also be separated by a comma. Each layout cell consists of one of the following case-insensitive keys: -.Bl -tag -width Ds +.Bl -tag -width 2n .It Cm c Centre a literal string within its column. .It Cm r @@ -244,35 +245,35 @@ Keys may be followed by a set of modifiers. A modifier is either a modifier key or a natural number for specifying the minimum width of a column. The following case-insensitive modifier keys are available: -.Cm z , -.Cm u , -.Cm e , -.Cm t , +.Bl -tag -width 2n +.It Cm b +Use a bold font for the contents of this column. +.It Cm f +The next character selects the font to use for this column. +See the +.Xr roff 7 +manual for supported one-character font names. +.It Cm i +Use an italic font for the contents of this column. +.El +.Pp +The modifiers .Cm d , -.Cm b , -.Cm i , +.Cm e , .Cm r , +.Cm t , +.Cm u , and -.Cm f -.Po -followed by -.Cm b , -.Cm i , -.Cm r , -.Cm 3 , -.Cm 2 , -or -.Cm 1 -.Pc . -All of these are ignored by +.Cm z +are ignored by .Xr mandoc 1 . .Pp For example, the following layout specifies a centre-justified column of minimum width 10, followed by vertical bar, followed by a left-justified -column of minimum width 10, another vertical bar, then a column -justified about the decimal point in numbers: +column of minimum width 10, another vertical bar, then a column using +bold font justified about the decimal point in numbers: .Pp -.Dl c10 | l10 | n +.Dl c10 | l10 | nfB .Ss Data The data section follows the last layout row. By default, cells in a data section are delimited by a tab. diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c index 4e4f70a9792..eb515287b5b 100644 --- a/usr.bin/mandoc/tbl_term.c +++ b/usr.bin/mandoc/tbl_term.c @@ -1,4 +1,4 @@ -/* $Id: tbl_term.c,v 1.16 2014/04/20 16:44:44 schwarze Exp $ */ +/* $OpenBSD: tbl_term.c,v 1.17 2014/10/13 23:31:26 schwarze Exp $ */ /* * Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -15,6 +15,8 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/types.h> + #include <assert.h> #include <stdio.h> #include <stdlib.h> @@ -39,6 +41,7 @@ static void tbl_number(struct termp *, const struct tbl_opts *, const struct roffcol *); static void tbl_hrule(struct termp *, const struct tbl_span *); static void tbl_vrule(struct termp *, const struct tbl_head *); +static void tbl_word(struct termp *, const struct tbl_dat *); static size_t @@ -374,7 +377,7 @@ tbl_literal(struct termp *tp, const struct tbl_dat *dp, } tbl_char(tp, ASCII_NBRSP, padl); - term_word(tp, dp->string); + tbl_word(tp, dp); tbl_char(tp, ASCII_NBRSP, padr); } @@ -415,8 +418,23 @@ tbl_number(struct termp *tp, const struct tbl_opts *opts, padl = col->decimal - d; tbl_char(tp, ASCII_NBRSP, padl); - term_word(tp, dp->string); + tbl_word(tp, dp); if (col->width > sz + padl) tbl_char(tp, ASCII_NBRSP, col->width - sz - padl); } +static void +tbl_word(struct termp *tp, const struct tbl_dat *dp) +{ + const void *prev_font; + + prev_font = term_fontq(tp); + if (dp->layout->flags & TBL_CELL_BOLD) + term_fontpush(tp, TERMFONT_BOLD); + else if (dp->layout->flags & TBL_CELL_ITALIC) + term_fontpush(tp, TERMFONT_UNDER); + + term_word(tp, dp->string); + + term_fontpopq(tp, prev_font); +} |