w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit a7996755f3f820b32de2f8abe19401c3a889c329
parent 8cb1dd92ec5efce6dd7d299963ebdb6a7d554f8f
Author: ukai <ukai>
Date:   Tue, 13 May 2003 17:08:19 +0000

[w3m-dev 03898] Re: table rendering
* table.c (check_relative_width): added
	(set_table_matrix): use check_relative_width
From: Akinori Ito <aito@fw.ipsj.or.jp>

Diffstat:
MChangeLog | 6++++++
Mtable.c | 77+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2003-05-14 Akinori Ito <aito@fw.ipsj.or.jp> + + * [w3m-dev 03898] Re: table rendering + * table.c (check_relative_width): added + (set_table_matrix): use check_relative_width + 2003-05-13 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> * [w3m-dev 03896] html_quote in textarea in frame diff --git a/table.c b/table.c @@ -3491,6 +3491,81 @@ set_table_matrix0(struct table *t, int maxwidth) } void +check_relative_width(struct table *t,int maxwidth) +{ + int i; + double rel_total = 0; + int size = t->maxcol+1; + double *rcolwidth = New_N(double,size); + struct table_cell *cell = &t->cell; + int n_leftcol = 0; + + for (i = 0; i < size; i++) + rcolwidth[i] = 0; + + for (i = 0; i < size; i++) { + if (t->fixed_width[i] < 0) + rcolwidth[i] = -(double)t->fixed_width[i]/100.0; + else if (t->fixed_width[i] > 0) + rcolwidth[i] = (double)t->fixed_width[i]/maxwidth; + else + n_leftcol++; + } + for (i = 0; i <= cell->maxcell; i++) { + if (cell->fixed_width[i] < 0) { + double w = -(double)cell->fixed_width[i]/100.0; + double r; + int j,k; + int n_leftcell = 0; + k = cell->col[i]; + r = 0.0; + for (j = 1; j < cell->colspan[i]; j++) { + if (rcolwidth[j+k] > 0) + r += rcolwidth[j+k]; + else + n_leftcell++; + } + if (w < r || (w == r && n_leftcell > 0)) { + cell->fixed_width[i] = -100*r; + } + else { + for (j = 1; j < cell->colspan[i]; j++) { + if (rcolwidth[j+k] == 0) + rcolwidth[j+k] = (w-r)/n_leftcell; + } + } + } + else if (cell->fixed_width[i] > 0) { + /* todo */ + } + } + /* sanity check */ + for (i = 0; i < size; i++) + rel_total += rcolwidth[i]; + + if ((n_leftcol == 0 && rel_total < 0.9) || 1.1 < rel_total) { + for (i = 0; i < size; i++) { + rcolwidth[i] /= rel_total; + } + for (i = 0; i < size; i++) { + if (t->fixed_width[i] < 0) + t->fixed_width[i] = -rcolwidth[i]*100; + } + for (i = 0; i <= cell->maxcell; i++) { + if (cell->fixed_width[i] < 0) { + double r; + int j,k; + k = cell->col[i]; + r = 0.0; + for (j = 1; j < cell->colspan[i]; j++) + r += rcolwidth[j+k]; + cell->fixed_width[i] = -r*100; + } + } + } +} + +void set_table_matrix(struct table *t, int width) { int size = t->maxcol + 1; @@ -3510,6 +3585,8 @@ set_table_matrix(struct table *t, int width) v_set_val(t->vector, i, 0.); } + check_relative_width(t,width); + for (i = 0; i < size; i++) { if (t->fixed_width[i] > 0) { a = max(t->fixed_width[i], t->minimum_width[i]);