Index: src/preproc/tbl/main.cpp =================================================================== RCS file: /sources/groff/groff/src/preproc/tbl/main.cpp,v retrieving revision 1.8 diff -u -r1.8 main.cpp --- src/preproc/tbl/main.cpp 16 Jun 2005 09:47:49 -0000 1.8 +++ src/preproc/tbl/main.cpp 19 Jun 2006 10:16:19 -0000 @@ -1,5 +1,6 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004, 2005 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, + 2004, 2005, 2006 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -597,6 +598,16 @@ put_string(macro, stderr); putc(' ', stderr); } + if (!bg_color.empty()) { + put_string("bg", stderr); + put_string(bg_color, stderr); + putc(' ', stderr); + } + if (!fg_color.empty()) { + put_string("fg", stderr); + put_string(fg_color, stderr); + putc(' ', stderr); + } switch (vertical_alignment) { case entry_modifier::CENTER: break; @@ -742,6 +753,45 @@ putc(',', stderr); } +/* + * read_string - returns a string which may be terminated by + * white space or delim1 or delim2. + */ + +string read_string(table_input &in, const char delim1, + const char delim2) +{ + string result; + char c; + + for (;;) { + c = in.get(); + if (c == EOF || c == ' ' || c == '\t') { + string message; + + message = "missing `"; + message += char(delim1); + message += "'"; + if (delim1 != delim2) { + message = " or `"; + message += char(delim2); + message += "'"; + } + message += char('\0'); + error(message.contents()); + in.unget(c); + return result; + } + if (c == delim1 || c == delim2) { + in.unget(c); + return result; + } + result += char(c); + } + in.unget(c); + return result; +} + // Return zero if we should give up on this table. // If this is a continuation format line, current_format will be the current // format line. @@ -886,18 +936,10 @@ break; } if (c == '(') { - for (;;) { + list->font = read_string(in, ')', ')'); + c = in.get(); + if (c == ')') c = in.get(); - if (c == EOF || c == ' ' || c == '\t') { - error("missing `)'"); - break; - } - if (c == ')') { - c = in.get(); - break; - } - list->font += char(c); - } } else { list->font = c; @@ -910,6 +952,38 @@ } } break; + case 'm': + case 'M': + do { + c = in.get(); + } while (c == ' ' || c == '\t'); + if (c == EOF) { + error("missing background color"); + break; + } + if (c == '(') { + list->bg_color = read_string(in, ',', ')'); + c = in.get(); + if (c == ',') { + list->fg_color = read_string(in, ')', ')'); + c = in.get(); + } + if (c == ')') + c = in.get(); + else + error ("expecting ) at close of color specifier"); + } + 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 'x': case 'X': do { @@ -920,18 +994,10 @@ break; } if (c == '(') { - for (;;) { + list->macro = read_string(in, ')', ')'); + c = in.get(); + if (c == ')') 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; @@ -1587,4 +1653,3 @@ fatal("output error"); return 0; } - Index: src/preproc/tbl/table.cpp =================================================================== RCS file: /sources/groff/groff/src/preproc/tbl/table.cpp,v retrieving revision 1.7 diff -u -r1.7 table.cpp --- src/preproc/tbl/table.cpp 26 May 2005 21:02:01 -0000 1.7 +++ src/preproc/tbl/table.cpp 19 Jun 2006 10:16:20 -0000 @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2003, 2004 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2003, 2004, 2006 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -689,9 +689,20 @@ prints("-2n"); prints("\n"); prints(".cp \\n(" COMPATIBLE_REG "\n"); + if (!mod->bg_color.empty()) + printfs(".br\n.nop \\M[%1]\n.sp -1\n", mod->bg_color); + if (!mod->fg_color.empty()) + printfs(".br\n.nop \\m[%1]\n.sp -1\n", mod->fg_color); + set_modifier(mod); set_location(); prints(contents); + + if (!mod->bg_color.empty()) + printfs(".br\n.nop \\M[]\n.sp -1\n"); + if (!mod->fg_color.empty()) + printfs(".br\n.nop \\m[]\n.sp -1\n"); + prints(".br\n.di\n.cp 0\n"); if (!mod->zero_width) { if (alphabetic) { @@ -982,6 +993,10 @@ prints('-'); printfs("%1]", as_string(m->point_size.val)); } + if (!m->bg_color.empty()) + printfs("\\M[%1]", m->bg_color); + if (!m->fg_color.empty()) + printfs("\\m[%1]", m->fg_color); if (m->stagger) prints("\\v'-.5v'"); } @@ -992,6 +1007,10 @@ prints("\\f[\\n[" SAVED_FONT_REG "]]"); if (m->point_size.val != 0) prints("\\s[\\n[" SAVED_SIZE_REG "]]"); + if (!m->bg_color.empty()) + prints("\\M[]"); + if (!m->fg_color.empty()) + prints("\\m[]"); if (m->stagger) prints("\\v'.5v'"); } @@ -2695,6 +2714,73 @@ //printfs(".mk %1\n", row_top_reg(0)); } +void table::do_move(table_entry *e) +{ + printfs("\\v'|\\n[tbl*top]u"); + printfs("+\\n[%1]u+" BODY_DEPTH , row_top_reg(e->start_row)); + if (e->start_row > 0) + if (flags & DOUBLEBOX) + printfs("-\\n[%1]u+" LINE_SEP "+" DOUBLE_LINE_SEP , row_top_reg(0)); + else + printfs("-\\n[%1]u+" LINE_SEP , row_top_reg(0)); + printfs("'\\h'|\\n[%1]u'", column_divide_reg(e->start_col)); +} + +void table::do_background_row(int r) +{ + int first_start_row = r; + int c; + + for (c = 0; c < ncolumns; c++) { + table_entry *e = entry[r][c]; + if (e) { + if (e && e->mod && !e->mod->bg_color.empty()) { + printfs(".nop \\&"); + do_move(e); + set_inline_modifier(e->mod); + if (e->end_row+1 == nrows) { + printfs("\\D'P (\\n[%1]u-\\n[%2]u) 0u 0u (\\n[%3]u-\\n[%4]u+" LINE_SEP ")", + column_divide_reg(e->start_col+1), + column_divide_reg(e->start_col), + row_top_reg(e->end_row+1), row_top_reg(e->start_row)); + printfs(" -(\\n[%1]u-\\n[%2]u) 0u 0u", + column_divide_reg(e->start_col+1), + column_divide_reg(e->start_col)); + printfs(" -(\\n[%1]u-\\n[%2]u+" LINE_SEP ")'", + row_top_reg(e->end_row+1), row_top_reg(e->start_row)); + } else { + printfs("\\D'P (\\n[%1]u-\\n[%2]u) 0u 0u (\\n[%3]u-\\n[%4]u)", + column_divide_reg(e->start_col+1), + column_divide_reg(e->start_col), + row_top_reg(e->end_row+1), row_top_reg(e->start_row)); + printfs(" -(\\n[%1]u-\\n[%2]u) 0u 0u", + column_divide_reg(e->start_col+1), + column_divide_reg(e->start_col)); + printfs(" -(\\n[%1]u-\\n[%2]u)'", + row_top_reg(e->end_row+1), row_top_reg(e->start_row)); + } + restore_inline_modifier(e->mod); + printfs("\n.sp -1\n"); + } + } + c = e->end_col; + } +} + +void table::do_background() +{ + printfs(".di\n" + ".nr tbl*vert \\n[dn]u\n"); + if (flags & CENTER) + prints(".in +(u;\\n[.l]-\\n[.i]-\\n[TW]/2>?-\\n[.i])\n"); + + for (int i = 0; i < nrows; i++) + do_background_row(i); + + if (flags & CENTER) + printfs(".in\n"); +} + void table::do_bottom() { // print stuff after last row @@ -2714,6 +2800,7 @@ prints("." RESET_MACRO_NAME "\n" ".fc\n" ".cp \\n(" COMPATIBLE_REG "\n"); + do_background(); } int table::get_nrows() @@ -2775,4 +2862,3 @@ } } } - Index: src/preproc/tbl/table.h =================================================================== RCS file: /sources/groff/groff/src/preproc/tbl/table.h,v retrieving revision 1.8 diff -u -r1.8 table.h --- src/preproc/tbl/table.h 26 May 2005 21:02:01 -0000 1.8 +++ src/preproc/tbl/table.h 19 Jun 2006 10:16:20 -0000 @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004 +/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -50,6 +50,8 @@ inc_number vertical_spacing; string font; string macro; + string bg_color; + string fg_color; enum { CENTER, TOP, BOTTOM } vertical_alignment; char zero_width; char stagger; @@ -114,6 +116,9 @@ void compute_separation_factor(); void compute_column_positions(); void do_row(int); + void do_background_row(int); + void do_background(); + void do_move(table_entry *); void init_output(); void add_stuff(stuff *); void do_top(); Index: src/preproc/tbl/tbl.man =================================================================== RCS file: /sources/groff/groff/src/preproc/tbl/tbl.man,v retrieving revision 1.14 diff -u -r1.14 tbl.man --- src/preproc/tbl/tbl.man 13 Mar 2006 06:49:22 -0000 1.14 +++ src/preproc/tbl/tbl.man 19 Jun 2006 10:16:20 -0000 @@ -271,6 +271,18 @@ follows. . .TP +m,M +Background and foreground color. +Must be followed either by a +.BR @g@troff (@MAN1EXT@) +defined color in parentheses. +The first color is the background color and the optional +second color separated by a comma is the foreground color. +For example m(red,blue) indicates that this column or cell +will be drawn using a red background and blue text. +Whereas m(red) indicates this cell or column is to be +drawn using a red background. +.TP p,P Followed by a number, this does a point size change for the affected fields. If signed, the current point size is incremented or decremented (using a Index: tmac/s.tmac =================================================================== RCS file: /sources/groff/groff/tmac/s.tmac,v retrieving revision 1.25 diff -u -r1.25 s.tmac --- tmac/s.tmac 26 May 2005 21:02:01 -0000 1.25 +++ tmac/s.tmac 19 Jun 2006 10:16:20 -0000 @@ -1750,6 +1750,10 @@ .. .de @TS .sp \\n[DD]u +.mk tbl*top +.br +.di tbl*contents +.br .if '\\$1'H' .di tbl*header-div .HTML-IMAGE .. @@ -1793,6 +1797,14 @@ .ie '\\n(.z'tbl*header-div' .@error-recover .TS H but no .TH before .TE .el \{\ . nr tbl*have-header 0 +. rt \\n[tbl*top]u +. sp |\\n[tbl*top]u +. sp +. ne \\n[tbl*vert]u +. ev tbl*nf +. nf +. tbl*contents +. ev . if !'\*(.T'html' .sp \\n[DD]u .\} . HTML-IMAGE-END