From f39b8cfad4e6ab2c55659e7d881d0a482fe63cf9 Mon Sep 17 00:00:00 2001 From: Werner LEMBERG Date: Sun, 17 Aug 2003 05:21:56 +0000 Subject: [PATCH] Add key character `x' to tbl which makes tbl call a user-defined macro on a table cell. * src/preproc/tbl/table.h (entry_modifier): Add `macro'. * src/preproc/tbl/table.cpp (block_entry::do_divert): Call `set_modifier' after printing the compatibility request. (set_modifier): Print call to `m->macro' if not empty. * src/preproc/tbl/main.cpp (entry_format::debug_print): Handle `macro'. (process_format): Implement cases `x' and `X'. * src/preproc/tbl/tbl.man, NEWS: Updated. --- ChangeLog | 14 ++++++++++++++ NEWS | 6 ++++++ src/preproc/tbl/main.cpp | 39 +++++++++++++++++++++++++++++++++++++++ src/preproc/tbl/table.cpp | 4 +++- src/preproc/tbl/table.h | 1 + src/preproc/tbl/tbl.man | 27 +++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b9923898..e04135b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-08-26 Heinz-Jürgen Oertel + + Add key character `x' to tbl which makes tbl call a user-defined + macro on a table cell. + + * src/preproc/tbl/table.h (entry_modifier): Add `macro'. + * src/preproc/tbl/table.cpp (block_entry::do_divert): Call + `set_modifier' after printing the compatibility request. + (set_modifier): Print call to `m->macro' if not empty. + * src/preproc/tbl/main.cpp (entry_format::debug_print): Handle + `macro'. + (process_format): Implement cases `x' and `X'. + * src/preproc/tbl/tbl.man, NEWS: Updated. + 2003-08-15 Werner LEMBERG * doc/groff.texinfo: Minor fixes. diff --git a/NEWS b/NEWS index 1462c0d0..062d01cf 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,12 @@ ___ o Dashed and dotted ellipses have been implemented. +Tbl +--- + +o New key character `x' to make tbl call a user-defined macro on a table + cell. Patch by Heinz-Jürgen Oertel . + Grap2graph ---------- diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp index fe3aabf9..8984786e 100644 --- a/src/preproc/tbl/main.cpp +++ b/src/preproc/tbl/main.cpp @@ -573,6 +573,11 @@ void entry_format::debug_print() const put_string(font, stderr); putc(' ', stderr); } + if (!macro.empty()) { + putc('m', stderr); + put_string(macro, stderr); + putc(' ', stderr); + } switch (vertical_alignment) { case entry_modifier::CENTER: break; @@ -886,6 +891,40 @@ format *process_format(table_input &in, options *opt, } } break; + case 'x': + case 'X': + do { + c = in.get(); + } while (c == ' ' || c == '\t'); + if (c == EOF) { + error("missing macro name"); + break; + } + if (c == '(') { + for (;;) { + c = in.get(); + if (c == EOF || c == ' ' || c == '\t') { + error("missing `)'"); + break; + } + if (c == ')') { + c = in.get(); + break; + } + list->macro += char(c); + } + } + else { + list->macro = c; + char cc = c; + c = in.get(); + if (!csdigit(cc) + && c != EOF && c != ' ' && c != '\t' && c != '.' && c != '\n') { + list->macro += char(c); + c = in.get(); + } + } + break; case 'v': case 'V': c = in.get(); diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp index 32068c36..b93edc02 100644 --- a/src/preproc/tbl/table.cpp +++ b/src/preproc/tbl/table.cpp @@ -687,8 +687,8 @@ void block_entry::do_divert(int alphabetic, int ncols, const string *mw, if (alphabetic) prints("-2n"); prints("\n"); - set_modifier(mod); prints(".cp \\n(" COMPATIBLE_REG "\n"); + set_modifier(mod); set_location(); prints(contents); prints(".br\n.di\n.cp 0\n"); @@ -965,6 +965,8 @@ void set_modifier(const entry_modifier *m) prints('-'); printfs("%1\n", as_string(m->vertical_spacing.val)); } + if (!m->macro.empty()) + printfs(".%1\n", m->macro); } void set_inline_modifier(const entry_modifier *m) diff --git a/src/preproc/tbl/table.h b/src/preproc/tbl/table.h index 69959b89..16540103 100644 --- a/src/preproc/tbl/table.h +++ b/src/preproc/tbl/table.h @@ -41,6 +41,7 @@ struct entry_modifier { inc_number point_size; inc_number vertical_spacing; string font; + string macro; enum { CENTER, TOP, BOTTOM } vertical_alignment; char zero_width; char stagger; diff --git a/src/preproc/tbl/tbl.man b/src/preproc/tbl/tbl.man index 1ee5a5db..b78c7fca 100644 --- a/src/preproc/tbl/tbl.man +++ b/src/preproc/tbl/tbl.man @@ -287,6 +287,33 @@ If used multiple times to specify the width for a particular column, the last entry takes effect. . .TP +x,X +This is a GNU tbl extension. +Either of these specifiers may be followed by a macro name +(either one or two characters long), +or long name in parentheses. +A one-letter macro name must be separated by one or more blanks +from whatever follows. +The macro which name can be specified here +must be defined before creating the table. +It is called just before the table's cell text is output. +As implemented currently, this macro is only called if block input is used, +that is, text between `T{' and `T}'. +The macro should contain only simple +.B troff +requests to change the text block formatting, like text adjustment, +hyphenation, size, or font. +The macro is called +.I after +other cell modifications like +.B b , +.B f +or +.B v +are output. +Thus the macro can overwrite other modification specifiers. +. +.TP e,E Make equally-spaced columns. . -- 2.11.4.GIT