version 1.116, 2010/04/06 16:27:53 |
version 1.130, 2010/05/24 21:51:20 |
|
|
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
#include <stdint.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <string.h> |
#include <string.h> |
|
|
|
#include "mandoc.h" |
#include "out.h" |
#include "out.h" |
#include "term.h" |
#include "term.h" |
#include "mdoc.h" |
#include "mdoc.h" |
Line 58 static int arg_hasattr(int, const struct mdoc_node * |
|
Line 60 static int arg_hasattr(int, const struct mdoc_node * |
|
static int arg_getattrs(const int *, int *, size_t, |
static int arg_getattrs(const int *, int *, size_t, |
const struct mdoc_node *); |
const struct mdoc_node *); |
static int arg_getattr(int, const struct mdoc_node *); |
static int arg_getattr(int, const struct mdoc_node *); |
static int arg_listtype(const struct mdoc_node *); |
static int arg_disptype(const struct mdoc_node *); |
static void print_bvspace(struct termp *, |
static void print_bvspace(struct termp *, |
const struct mdoc_node *, |
const struct mdoc_node *, |
const struct mdoc_node *); |
const struct mdoc_node *); |
Line 93 static void termp_sq_post(DECL_ARGS); |
|
Line 95 static void termp_sq_post(DECL_ARGS); |
|
static void termp_ss_post(DECL_ARGS); |
static void termp_ss_post(DECL_ARGS); |
static void termp_vt_post(DECL_ARGS); |
static void termp_vt_post(DECL_ARGS); |
|
|
static int termp__t_pre(DECL_ARGS); |
|
static int termp_an_pre(DECL_ARGS); |
static int termp_an_pre(DECL_ARGS); |
static int termp_ap_pre(DECL_ARGS); |
static int termp_ap_pre(DECL_ARGS); |
static int termp_aq_pre(DECL_ARGS); |
static int termp_aq_pre(DECL_ARGS); |
Line 188 static const struct termact termacts[MDOC_MAX] = { |
|
Line 189 static const struct termact termacts[MDOC_MAX] = { |
|
{ NULL, termp____post }, /* %O */ |
{ NULL, termp____post }, /* %O */ |
{ NULL, termp____post }, /* %P */ |
{ NULL, termp____post }, /* %P */ |
{ NULL, termp____post }, /* %R */ |
{ NULL, termp____post }, /* %R */ |
{ termp__t_pre, termp____post }, /* %T */ |
{ termp_under_pre, termp____post }, /* %T */ |
{ NULL, termp____post }, /* %V */ |
{ NULL, termp____post }, /* %V */ |
{ NULL, NULL }, /* Ac */ |
{ NULL, NULL }, /* Ac */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
{ termp_aq_pre, termp_aq_post }, /* Ao */ |
Line 272 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
Line 273 terminal_mdoc(void *arg, const struct mdoc *mdoc) |
|
p = (struct termp *)arg; |
p = (struct termp *)arg; |
|
|
p->overstep = 0; |
p->overstep = 0; |
p->maxrmargin = 78; |
p->maxrmargin = p->defrmargin; |
|
p->tabwidth = 5; |
|
|
if (NULL == p->symtab) |
if (NULL == p->symtab) |
switch (p->enc) { |
switch (p->enc) { |
Line 336 print_mdoc_node(DECL_ARGS) |
|
Line 338 print_mdoc_node(DECL_ARGS) |
|
if (termacts[n->tok].post) |
if (termacts[n->tok].post) |
(*termacts[n->tok].post)(p, &npair, m, n); |
(*termacts[n->tok].post)(p, &npair, m, n); |
|
|
|
if (MDOC_EOS & n->flags) |
|
p->flags |= TERMP_SENTENCE; |
|
|
p->offset = offset; |
p->offset = offset; |
p->rmargin = rmargin; |
p->rmargin = rmargin; |
} |
} |
Line 421 print_mdoc_head(DECL_ARGS) |
|
Line 426 print_mdoc_head(DECL_ARGS) |
|
strlcat(buf, ")", BUFSIZ); |
strlcat(buf, ")", BUFSIZ); |
} |
} |
|
|
snprintf(title, BUFSIZ, "%s(%d)", m->title, m->msec); |
snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec); |
|
|
p->offset = 0; |
p->offset = 0; |
p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2; |
p->rmargin = (p->maxrmargin - strlen(buf) + 1) / 2; |
Line 479 a2width(const struct mdoc_argv *arg, int pos) |
|
Line 484 a2width(const struct mdoc_argv *arg, int pos) |
|
|
|
|
|
static int |
static int |
arg_listtype(const struct mdoc_node *n) |
arg_disptype(const struct mdoc_node *n) |
{ |
{ |
int i, len; |
int i, len; |
|
|
Line 487 arg_listtype(const struct mdoc_node *n) |
|
Line 492 arg_listtype(const struct mdoc_node *n) |
|
|
|
len = (int)(n->args ? n->args->argc : 0); |
len = (int)(n->args ? n->args->argc : 0); |
|
|
for (i = 0; i < len; i++) |
for (i = 0; i < len; i++) |
switch (n->args->argv[i].arg) { |
switch (n->args->argv[i].arg) { |
case (MDOC_Bullet): |
case (MDOC_Centred): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (MDOC_Ragged): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Enum): |
case (MDOC_Filled): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (MDOC_Unfilled): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Tag): |
case (MDOC_Literal): |
/* FALLTHROUGH */ |
|
case (MDOC_Inset): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Diag): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Item): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Column): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Hang): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Ohang): |
|
return(n->args->argv[i].arg); |
return(n->args->argv[i].arg); |
default: |
default: |
break; |
break; |
Line 621 print_bvspace(struct termp *p, |
|
Line 614 print_bvspace(struct termp *p, |
|
|
|
/* A `-column' does not assert vspace within the list. */ |
/* A `-column' does not assert vspace within the list. */ |
|
|
if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Column, bl)) |
if (MDOC_Bl == bl->tok && LIST_column == bl->data.list) |
if (n->prev && MDOC_It == n->prev->tok) |
if (n->prev && MDOC_It == n->prev->tok) |
return; |
return; |
|
|
/* A `-diag' without body does not vspace. */ |
/* A `-diag' without body does not vspace. */ |
|
|
if (MDOC_Bl == bl->tok && arg_hasattr(MDOC_Diag, bl)) |
if (MDOC_Bl == bl->tok && LIST_diag == bl->data.list) |
if (n->prev && MDOC_It == n->prev->tok) { |
if (n->prev && MDOC_It == n->prev->tok) { |
assert(n->prev->body); |
assert(n->prev->body); |
if (NULL == n->prev->body->child) |
if (NULL == n->prev->body->child) |
Line 671 termp_it_pre(DECL_ARGS) |
|
Line 664 termp_it_pre(DECL_ARGS) |
|
{ |
{ |
const struct mdoc_node *bl, *nn; |
const struct mdoc_node *bl, *nn; |
char buf[7]; |
char buf[7]; |
int i, type, keys[3], vals[3]; |
int i, keys[3], vals[3]; |
size_t width, offset, ncols, dcol; |
size_t width, offset, ncols, dcol; |
|
enum mdoc_list type; |
|
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
print_bvspace(p, n->parent->parent, n); |
print_bvspace(p, n->parent->parent, n); |
Line 691 termp_it_pre(DECL_ARGS) |
|
Line 685 termp_it_pre(DECL_ARGS) |
|
|
|
arg_getattrs(keys, vals, 3, bl); |
arg_getattrs(keys, vals, 3, bl); |
|
|
type = arg_listtype(bl); |
type = bl->data.list; |
assert(-1 != type); |
|
|
|
/* |
/* |
* First calculate width and offset. This is pretty easy unless |
* First calculate width and offset. This is pretty easy unless |
Line 706 termp_it_pre(DECL_ARGS) |
|
Line 699 termp_it_pre(DECL_ARGS) |
|
offset = a2offs(&bl->args->argv[vals[1]]); |
offset = a2offs(&bl->args->argv[vals[1]]); |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Column): |
case (LIST_column): |
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
break; |
break; |
/* |
/* |
Line 764 termp_it_pre(DECL_ARGS) |
|
Line 757 termp_it_pre(DECL_ARGS) |
|
*/ |
*/ |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Bullet): |
case (LIST_bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
if (width < 4) |
if (width < 4) |
width = 4; |
width = 4; |
break; |
break; |
case (MDOC_Enum): |
case (LIST_enum): |
if (width < 5) |
if (width < 5) |
width = 5; |
width = 5; |
break; |
break; |
case (MDOC_Hang): |
case (LIST_hang): |
if (0 == width) |
if (0 == width) |
width = 8; |
width = 8; |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Tag): |
case (LIST_tag): |
if (0 == width) |
if (0 == width) |
width = 10; |
width = 10; |
break; |
break; |
Line 798 termp_it_pre(DECL_ARGS) |
|
Line 791 termp_it_pre(DECL_ARGS) |
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Diag): |
case (LIST_diag): |
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
term_word(p, "\\ \\ "); |
term_word(p, "\\ \\ "); |
break; |
break; |
case (MDOC_Inset): |
case (LIST_inset): |
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
term_word(p, "\\ "); |
term_word(p, "\\ "); |
break; |
break; |
Line 813 termp_it_pre(DECL_ARGS) |
|
Line 806 termp_it_pre(DECL_ARGS) |
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Diag): |
case (LIST_diag): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
break; |
break; |
Line 829 termp_it_pre(DECL_ARGS) |
|
Line 822 termp_it_pre(DECL_ARGS) |
|
*/ |
*/ |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Bullet): |
case (LIST_bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Enum): |
case (LIST_enum): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK; |
else |
else |
p->flags |= TERMP_NOLPAD; |
p->flags |= TERMP_NOLPAD; |
break; |
break; |
case (MDOC_Hang): |
case (LIST_hang): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK; |
else |
else |
Line 864 termp_it_pre(DECL_ARGS) |
|
Line 857 termp_it_pre(DECL_ARGS) |
|
} else |
} else |
p->flags |= TERMP_HANG; |
p->flags |= TERMP_HANG; |
break; |
break; |
case (MDOC_Tag): |
case (LIST_tag): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE; |
p->flags |= TERMP_NOBREAK | TERMP_TWOSPACE; |
else |
else |
Line 875 termp_it_pre(DECL_ARGS) |
|
Line 868 termp_it_pre(DECL_ARGS) |
|
if (NULL == n->next || NULL == n->next->child) |
if (NULL == n->next || NULL == n->next->child) |
p->flags |= TERMP_DANGLE; |
p->flags |= TERMP_DANGLE; |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
if (MDOC_HEAD == n->type) { |
if (MDOC_HEAD == n->type) { |
assert(n->next); |
assert(n->next); |
if (MDOC_BODY == n->next->type) |
if (MDOC_BODY == n->next->type) |
Line 886 termp_it_pre(DECL_ARGS) |
|
Line 879 termp_it_pre(DECL_ARGS) |
|
p->flags |= TERMP_NOLPAD; |
p->flags |= TERMP_NOLPAD; |
} |
} |
break; |
break; |
case (MDOC_Diag): |
case (LIST_diag): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->flags |= TERMP_NOBREAK; |
p->flags |= TERMP_NOBREAK; |
break; |
break; |
Line 903 termp_it_pre(DECL_ARGS) |
|
Line 896 termp_it_pre(DECL_ARGS) |
|
p->offset += offset; |
p->offset += offset; |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Hang): |
case (LIST_hang): |
/* |
/* |
* Same stipulation as above, regarding `-hang'. We |
* Same stipulation as above, regarding `-hang'. We |
* don't want to recalculate rmargin and offsets when |
* don't want to recalculate rmargin and offsets when |
Line 914 termp_it_pre(DECL_ARGS) |
|
Line 907 termp_it_pre(DECL_ARGS) |
|
MDOC_Bd == n->next->child->tok)) |
MDOC_Bd == n->next->child->tok)) |
break; |
break; |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Bullet): |
case (LIST_bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Enum): |
case (LIST_enum): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Tag): |
case (LIST_tag): |
assert(width); |
assert(width); |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + width; |
else |
else |
p->offset += width; |
p->offset += width; |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
assert(width); |
assert(width); |
p->rmargin = p->offset + width; |
p->rmargin = p->offset + width; |
/* |
/* |
Line 952 termp_it_pre(DECL_ARGS) |
|
Line 945 termp_it_pre(DECL_ARGS) |
|
|
|
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
switch (type) { |
switch (type) { |
case (MDOC_Bullet): |
case (LIST_bullet): |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
term_word(p, "\\[bu]"); |
term_word(p, "\\[bu]"); |
term_fontpop(p); |
term_fontpop(p); |
break; |
break; |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
term_word(p, "\\(hy"); |
term_word(p, "\\(hy"); |
term_fontpop(p); |
term_fontpop(p); |
break; |
break; |
case (MDOC_Enum): |
case (LIST_enum): |
(pair->ppair->ppair->count)++; |
(pair->ppair->ppair->count)++; |
snprintf(buf, sizeof(buf), "%d.", |
snprintf(buf, sizeof(buf), "%d.", |
pair->ppair->ppair->count); |
pair->ppair->ppair->count); |
Line 979 termp_it_pre(DECL_ARGS) |
|
Line 972 termp_it_pre(DECL_ARGS) |
|
*/ |
*/ |
|
|
switch (type) { |
switch (type) { |
case (MDOC_Bullet): |
case (LIST_bullet): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Item): |
case (LIST_item): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Dash): |
case (LIST_dash): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Hyphen): |
case (LIST_hyphen): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Enum): |
case (LIST_enum): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
return(0); |
return(0); |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
return(0); |
return(0); |
break; |
break; |
Line 1007 termp_it_pre(DECL_ARGS) |
|
Line 1000 termp_it_pre(DECL_ARGS) |
|
static void |
static void |
termp_it_post(DECL_ARGS) |
termp_it_post(DECL_ARGS) |
{ |
{ |
int type; |
enum mdoc_list type; |
|
|
if (MDOC_BLOCK == n->type) |
if (MDOC_BLOCK == n->type) |
return; |
return; |
|
|
type = arg_listtype(n->parent->parent->parent); |
type = n->parent->parent->parent->data.list; |
assert(-1 != type); |
|
|
|
switch (type) { |
switch (type) { |
case (MDOC_Item): |
case (LIST_item): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Diag): |
case (LIST_diag): |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
case (MDOC_Inset): |
case (LIST_inset): |
if (MDOC_BODY == n->type) |
if (MDOC_BODY == n->type) |
term_flushln(p); |
term_newln(p); |
break; |
break; |
case (MDOC_Column): |
case (LIST_column): |
if (MDOC_HEAD == n->type) |
if (MDOC_HEAD == n->type) |
term_flushln(p); |
term_flushln(p); |
break; |
break; |
default: |
default: |
term_flushln(p); |
term_newln(p); |
break; |
break; |
} |
} |
|
|
|
|
termp_nm_pre(DECL_ARGS) |
termp_nm_pre(DECL_ARGS) |
{ |
{ |
|
|
if (SEC_SYNOPSIS == n->sec) |
if (NULL == n->child && NULL == m->name) |
|
return(1); |
|
|
|
if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) |
term_newln(p); |
term_newln(p); |
|
|
term_fontpush(p, TERMFONT_BOLD); |
term_fontpush(p, TERMFONT_BOLD); |
|
|
if (NULL == n->child) |
if (NULL == n->child) |
term_word(p, m->name); |
term_word(p, m->name); |
|
|
return(1); |
return(1); |
} |
} |
|
|
Line 1127 termp_an_post(DECL_ARGS) |
|
Line 1123 termp_an_post(DECL_ARGS) |
|
return; |
return; |
} |
} |
|
|
if (arg_getattr(MDOC_Split, n) > -1) { |
if (arg_hasattr(MDOC_Split, n)) { |
p->flags &= ~TERMP_NOSPLIT; |
p->flags &= ~TERMP_NOSPLIT; |
p->flags |= TERMP_SPLIT; |
p->flags |= TERMP_SPLIT; |
} else { |
} else { |
Line 1183 termp_rv_pre(DECL_ARGS) |
|
Line 1179 termp_rv_pre(DECL_ARGS) |
|
term_word(p, "()"); |
term_word(p, "()"); |
} |
} |
|
|
if (n->child->next) |
if (n->child && n->child->next) |
term_word(p, "functions return"); |
term_word(p, "functions return"); |
else |
else |
term_word(p, "function returns"); |
term_word(p, "function returns"); |
Line 1222 termp_ex_pre(DECL_ARGS) |
|
Line 1218 termp_ex_pre(DECL_ARGS) |
|
p->flags &= ~TERMP_NOSPACE; |
p->flags &= ~TERMP_NOSPACE; |
} |
} |
|
|
if (n->child->next) |
if (n->child && n->child->next) |
term_word(p, "utilities exit"); |
term_word(p, "utilities exit"); |
else |
else |
term_word(p, "utility exits"); |
term_word(p, "utility exits"); |
|
|
termp_fd_post(DECL_ARGS) |
termp_fd_post(DECL_ARGS) |
{ |
{ |
|
|
if (n->sec != SEC_SYNOPSIS) |
if (n->sec != SEC_SYNOPSIS || ! (MDOC_LINE & n->flags)) |
return; |
return; |
|
|
term_newln(p); |
term_newln(p); |
|
|
termp_lb_post(DECL_ARGS) |
termp_lb_post(DECL_ARGS) |
{ |
{ |
|
|
if (SEC_LIBRARY == n->sec) |
if (SEC_LIBRARY == n->sec && MDOC_LINE & n->flags) |
term_newln(p); |
term_newln(p); |
} |
} |
|
|
|
|
termp_ft_pre(DECL_ARGS) |
termp_ft_pre(DECL_ARGS) |
{ |
{ |
|
|
if (SEC_SYNOPSIS == n->sec) |
if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) |
if (n->prev && MDOC_Fo == n->prev->tok) |
if (n->prev && MDOC_Fo == n->prev->tok) |
term_vspace(p); |
term_vspace(p); |
|
|
|
|
termp_ft_post(DECL_ARGS) |
termp_ft_post(DECL_ARGS) |
{ |
{ |
|
|
if (SEC_SYNOPSIS == n->sec) |
if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) |
term_newln(p); |
term_newln(p); |
} |
} |
|
|
|
|
termp_fn_post(DECL_ARGS) |
termp_fn_post(DECL_ARGS) |
{ |
{ |
|
|
if (n->sec == SEC_SYNOPSIS && n->next) |
if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags) |
term_vspace(p); |
term_vspace(p); |
} |
} |
|
|
Line 1598 termp_fa_pre(DECL_ARGS) |
|
Line 1594 termp_fa_pre(DECL_ARGS) |
|
static int |
static int |
termp_bd_pre(DECL_ARGS) |
termp_bd_pre(DECL_ARGS) |
{ |
{ |
|
size_t tabwidth; |
int i, type; |
int i, type; |
|
size_t rm, rmax; |
const struct mdoc_node *nn; |
const struct mdoc_node *nn; |
|
|
if (MDOC_BLOCK == n->type) { |
if (MDOC_BLOCK == n->type) { |
Line 1609 termp_bd_pre(DECL_ARGS) |
|
Line 1607 termp_bd_pre(DECL_ARGS) |
|
|
|
nn = n->parent; |
nn = n->parent; |
|
|
for (type = -1, i = 0; i < (int)nn->args->argc; i++) { |
type = arg_disptype(nn); |
switch (nn->args->argv[i].arg) { |
assert(-1 != type); |
case (MDOC_Centred): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Ragged): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Filled): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Unfilled): |
|
/* FALLTHROUGH */ |
|
case (MDOC_Literal): |
|
type = nn->args->argv[i].arg; |
|
break; |
|
case (MDOC_Offset): |
|
p->offset += a2offs(&nn->args->argv[i]); |
|
break; |
|
default: |
|
break; |
|
} |
|
} |
|
|
|
|
if (-1 != (i = arg_getattr(MDOC_Offset, nn))) |
|
p->offset += a2offs(&nn->args->argv[i]); |
|
|
/* |
/* |
* If -ragged or -filled are specified, the block does nothing |
* If -ragged or -filled are specified, the block does nothing |
* but change the indentation. If -unfilled or -literal are |
* but change the indentation. If -unfilled or -literal are |
Line 1638 termp_bd_pre(DECL_ARGS) |
|
Line 1621 termp_bd_pre(DECL_ARGS) |
|
* lines are allowed. |
* lines are allowed. |
*/ |
*/ |
|
|
assert(type > -1); |
|
if (MDOC_Literal != type && MDOC_Unfilled != type) |
if (MDOC_Literal != type && MDOC_Unfilled != type) |
return(1); |
return(1); |
|
|
|
tabwidth = p->tabwidth; |
|
p->tabwidth = 8; |
|
rm = p->rmargin; |
|
rmax = p->maxrmargin; |
|
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
|
|
for (nn = n->child; nn; nn = nn->next) { |
for (nn = n->child; nn; nn = nn->next) { |
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
print_mdoc_node(p, pair, m, nn); |
print_mdoc_node(p, pair, m, nn); |
if (NULL == nn->next) |
if (NULL == nn->prev || |
continue; |
nn->prev->line < nn->line || |
if (nn->prev && nn->prev->line < nn->line) |
NULL == nn->next) |
term_flushln(p); |
term_flushln(p); |
else if (NULL == nn->prev) |
|
term_flushln(p); |
|
} |
} |
|
p->tabwidth = tabwidth; |
|
|
|
p->rmargin = rm; |
|
p->maxrmargin = rmax; |
return(0); |
return(0); |
} |
} |
|
|
Line 1661 termp_bd_pre(DECL_ARGS) |
|
Line 1650 termp_bd_pre(DECL_ARGS) |
|
static void |
static void |
termp_bd_post(DECL_ARGS) |
termp_bd_post(DECL_ARGS) |
{ |
{ |
|
int type; |
|
size_t rm, rmax; |
|
|
if (MDOC_BODY != n->type) |
if (MDOC_BODY != n->type) |
return; |
return; |
|
|
|
type = arg_disptype(n->parent); |
|
assert(-1 != type); |
|
|
|
rm = p->rmargin; |
|
rmax = p->maxrmargin; |
|
|
|
if (MDOC_Literal == type || MDOC_Unfilled == type) |
|
p->rmargin = p->maxrmargin = TERM_MAXMARGIN; |
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
term_flushln(p); |
term_newln(p); |
|
|
|
p->rmargin = rm; |
|
p->maxrmargin = rmax; |
} |
} |
|
|
|
|
Line 1855 termp_in_post(DECL_ARGS) |
|
Line 1859 termp_in_post(DECL_ARGS) |
|
term_word(p, ">"); |
term_word(p, ">"); |
term_fontpop(p); |
term_fontpop(p); |
|
|
if (SEC_SYNOPSIS != n->sec) |
if (SEC_SYNOPSIS != n->sec && ! (MDOC_LINE & n->flags)) |
return; |
return; |
|
|
term_newln(p); |
term_newln(p); |
Line 2080 termp____post(DECL_ARGS) |
|
Line 2084 termp____post(DECL_ARGS) |
|
/* TODO: %U. */ |
/* TODO: %U. */ |
|
|
p->flags |= TERMP_NOSPACE; |
p->flags |= TERMP_NOSPACE; |
switch (n->tok) { |
|
case (MDOC__T): |
|
term_word(p, "\\(rq"); |
|
p->flags |= TERMP_NOSPACE; |
|
break; |
|
default: |
|
break; |
|
} |
|
term_word(p, n->next ? "," : "."); |
term_word(p, n->next ? "," : "."); |
} |
} |
|
|
Line 2135 termp_under_pre(DECL_ARGS) |
|
Line 2131 termp_under_pre(DECL_ARGS) |
|
{ |
{ |
|
|
term_fontpush(p, TERMFONT_UNDER); |
term_fontpush(p, TERMFONT_UNDER); |
return(1); |
|
} |
|
|
|
|
|
/* ARGSUSED */ |
|
static int |
|
termp__t_pre(DECL_ARGS) |
|
{ |
|
|
|
term_word(p, "\\(lq"); |
|
p->flags |= TERMP_NOSPACE; |
|
return(1); |
return(1); |
} |
} |