[BACK]Return to man_term.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/man_term.c between version 1.76 and 1.77

version 1.76, 2010/06/19 20:46:28 version 1.77, 2010/06/25 18:53:14
Line 70  struct termact {
Line 70  struct termact {
 #define MAN_NOTEXT       (1 << 0) /* Never has text children. */  #define MAN_NOTEXT       (1 << 0) /* Never has text children. */
 };  };
   
 static  int               a2width(const struct man_node *);  static  int               a2width(const struct termp *, const char *);
 static  int               a2height(const struct man_node *);  static  size_t            a2height(const struct termp *, const char *);
   
 static  void              print_man_nodelist(DECL_ARGS);  static  void              print_man_nodelist(DECL_ARGS);
 static  void              print_man_node(DECL_ARGS);  static  void              print_man_node(DECL_ARGS);
Line 158  terminal_man(void *arg, const struct man *man)
Line 158  terminal_man(void *arg, const struct man *man)
   
         p->overstep = 0;          p->overstep = 0;
         p->maxrmargin = p->defrmargin;          p->maxrmargin = p->defrmargin;
         p->tabwidth = 5;          p->tabwidth = term_len(p, 5);
   
         if (NULL == p->symtab)          if (NULL == p->symtab)
                 switch (p->enc) {                  switch (p->enc) {
Line 177  terminal_man(void *arg, const struct man *man)
Line 177  terminal_man(void *arg, const struct man *man)
         p->flags |= TERMP_NOSPACE;          p->flags |= TERMP_NOSPACE;
   
         mt.fl = 0;          mt.fl = 0;
         mt.lmargin = INDENT;          mt.lmargin = term_len(p, INDENT);
         mt.offset = INDENT;          mt.offset = term_len(p, INDENT);
   
         if (n->child)          if (n->child)
                 print_man_nodelist(p, &mt, n->child, m);                  print_man_nodelist(p, &mt, n->child, m);
Line 187  terminal_man(void *arg, const struct man *man)
Line 187  terminal_man(void *arg, const struct man *man)
 }  }
   
   
 static int  static size_t
 a2height(const struct man_node *n)  a2height(const struct termp *p, const char *cp)
 {  {
         struct roffsu    su;          struct roffsu    su;
   
         assert(MAN_TEXT == n->type);          if ( ! a2roffsu(cp, &su, SCALE_VS))
         assert(n->string);                  SCALE_VS_INIT(&su, term_strlen(p, cp));
         if ( ! a2roffsu(n->string, &su, SCALE_VS))  
                 SCALE_VS_INIT(&su, strlen(n->string));  
   
         return((int)term_vspan(&su));          return(term_vspan(p, &su));
 }  }
   
   
 static int  static int
 a2width(const struct man_node *n)  a2width(const struct termp *p, const char *cp)
 {  {
         struct roffsu    su;          struct roffsu    su;
   
         assert(MAN_TEXT == n->type);          if ( ! a2roffsu(cp, &su, SCALE_BU))
         assert(n->string);  
         if ( ! a2roffsu(n->string, &su, SCALE_BU))  
                 return(-1);                  return(-1);
   
         return((int)term_hspan(&su));          return((int)term_hspan(p, &su));
 }  }
   
   
