home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / tbl / tt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  1.4 KB  |  86 lines

  1.  /* tt.c: subroutines for drawing horizontal lines */
  2. # include "t..c"
  3. ctype(il, ic)
  4. {
  5. if (instead[il])
  6.     return(0);
  7. if (fullbot[il])
  8.     return(0);
  9. il = stynum[il];
  10. return(style[il][ic]);
  11. }
  12. min(a,b)
  13. {
  14. return(a<b ? a : b);
  15. }
  16. fspan(i,c)
  17. {
  18. c++;
  19. return(c<ncol && ctype(i,c)=='s');
  20. }
  21. lspan(i,c)
  22. {
  23. int k;
  24. if (ctype(i,c) != 's') return(0);
  25. c++;
  26. if (c < ncol && ctype(i,c)== 's') 
  27.     return(0);
  28. for(k=0; ctype(i,--c) == 's'; k++);
  29. return(k);
  30. }
  31. ctspan(i,c)
  32. {
  33. int k;
  34. c++;
  35. for(k=1; c<ncol && ctype(i,c)=='s'; k++)
  36.     c++;
  37. return(k);
  38. }
  39. tohcol(ic)
  40. {
  41.             if (ic==0)
  42.                 fprintf(tabout, "\\h'|0'");
  43.             else
  44.                 fprintf(tabout, "\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
  45. }
  46. allh(i)
  47. {
  48. /* return true if every element in line i is horizontal */
  49. /* also at least one must be horizontl */
  50. int c, one, k;
  51. if (fullbot[i]) return(1);
  52. for(one=c=0; c<ncol; c++)
  53.     {
  54.     k = thish(i,c);
  55.     if (k==0) return(0);
  56.     if (k==1) continue;
  57.     one=1;
  58.     }
  59. return(one);
  60. }
  61. thish(i,c)
  62. {
  63.     int t;
  64.     char *s;
  65.     struct colstr *pc;
  66.     if (c<0)return(0);
  67.     if (i<0) return(0);
  68.     t = ctype(i,c);
  69.     if (t=='_' || t == '-')
  70.         return('-');
  71.     if (t=='=')return('=');
  72.     if (t=='^') return(1);
  73.     if (fullbot[i] )
  74.         return(fullbot[i]);
  75.     if (t=='s') return(thish(i,c-1));
  76.     if (t==0) return(1);
  77.     pc = &table[i][c];
  78.     s = (t=='a' ? pc->rcol : pc->col);
  79.     if (s==0 || (point(s) && *s==0))
  80.         return(1);
  81.     if (vspen(s)) return(1);
  82.     if (t=barent( s))
  83.         return(t);
  84.     return(0);
  85. }
  86.