diff options
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | doc/meref.me | 15 | ||||
-rw-r--r-- | doc/webpage.ms | 42 | ||||
-rw-r--r-- | src/preproc/tbl/table.cpp | 69 | ||||
-rw-r--r-- | tmac/e.tmac | 120 |
6 files changed, 248 insertions, 24 deletions
@@ -1,3 +1,22 @@ +2011-07-20 George HELFFRICH <ghfbsd@gmail.com> + + Improve line numbering support in tbl and with me macros. + + * tmac/e.tmac (n1, n2, TH, PS): Implement it. + (@h, @n, @o, @t, @k, )b, (c, (q, )q, (l, )l, (f, @q, PE): Updated. + * doc/meref.me: Document changes. + + * src/preproc/tbl/table.cpp (ROW_START_LINE_REG, ROW_SAVE_LINE_REG, + ROW_MAX_LINE_REG, REPEATED_NM_SET_MACRO, REPEATED_NM_SUS_MACRO): New + macros. + (table::init_output): Define REPEATED_NM_SET_MACRO and + REPEATED_NM_SUS_MACRO. + (table::print_single_hline, table::print_double_hline, + table::define_bottom_macro, table::do_row, table::do_top, + table::do_bottom): Updated. + + * doc/webpage.ms: Updated. + 2011-07-12 Ted Harding <ted.harding@wlandres.net> Werner LEMBERG <wl@gnu.org> @@ -22,6 +22,13 @@ Macro Packages o Support for the `refer' preprocessor has been added to the -mm macro package. +o Bugs in the support for the `n1' and `n2' requests in the -me package were + fixed that caused extra line numbers to be added to text in floats and + diversion environments, as well as equations and pic-style pictures. + + The `TH' macro was changed for compatibility with line number support in + tables. + VERSION 1.21 ============ diff --git a/doc/meref.me b/doc/meref.me index 848b6c83..1685561f 100644 --- a/doc/meref.me +++ b/doc/meref.me @@ -1329,12 +1329,25 @@ on each page. .TL .b .n2 .i N +.i c .DE Number lines from .i N , stop if .i N -= 0. +missing; resume where stopped with (unsigned) value +.i N +or increment +.i N +if +.i N +is \(+-\c +.i N . +If +.i c +is c, maintain compatibility with original +.b .n2 +by narrowing line width to accommodate numbers. .TL .b .sk .DE diff --git a/doc/webpage.ms b/doc/webpage.ms index cbd9e3b7..b195f6c8 100644 --- a/doc/webpage.ms +++ b/doc/webpage.ms @@ -296,6 +296,46 @@ postings to the corresponding mailing list. . . .SH +NEWS VERSION 1.21.1 +.LP +.SH 2 +groff + +.ULS +.LI +A new option `\-j' has been added to call the `chem' preprocessor. +.ULE +. +. +.SH 2 +macro packages + +.ULS +.LI +Support for the `refer' preprocessor has been added to the \-mm macro +package. + + +.LI +Bugs in the support for the `n1' and `n2' requests in the \-me package were +fixed that caused extra line numbers to be added to text in floats and +diversion environments, as well as equations and pic-style pictures. + +The `TH' macro was changed for compatibility with line number support in +tables. +.ULE +. +. +.SH 2 +tbl + +.ULS +.LI +Added numbered line support in tables. +.ULE +. +. +.SH NEWS VERSION 1.21 .LP .SH 2 @@ -689,7 +729,7 @@ Here the same table using a more expanded syntax: Tables can be nested; `hdtbl' works without a preprocessor so that the full capability of groff's macro engine is available. -This package currently works with `-Tps' only. +This package currently works with `\-Tps' only. .LI \-mandoc now supports multiple man pages (in either man or mdoc format). diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp index e1b8c3fb..64f5ab40 100644 --- a/src/preproc/tbl/table.cpp +++ b/src/preproc/tbl/table.cpp @@ -1,6 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2003, 2004, 2007, 2008, - 2009, 2010 +/* Copyright (C) 1989-1992, 2000, 2003, 2004, 2007-2011 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -59,6 +58,11 @@ const int DEFAULT_COLUMN_SEPARATION = 3; #define REPEATED_VPT_MACRO PREFIX "rvpt" #define SUPPRESS_BOTTOM_REG PREFIX "supbot" #define SAVED_DN_REG PREFIX "dn" +#define ROW_START_LINE_REG PREFIX "lnst" +#define ROW_SAVE_LINE_REG PREFIX "lnsv" +#define ROW_MAX_LINE_REG PREFIX "lnmx" +#define REPEATED_NM_SET_MACRO PREFIX "rlns" +#define REPEATED_NM_SUS_MACRO PREFIX "rlnx" // this must be one character #define COMPATIBLE_REG PREFIX "c" @@ -1780,6 +1784,31 @@ void table::init_output() ".de " REPEATED_VPT_MACRO "\n" ".vpt \\$1\n" ".if !'\\n(.z'' \\!." REPEATED_VPT_MACRO " \"\\$1\"\n" + "..\n" + ".de " REPEATED_NM_SET_MACRO "\n" + ".ie !'\\n(.z'' \\{.nm\n" + "\\!." REPEATED_NM_SET_MACRO " \"\\$1\"\n" + ".\\}\n" + ".el .if \\n[ln] \\{\\\n" + ".if '\\$1'd' .nr " ROW_START_LINE_REG " \\n[ln]\n" + ".if '\\$1's' .nm \\n[" ROW_START_LINE_REG "]\n" + ".if '\\$1'm' .nr " ROW_MAX_LINE_REG " \\n[ln]>?\\n[" ROW_MAX_LINE_REG "]\n" + ".\\}\n" + "..\n" + ".de " REPEATED_NM_SUS_MACRO "\n" + ".ie !'\\n(.z'' \\{.nm\n" + "\\!." REPEATED_NM_SUS_MACRO " \"\\$1\"\n" + ".\\}\n" + ".el .if \\n[ln] \\{\\\n" + ".ie '\\$1's' \\{\\\n" + ".nr " ROW_SAVE_LINE_REG " \\n(ln<?\\n[" ROW_MAX_LINE_REG "]\n" + ".nm +0 \\n[ln]+42\n" + ".\\}\n" + ".el \\{\\\n" + ".nr ln \\n[" ROW_SAVE_LINE_REG "]\n" + ".nm \\n[ln] 1\n" + ".\\}\n" + ".\\}\n" "..\n"); if (!(flags & NOKEEP)) prints(".de " KEEP_MACRO_NAME "\n" @@ -1812,9 +1841,12 @@ void table::init_output() page. */ ".tm warning: page \\n%: table text block will not fit on one page\n" ".nf\n" + ".if \\n[ln] .nm \\n[ln]\n" + ".nr " ROW_MAX_LINE_REG " \\n[ln]\n" ".ls 1\n" "." SECTION_DIVERSION_NAME "\n" ".ls\n" + ".if \\n[ln] .nm\n" ".rm " SECTION_DIVERSION_NAME "\n" ".\\}\n" "..\n" @@ -1836,10 +1868,14 @@ void table::init_output() ".in 0\n" ".ls 1\n" ".nf\n" + ".if \\n[ln] .nm \\n[ln]\n" "." TABLE_DIVERSION_NAME "\n" ".\\}\n" ".rm " TABLE_DIVERSION_NAME "\n" ".\\}\n" + ".if \\n[ln] \\{.nm\n" + ".nr ln \\n[" ROW_MAX_LINE_REG "]\n" + ".\\}\n" "..\n"); prints(".ec\n" ".ce 0\n" @@ -2268,6 +2304,7 @@ void table::print_single_hline(int r) { prints(".vs " LINE_SEP ">?\\n[.V]u\n" ".ls 1\n" + "." REPEATED_NM_SUS_MACRO " s\n" "\\v'" BODY_DEPTH "'" "\\s[\\n[" LINESIZE_REG "]]"); if (r > nrows - 1) @@ -2304,7 +2341,8 @@ void table::print_single_hline(int r) } } prints("\\s0\n"); - prints(".ls\n" + prints("." REPEATED_NM_SUS_MACRO " r\n" + ".ls\n" ".vs\n"); } @@ -2313,6 +2351,7 @@ void table::print_double_hline(int r) prints(".vs " LINE_SEP "+" DOUBLE_LINE_SEP ">?\\n[.V]u\n" ".ls 1\n" + "." REPEATED_NM_SUS_MACRO " s\n" "\\v'" BODY_DEPTH "'" "\\s[\\n[" LINESIZE_REG "]]"); if (r > nrows - 1) @@ -2371,6 +2410,7 @@ void table::print_double_hline(int r) } } prints("\\s0\n" + "." REPEATED_NM_SUS_MACRO " r\n" ".ls\n" ".vs\n"); } @@ -2571,7 +2611,8 @@ void table::define_bottom_macro() print_single_hline(0); prints(".\\}\n"); } - prints(".ls 1\n"); + prints("." REPEATED_NM_SUS_MACRO " s\n" + ".ls 1\n"); for (vertical_rule *p = vrule_list; p; p = p->next) p->contribute_to_bottom_macro(this); if (flags & DOUBLEBOX) @@ -2588,7 +2629,8 @@ void table::define_bottom_macro() ".sp -1\n" "\\v'" BODY_DEPTH "'\\h'|\\n[TW]u'\\s[\\n[" LINESIZE_REG "]]" "\\D'l 0 |\\n[" TOP_REG "]u-1v'\\s0\n"); - prints(".ls\n"); + prints("." REPEATED_NM_SUS_MACRO " r\n" + ".ls\n"); prints(".nr " LAST_PASSED_ROW_REG " \\n[" CURRENT_ROW_REG "]\n" ".sp |\\n[" SAVED_VERTICAL_POS_REG "]u\n" "." REPEATED_VPT_MACRO " 1\n" @@ -2659,6 +2701,8 @@ void table::do_row(int r) // we might have had a .TH, for example, since we last tried if (!(flags & NOKEEP) && row_begins_section(r)) prints("." KEEP_MACRO_NAME "\n"); + prints("." REPEATED_NM_SET_MACRO " d\n" + ".nr " ROW_MAX_LINE_REG " \\n[ln]\n"); printfs(".mk %1\n", row_start_reg(r)); prints(".mk " BOTTOM_REG "\n" "." REPEATED_VPT_MACRO " 0\n"); @@ -2755,6 +2799,7 @@ void table::do_row(int r) table_entry *e = entry[r][c]; if (e) { if (e->end_row == r && e->to_simple_entry() == 0) { + prints("." REPEATED_NM_SET_MACRO " s\n"); e->position_vertically(); e->print(); prints(".nr " BOTTOM_REG " \\n[" BOTTOM_REG "]>?\\n[.d]\n"); @@ -2763,7 +2808,8 @@ void table::do_row(int r) c = e->end_col; } } - prints("." REPEATED_VPT_MACRO " 1\n" + prints("." REPEATED_NM_SET_MACRO " m\n" + "." REPEATED_VPT_MACRO " 1\n" ".sp |\\n[" BOTTOM_REG "]u\n" "\\*[" TRANSPARENT_STRING_NAME "].nr " NEED_BOTTOM_RULE_REG " 1\n"); if (r != nrows - 1 && (flags & ALLBOX)) { @@ -2791,6 +2837,7 @@ void table::do_row(int r) if (!(flags & NOKEEP) && row_ends_section(r)) prints("." RELEASE_MACRO_NAME "\n"); } + prints(".if \\n[ln] .nr ln \\n[" ROW_MAX_LINE_REG "]\n"); } void table::do_top() @@ -2799,7 +2846,8 @@ void table::do_top() if (!(flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX))) prints("." TABLE_KEEP_MACRO_NAME "\n"); if (flags & DOUBLEBOX) { - prints(".ls 1\n" + prints("." REPEATED_NM_SUS_MACRO " s\n" + ".ls 1\n" ".vs " LINE_SEP ">?\\n[.V]u\n" "\\v'" BODY_DEPTH "'\\s[\\n[" LINESIZE_REG "]]\\D'l \\n[TW]u 0'\\s0\n" ".vs\n" @@ -2813,7 +2861,8 @@ void table::do_top() "\n", column_divide_reg(0), column_divide_reg(ncolumns)); - prints(".ls\n" + prints("." REPEATED_NM_SUS_MACRO " r\n" + ".ls\n" ".vs\n"); } else if (flags & (ALLBOX | BOX)) { @@ -2836,6 +2885,10 @@ void table::do_bottom() ".T#\n"); if (!(flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX))) prints("." TABLE_RELEASE_MACRO_NAME "\n"); + else + prints(".if \\n[ln] \\{.nm\n" + ".nr ln \\n[" ROW_MAX_LINE_REG "]\n" + ".\\}\n"); if (flags & DOUBLEBOX) prints(".sp " DOUBLE_LINE_SEP "\n"); prints("." RESET_MACRO_NAME "\n" diff --git a/tmac/e.tmac b/tmac/e.tmac index a5bfaabb..af0a28e8 100644 --- a/tmac/e.tmac +++ b/tmac/e.tmac @@ -253,7 +253,7 @@ . sp |\\n(tmu \" move to top of text .ev .mk _k \" for columned output -.if \\n(?n .nm 1 \" restore line numbering if n1 mode +.if \\n(?n=1 .nm 1 \" restore line numbering if n1 mode .nr $c 1 \" set first column .if \n@>4 .tm -- @h >> .ns nl=\\n(nl %=\\n% _k=\\n(_k tm=\\n(tm .ie \\n(?s \ @@ -297,9 +297,13 @@ .if \\n(?T \ \{\ . nr _i \\n(.i +. if \\n(?n \ +. nm \\n(ln . in 0 . |h\" \" output the table header . in \\n(_iu +. if \\n(?n \ +. nm . rr _i . mk #T \" for tbl commands . ns @@ -351,7 +355,11 @@ .in 0 .if \n@>2 .tm @o last printed text = \\n(nl placing @r trap at -\\n(_B .wh -\\n(_Bu @r +.if \\n(?n \ +. nm \\n(ln .|f +.if \\n(?n \ +. nm .fi .if \n@>2 .tm @o triggered @r (?o) = \\n(?o .if \\n(?o \ @@ -394,9 +402,13 @@ . sz \\n(tp\" \" set header/footer type fonts, etc. . @F \\n(tf . lt \\n(_Lu \" make title span entire page +. if \\n(?n \ +. nm \\n(ln . nf . \\$1 . br +. if \\n(?n \ +. nm .\} .. . @@ -506,16 +518,46 @@ . .de n1 \" *** line numbering 1 .nm 1 -.xl -\w'0000'u +.ll -\w'0000'u .nr ?n 1 .. . .de n2 \" *** line numbering 2 -.nm \\$1 .ie \\n(.$ \ -. xl -\w'0000'u +\{\ +. ie !`\\$2`c` \ +. po -\w'0000'u +. el \ +. ll -\w'0000'u +. ie \\B`\\$1` \ +\{\ +. ds |i \\$1 +. ds |j \\$1 +. do substring |i 0 0 \" pick off leading char and rest to check +. do substring |j 1 \" for +N / -N +. ie `\\*(|i`+` \ +. nr ln (\\n[_ln])+\\*(|j +. el \ +. ie `\\*(|i`-` \ +. nr ln (\\n[_ln])-\\*(|j +. el \ +. nr ln \\$1 \" unsigned N +. nm \\n(ln +. nr ?n 2 +. rm |i |j +.\} +. el \ +. tm Line \\n(.c -- Bad .n2 value +.\} .el \ -. xl \\n($lu +\{\ +. nm +. nr _ln \\n(ln +. po +\w'0000'u +. ll \\n($lu +. nr ?n 0 +. nr ln 0 +.\} .. . .de pa \" *** new page @@ -914,7 +956,11 @@ .ls 1 .in 0 .sp \\n(zsu +.if \\n(?n \ +. nm \\n(ln .\\$1 +.if \\n(?n \ +. nm .ec .br .rm \\$1 @@ -942,15 +988,8 @@ .@) .if (\\n(bt=0):(\\n(.t<\\n(bt) \ . ne \\n(dnu \" make it all on one page -.ls 1 -.nf -.|k -.ec -.fi -.in 0 -.xl \\n($lu -.ev -.rm |k +.@k |k +.ev \" return from display environment .sp \\n(bsu+\\n(.Lv-1v .. . @@ -992,6 +1031,7 @@ . .de (c \" *** begin block centered text .if "\\n(.z"|c" .tm Line \\n(c. -- Nested .(c requests +.if \\n(?n .nm .di |c .. . @@ -1004,11 +1044,15 @@ .ls 1 .in (\\n(.lu-\\n(.iu-\\n(dlu)/2u .if \n@>4 .tm -- .)c << .in .l=\\n(.l .i=\\n(.i dl=\\n(dl +.if \\n(?n \ +. nm \\n(ln .nf .|c .ec .in .ls +.if \\n(?n \ +. nm .ev .rm |c .. @@ -1025,10 +1069,14 @@ .in +\\n(qiu .xl -\\n(qiu .sz \\n(qp +.if \\n(?n \ +. nm \\n(ln .. . .de )q \" *** end block quote .br +.if \\n(?n \ +. nm .ev .sp \\n(qsu+\\n(.Lv-1v .nr ?k 0 @@ -1039,11 +1087,15 @@ .sp \\n(bsu .@D 3 \\$1 \\$2 .@M +.if \\n(?n \ +. nm \\n(ln .if '\*(.T'html' .sp \\n(bsu .. . .de )l \" *** end list .br +.if \\n(?n \ +. nm .ev .sp \\n(bsu+\\n(.Lv-1v .nr ?k 0 @@ -1123,7 +1175,11 @@ . tl """\\*(|p" . rt \\n(_qu .\} +.if \\n(?n \ +. nm \\n(ln .|e +.if \\n(?n \ +. nm .sp |\\n(_qu+\\n(_Qu .sp \\n(esu+\\n(.Lv-1v .rr _q @@ -1157,12 +1213,14 @@ .de TH \" *** end header part of table .nr T. 0 .T# 0 +.if \\n(?n \!.nm .di .nr _T \\n(?T .nr ?T 0 .ne \\n(dnu+1v .nr ?T \\n(_T .nr _i \\n(.i +.if \\n(?n .nm \\n(ln .in 0 .|h\" \" put in the initial header .in \\n(_iu @@ -1220,9 +1278,41 @@ .ne \\$1u .nr g7 \\n(.u .ls 1 +.if \\n(?n \ +\{\ +. de PS_nm_check && \" define macro to emit .nm at top diversion +. if \n@>4 .tm -- PS: \\\\$1 \\\\$2 .z=\\\\n(.z PS_nm_cnt=\\\\n[PS_nm_cnt] +. \" \" multiple .PS/.PE in a keep. +. if `\\\\$2`init` \ +. do nr PS_nm_cnt \\\\n[PS_nm_cnt]+1 +. ie `\\\\n(.z`` \ +\{\ +. if `\\\\$1`suspend` \ +. nm +. if `\\\\$1`resume` \ +\{\ +. nm \\\\n(ln +. do nr PS_nm_cnt \\\\n[PS_nm_cnt]-1 +. do if !\\\\n[PS_nm_cnt] \ +\{\ +. do rm PS_nm_check +. do rr PS_nm_cnt +.\} +.\} +.\} +.el \!.PS_nm_check \\\\$1 +.&& +. mk _q \" emit a single numbered line for PS picture +. rs +\&\ +. br +. rt \\n(_qu +. PS_nm_check suspend init +.\} .. . .de PE \" *** end picture +.if \\n(?n .PS_nm_check resume .ls .in .if \\n(g7 .fi @@ -1380,6 +1470,7 @@ . nr _D \\n(dn . nr _0 1v+\\n(nlu . ev 2 +. nm . da |f . in 0 . xl \\n($lu-\\n(fuu @@ -1420,6 +1511,7 @@ .el \ \{\ . ev 2 +. nm . in 0 . xl \\n($lu-\\n(fuu . @F \\n(ff |