Line 359  pre_B(DECL_ARGS)
Line 355  pre_B(DECL_ARGS)
 static int  static int
 pre_sp(DECL_ARGS)  pre_sp(DECL_ARGS)
 {  {
         int              i, len;          size_t           i, len;
   
         len = n->child ? a2height(n->child) : 1;          len = n->child ?
                   a2height(p, n->child->string) : term_len(p, 1);
   
         if (0 == len)          if (0 == len)
                 term_newln(p);                  term_newln(p);
Line 408  pre_HP(DECL_ARGS)
Line 405  pre_HP(DECL_ARGS)
         /* Calculate offset. */          /* Calculate offset. */
   
         if (NULL != (nn = n->parent->head->child))          if (NULL != (nn = n->parent->head->child))
                 if ((ival = a2width(nn)) >= 0)                  if ((ival = a2width(p, nn->string)) >= 0)
                         len = (size_t)ival;                          len = (size_t)ival;
   
         if (0 == len)          if (0 == len)
                 len = 1;                  len = term_len(p, 1);
   
         p->offset = mt->offset;          p->offset = mt->offset;
         p->rmargin = mt->offset + len;          p->rmargin = mt->offset + len;
Line 453  pre_PP(DECL_ARGS)
Line 450  pre_PP(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case (MAN_BLOCK):          case (MAN_BLOCK):
                 mt->lmargin = INDENT;                  mt->lmargin = term_len(p, INDENT);
                 print_bvspace(p, n);                  print_bvspace(p, n);
                 break;                  break;
         default:          default:
Line 497  pre_IP(DECL_ARGS)
Line 494  pre_IP(DECL_ARGS)
                 if (NULL != (nn = nn->next)) {                  if (NULL != (nn = nn->next)) {
                         for ( ; nn->next; nn = nn->next)                          for ( ; nn->next; nn = nn->next)
                                 /* Do nothing. */ ;                                  /* Do nothing. */ ;
                         if ((ival = a2width(nn)) >= 0)                          if ((ival = a2width(p, nn->string)) >= 0)
                                 len = (size_t)ival;                                  len = (size_t)ival;
                 }                  }
   
Line 505  pre_IP(DECL_ARGS)
Line 502  pre_IP(DECL_ARGS)
         case (MAN_HEAD):          case (MAN_HEAD):
                 /* Handle zero-width lengths. */                  /* Handle zero-width lengths. */
                 if (0 == len)                  if (0 == len)
                         len = 1;                          len = term_len(p, 1);
   
                 p->offset = mt->offset;                  p->offset = mt->offset;
                 p->rmargin = mt->offset + len;                  p->rmargin = mt->offset + len;
Line 585  pre_TP(DECL_ARGS)
Line 582  pre_TP(DECL_ARGS)
                 while (nn && MAN_TEXT != nn->type)                  while (nn && MAN_TEXT != nn->type)
                         nn = nn->next;                          nn = nn->next;
                 if (nn && nn->next)                  if (nn && nn->next)
                         if ((ival = a2width(nn)) >= 0)                          if ((ival = a2width(p, nn->string)) >= 0)
                                 len = (size_t)ival;                                  len = (size_t)ival;
         }          }
   
Line 593  pre_TP(DECL_ARGS)
Line 590  pre_TP(DECL_ARGS)
         case (MAN_HEAD):          case (MAN_HEAD):
                 /* Handle zero-length properly. */                  /* Handle zero-length properly. */
                 if (0 == len)                  if (0 == len)
                         len = 1;                          len = term_len(p, 1);
   
                 p->offset = mt->offset;                  p->offset = mt->offset;
                 p->rmargin = mt->offset + len;                  p->rmargin = mt->offset + len;
Line 648  pre_SS(DECL_ARGS)
Line 645  pre_SS(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case (MAN_BLOCK):          case (MAN_BLOCK):
                 mt->lmargin = INDENT;                  mt->lmargin = term_len(p, INDENT);
                 mt->offset = INDENT;                  mt->offset = term_len(p, INDENT);
                 /* If following a prior empty `SS', no vspace. */                  /* If following a prior empty `SS', no vspace. */
                 if (n->prev && MAN_SS == n->prev->tok)                  if (n->prev && MAN_SS == n->prev->tok)
                         if (NULL == n->prev->body->child)                          if (NULL == n->prev->body->child)
Line 660  pre_SS(DECL_ARGS)
Line 657  pre_SS(DECL_ARGS)
                 break;                  break;
         case (MAN_HEAD):          case (MAN_HEAD):
                 term_fontrepl(p, TERMFONT_BOLD);                  term_fontrepl(p, TERMFONT_BOLD);
                 p->offset = HALFINDENT;                  p->offset = term_len(p, HALFINDENT);
                 break;                  break;
         case (MAN_BODY):          case (MAN_BODY):
                 p->offset = mt->offset;                  p->offset = mt->offset;
Line 698  pre_SH(DECL_ARGS)
Line 695  pre_SH(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case (MAN_BLOCK):          case (MAN_BLOCK):
                 mt->lmargin = INDENT;                  mt->lmargin = term_len(p, INDENT);
                 mt->offset = INDENT;                  mt->offset = term_len(p, INDENT);
                 /* If following a prior empty `SH', no vspace. */                  /* If following a prior empty `SH', no vspace. */
                 if (n->prev && MAN_SH == n->prev->tok)                  if (n->prev && MAN_SH == n->prev->tok)
                         if (NULL == n->prev->body->child)                          if (NULL == n->prev->body->child)
Line 760  pre_RS(DECL_ARGS)
Line 757  pre_RS(DECL_ARGS)
         }          }
   
         if (NULL == (nn = n->parent->head->child)) {          if (NULL == (nn = n->parent->head->child)) {
                 mt->offset = mt->lmargin + INDENT;                  mt->offset = mt->lmargin + term_len(p, INDENT);
                 p->offset = mt->offset;                  p->offset = mt->offset;
                 return(1);                  return(1);
         }          }
   
         if ((ival = a2width(nn)) < 0)          if ((ival = a2width(p, nn->string)) < 0)
                 return(1);                  return(1);
   
         mt->offset = INDENT + (size_t)ival;          mt->offset = term_len(p, INDENT) + (size_t)ival;
         p->offset = mt->offset;          p->offset = mt->offset;
   
         return(1);          return(1);
Line 782  post_RS(DECL_ARGS)
Line 779  post_RS(DECL_ARGS)
   
         switch (n->type) {          switch (n->type) {
         case (MAN_BLOCK):          case (MAN_BLOCK):
                 mt->offset = mt->lmargin = INDENT;                  mt->offset = mt->lmargin = term_len(p, INDENT);
                 break;                  break;
         case (MAN_HEAD):          case (MAN_HEAD):
                 break;                  break;
         default:          default:
                 term_newln(p);                  term_newln(p);
                 p->offset = INDENT;                  p->offset = term_len(p, INDENT);
                 break;                  break;
         }          }
 }  }
