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

Diff for /mandoc/term.c between version 1.103 and 1.113

version 1.103, 2009/09/23 11:02:21 version 1.113, 2009/10/26 17:05:44
Line 19 
Line 19 
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   #include <time.h>
   
 #include "chars.h"  #include "chars.h"
   #include "out.h"
 #include "term.h"  #include "term.h"
 #include "man.h"  #include "man.h"
 #include "mdoc.h"  #include "mdoc.h"
   #include "main.h"
   
 /* FIXME: accomodate non-breaking, non-collapsing white-space. */  /* FIXME: accomodate non-breaking, non-collapsing white-space. */
 /* FIXME: accomodate non-breaking, collapsing white-space. */  /* FIXME: accomodate non-breaking, collapsing white-space. */
   
 extern  void              man_run(struct termp *,  
                                 const struct man *);  
 extern  void              mdoc_run(struct termp *,  
                                 const struct mdoc *);  
   
 static  struct termp     *term_alloc(enum termenc);  static  struct termp     *term_alloc(enum termenc);
 static  void              term_free(struct termp *);  static  void              term_free(struct termp *);
   
Line 54  ascii_alloc(void)
Line 52  ascii_alloc(void)
   
   
 void  void
 terminal_man(void *arg, const struct man *man)  
 {  
         struct termp    *p;  
   
         p = (struct termp *)arg;  
         if (NULL == p->symtab)  
                 p->symtab = chars_init(CHARS_ASCII);  
   
         man_run(p, man);  
 }  
   
   
 void  
 terminal_mdoc(void *arg, const struct mdoc *mdoc)  
 {  
         struct termp    *p;  
   
         p = (struct termp *)arg;  
         if (NULL == p->symtab)  
                 p->symtab = chars_init(CHARS_ASCII);  
   
         mdoc_run(p, mdoc);  
 }  
   
   
 void  
 terminal_free(void *arg)  terminal_free(void *arg)
 {  {
   
Line 179  term_flushln(struct termp *p)
Line 151  term_flushln(struct termp *p)
   
         bp = TERMP_NOBREAK & p->flags ? mmax : maxvis;          bp = TERMP_NOBREAK & p->flags ? mmax : maxvis;
         vis = 0;          vis = 0;
         overstep = 0;  
   
         /*          /*
          * If in the standard case (left-justified), then begin with our           * If in the standard case (left-justified), then begin with our
Line 233  term_flushln(struct termp *p)
Line 204  term_flushln(struct termp *p)
                                         putchar(' ');                                          putchar(' ');
                                 vis = 0;                                  vis = 0;
                         }                          }
                           /* Remove the overstep width. */
                           bp += (int)/* LINTED */
                                   overstep;
                           overstep = 0;
                 } else {                  } else {
                         for (j = 0; j < (int)vbl; j++)                          for (j = 0; j < (int)vbl; j++)
                                 putchar(' ');                                  putchar(' ');
Line 249  term_flushln(struct termp *p)
Line 224  term_flushln(struct termp *p)
                 }                  }
                 vis += vsz;                  vis += vsz;
         }          }
   
         p->col = 0;          p->col = 0;
           overstep = 0;
   
         if ( ! (TERMP_NOBREAK & p->flags)) {          if ( ! (TERMP_NOBREAK & p->flags)) {
                 putchar('\n');                  putchar('\n');
Line 571  encode(struct termp *p, char c)
Line 548  encode(struct termp *p, char c)
 {  {
   
         if (' ' != c) {          if (' ' != c) {
                 if (p->bold) {  
                         buffer(p, c);  
                         buffer(p, 8);  
                 }  
                 if (p->under) {                  if (p->under) {
                         buffer(p, '_');                          buffer(p, '_');
                         buffer(p, 8);                          buffer(p, 8);
                 }                  }
                   if (p->bold) {
                           buffer(p, c);
                           buffer(p, 8);
                   }
         }          }
         buffer(p, c);          buffer(p, c);
 }  }
   
   
   size_t
   term_vspan(const struct roffsu *su)
   {
           double           r;
   
           switch (su->unit) {
           case (SCALE_CM):
                   r = su->scale * 2;
                   break;
           case (SCALE_IN):
                   r = su->scale * 6;
                   break;
           case (SCALE_PC):
                   r = su->scale;
                   break;
           case (SCALE_PT):
                   r = su->scale / 8;
                   break;
           case (SCALE_MM):
                   r = su->scale / 1000;
                   break;
           case (SCALE_VS):
                   r = su->scale;
                   break;
           default:
                   r = su->scale - 1;
                   break;
           }
   
           if (r < 0.0)
                   r = 0.0;
           return(/* LINTED */(size_t)
                           r);
   }
   
   
   size_t
   term_hspan(const struct roffsu *su)
   {
           double           r;
   
           /* XXX: CM, IN, and PT are approximations. */
   
           switch (su->unit) {
           case (SCALE_CM):
                   r = 4 * su->scale;
                   break;
           case (SCALE_IN):
                   /* XXX: this is an approximation. */
                   r = 10 * su->scale;
                   break;
           case (SCALE_PC):
                   r = (10 * su->scale) / 6;
                   break;
           case (SCALE_PT):
                   r = (10 * su->scale) / 72;
                   break;
           case (SCALE_MM):
                   r = su->scale / 1000; /* FIXME: double-check. */
                   break;
           case (SCALE_VS):
                   r = su->scale * 2 - 1; /* FIXME: double-check. */
                   break;
           default:
                   r = su->scale;
                   break;
           }
   
           if (r < 0.0)
                   r = 0.0;
           return((size_t)/* LINTED */
                           r);
   }
   
   

Legend:
Removed from v.1.103  
changed lines
  Added in v.1.113

CVSweb