version 1.12, 2011/01/07 13:20:58 |
version 1.14, 2011/01/08 17:00:27 |
|
|
#include "out.h" |
#include "out.h" |
#include "term.h" |
#include "term.h" |
|
|
/* FIXME: `n' modifier doesn't always do the right thing. */ |
|
/* FIXME: `n' modifier doesn't use the cell-spacing buffer. */ |
|
|
|
static size_t term_tbl_len(size_t, void *); |
static size_t term_tbl_len(size_t, void *); |
static size_t term_tbl_strlen(const char *, void *); |
static size_t term_tbl_strlen(const char *, void *); |
static void tbl_char(struct termp *, char, size_t); |
static void tbl_char(struct termp *, char, size_t); |
Line 272 tbl_data(struct termp *tp, const struct tbl *tbl, |
|
Line 269 tbl_data(struct termp *tp, const struct tbl *tbl, |
|
break; |
break; |
} |
} |
|
|
pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT; |
pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT; |
|
|
switch (pos) { |
switch (pos) { |
case (TBL_CELL_HORIZ): |
case (TBL_CELL_HORIZ): |
Line 344 tbl_literal(struct termp *tp, const struct tbl_dat *dp |
|
Line 341 tbl_literal(struct termp *tp, const struct tbl_dat *dp |
|
{ |
{ |
size_t padl, padr, ssz; |
size_t padl, padr, ssz; |
enum tbl_cellt pos; |
enum tbl_cellt pos; |
|
const char *str; |
|
|
padl = padr = 0; |
padl = padr = 0; |
|
|
pos = dp->layout ? dp->layout->pos : TBL_CELL_LEFT; |
pos = dp && dp->layout ? dp->layout->pos : TBL_CELL_LEFT; |
|
str = dp && dp->string ? dp->string : ""; |
|
|
ssz = term_len(tp, 1); |
ssz = term_len(tp, 1); |
|
|
switch (pos) { |
switch (pos) { |
case (TBL_CELL_LONG): |
case (TBL_CELL_LONG): |
padl = ssz; |
padl = ssz; |
padr = col->width - term_strlen(tp, dp->string) - ssz; |
padr = col->width - term_strlen(tp, str) - ssz; |
break; |
break; |
case (TBL_CELL_CENTRE): |
case (TBL_CELL_CENTRE): |
padl = col->width - term_strlen(tp, dp->string); |
padl = col->width - term_strlen(tp, str); |
if (padl % 2) |
if (padl % 2) |
padr++; |
padr++; |
padl /= 2; |
padl /= 2; |
padr += padl; |
padr += padl; |
break; |
break; |
case (TBL_CELL_RIGHT): |
case (TBL_CELL_RIGHT): |
padl = col->width - term_strlen(tp, dp->string); |
padl = col->width - term_strlen(tp, str); |
break; |
break; |
default: |
default: |
padr = col->width - term_strlen(tp, dp->string); |
padr = col->width - term_strlen(tp, str); |
break; |
break; |
} |
} |
|
|
tbl_char(tp, ASCII_NBRSP, padl); |
tbl_char(tp, ASCII_NBRSP, padl); |
term_word(tp, dp->string); |
term_word(tp, str); |
tbl_char(tp, ASCII_NBRSP, padr); |
tbl_char(tp, ASCII_NBRSP, padr); |
} |
} |
|
|
Line 391 tbl_number(struct termp *tp, const struct tbl *tbl, |
|
Line 391 tbl_number(struct termp *tp, const struct tbl *tbl, |
|
* and the maximum decimal; right-pad by the remaining amount. |
* and the maximum decimal; right-pad by the remaining amount. |
*/ |
*/ |
|
|
str = ""; |
str = dp && dp->string ? dp->string : ""; |
if (dp->string) |
|
str = dp->string; |
|
|
|
sz = term_strlen(tp, str); |
sz = term_strlen(tp, str); |
|
|
Line 418 tbl_number(struct termp *tp, const struct tbl *tbl, |
|
Line 416 tbl_number(struct termp *tp, const struct tbl *tbl, |
|
padl = col->decimal - d; |
padl = col->decimal - d; |
|
|
tbl_char(tp, ASCII_NBRSP, padl); |
tbl_char(tp, ASCII_NBRSP, padl); |
term_word(tp, dp->string); |
term_word(tp, str); |
tbl_char(tp, ASCII_NBRSP, col->width - sz - padl); |
tbl_char(tp, ASCII_NBRSP, col->width - sz - padl); |
} |
} |
|
|