URI:
       ttt.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       ttt.c (1696B)
       ---
            1 /* tt.c: subroutines for drawing horizontal lines */
            2 # include "t.h"
            3 
            4 int
            5 ctype(int il, int ic)
            6 {
            7         if (instead[il])
            8                 return(0);
            9         if (fullbot[il])
           10                 return(0);
           11         il = stynum[il];
           12         return(style[ic][il]);
           13 }
           14 
           15 
           16 int
           17 min(int a, int b)
           18 {
           19         return(a < b ? a : b);
           20 }
           21 
           22 
           23 int
           24 fspan(int i, int c)
           25 {
           26         c++;
           27         return(c < ncol && ctype(i, c) == 's');
           28 }
           29 
           30 
           31 int
           32 lspan(int i, int c)
           33 {
           34         int        k;
           35 
           36         if (ctype(i, c) != 's')
           37                 return(0);
           38         c++;
           39         if (c < ncol && ctype(i, c) == 's')
           40                 return(0);
           41         for (k = 0; ctype(i, --c) == 's'; k++)
           42                 ;
           43         return(k);
           44 }
           45 
           46 
           47 int
           48 ctspan(int i, int c)
           49 {
           50         int        k;
           51         c++;
           52         for (k = 1; c < ncol && ctype(i, c) == 's'; k++)
           53                 c++;
           54         return(k);
           55 }
           56 
           57 
           58 void
           59 tohcol(int ic)
           60 {
           61         if (ic == 0)
           62                 Bprint(&tabout, "\\h'|0'");
           63         else
           64                 Bprint(&tabout, "\\h'(|\\n(%2su+|\\n(%2su)/2u'", reg(ic, CLEFT),
           65                      reg(ic - 1, CRIGHT));
           66 }
           67 
           68 
           69 int
           70 allh(int i)
           71 {
           72                         /* return true if every element in line i is horizontal */
           73                                 /* also at least one must be horizontl */
           74         int        c, one, k;
           75 
           76         if (fullbot[i])
           77                 return(1);
           78         if (i >= nlin)
           79                 return(dboxflg || boxflg);
           80         for (one = c = 0; c < ncol; c++) {
           81                 k = thish(i, c);
           82                 if (k == 0)
           83                         return(0);
           84                 if (k == 1)
           85                         continue;
           86                 one = 1;
           87         }
           88         return(one);
           89 }
           90 
           91 
           92 int
           93 thish(int i, int c)
           94 {
           95         int        t;
           96         char        *s;
           97         struct colstr *pc;
           98 
           99         if (c < 0)
          100                 return(0);
          101         if (i < 0)
          102                 return(0);
          103         t = ctype(i, c);
          104         if (t == '_' || t == '-')
          105                 return('-');
          106         if (t == '=')
          107                 return('=');
          108         if (t == '^')
          109                 return(1);
          110         if (fullbot[i] )
          111                 return(fullbot[i]);
          112         if (t == 's')
          113                 return(thish(i, c - 1));
          114         if (t == 0)
          115                 return(1);
          116         pc = &table[i][c];
          117         s = (t == 'a' ? pc->rcol : pc->col);
          118         if (s == 0 || (point(s) && *s == 0))
          119                 return(1);
          120         if (vspen(s))
          121                 return(1);
          122         if (t = barent( s))
          123                 return(t);
          124         return(0);
          125 }