Line 877  print_man_foot(struct termp *p, const void *arg)
Line 874  print_man_foot(struct termp *p, const void *arg)
         term_vspace(p);          term_vspace(p);
   
         p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;          p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
         p->rmargin = p->maxrmargin - strlen(buf);          p->rmargin = p->maxrmargin - term_strlen(p, buf);
         p->offset = 0;          p->offset = 0;
   
         if (meta->source)          if (meta->source)
Line 918  print_man_head(struct termp *p, const void *arg)
Line 915  print_man_head(struct termp *p, const void *arg)
   
         if (m->vol)          if (m->vol)
                 strlcpy(buf, m->vol, BUFSIZ);                  strlcpy(buf, m->vol, BUFSIZ);
         buflen = strlen(buf);          buflen = term_strlen(p, buf);
   
         snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);          snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
         titlen = strlen(title);          titlen = term_strlen(p, title);
   
         p->offset = 0;          p->offset = 0;
         p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?          p->rmargin = 2 * (titlen+1) + buflen < p->maxrmargin ?
             (p->maxrmargin - strlen(buf) + 1) / 2 :              (p->maxrmargin -
                term_strlen(p, buf) + term_len(p, 1)) / 2 :
             p->maxrmargin - buflen;              p->maxrmargin - buflen;
         p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;          p->flags |= TERMP_NOBREAK | TERMP_NOSPACE;
   

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77

CVSweb