1*b5514887Smuffin /*
2*b5514887Smuffin * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
3*b5514887Smuffin * Use is subject to license terms.
4*b5514887Smuffin */
5*b5514887Smuffin
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate */
147c478bd9Sstevel@tonic-gate
157c478bd9Sstevel@tonic-gate /* tv.c: draw vertical lines */
167c478bd9Sstevel@tonic-gate # include "t..c"
17*b5514887Smuffin
18*b5514887Smuffin void
drawvert(int start,int end,int c,int lwid)19*b5514887Smuffin drawvert(int start, int end, int c, int lwid)
207c478bd9Sstevel@tonic-gate {
217c478bd9Sstevel@tonic-gate char *exb=0, *ext=0;
227c478bd9Sstevel@tonic-gate int tp=0, sl, ln, pos, epb, ept, vm;
237c478bd9Sstevel@tonic-gate end++;
247c478bd9Sstevel@tonic-gate vm='v';
257c478bd9Sstevel@tonic-gate /* note: nr 35 has value of 1m outside of linesize */
267c478bd9Sstevel@tonic-gate while (instead[end]) end++;
277c478bd9Sstevel@tonic-gate for(ln=0; ln<lwid; ln++)
287c478bd9Sstevel@tonic-gate {
297c478bd9Sstevel@tonic-gate epb=ept=0;
307c478bd9Sstevel@tonic-gate pos = 2*ln-lwid+1;
317c478bd9Sstevel@tonic-gate if (pos!=tp) fprintf(tabout, "\\h'%dp'", pos-tp);
327c478bd9Sstevel@tonic-gate tp = pos;
337c478bd9Sstevel@tonic-gate if (end<nlin)
347c478bd9Sstevel@tonic-gate {
357c478bd9Sstevel@tonic-gate if (fullbot[end]|| (!instead[end] && allh(end)))
367c478bd9Sstevel@tonic-gate epb=2;
377c478bd9Sstevel@tonic-gate else
387c478bd9Sstevel@tonic-gate switch (midbar(end,c))
397c478bd9Sstevel@tonic-gate {
407c478bd9Sstevel@tonic-gate case '-':
417c478bd9Sstevel@tonic-gate exb = "1v-.5m"; break;
427c478bd9Sstevel@tonic-gate case '=':
437c478bd9Sstevel@tonic-gate exb = "1v-.5m";
447c478bd9Sstevel@tonic-gate epb = 1; break;
457c478bd9Sstevel@tonic-gate }
467c478bd9Sstevel@tonic-gate }
477c478bd9Sstevel@tonic-gate if (lwid>1)
487c478bd9Sstevel@tonic-gate switch(interh(end, c))
497c478bd9Sstevel@tonic-gate {
507c478bd9Sstevel@tonic-gate case THRU: epb -= 1; break;
517c478bd9Sstevel@tonic-gate case RIGHT: epb += (ln==0 ? 1 : -1); break;
527c478bd9Sstevel@tonic-gate case LEFT: epb += (ln==1 ? 1 : -1); break;
537c478bd9Sstevel@tonic-gate }
547c478bd9Sstevel@tonic-gate if (lwid==1)
557c478bd9Sstevel@tonic-gate switch(interh(end,c))
567c478bd9Sstevel@tonic-gate {
577c478bd9Sstevel@tonic-gate case THRU: epb -= 1; break;
587c478bd9Sstevel@tonic-gate case RIGHT: case LEFT: epb += 1; break;
597c478bd9Sstevel@tonic-gate }
607c478bd9Sstevel@tonic-gate if (start>0)
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate sl = start-1;
637c478bd9Sstevel@tonic-gate while (sl>=0 && instead[sl]) sl--;
647c478bd9Sstevel@tonic-gate if (sl>=0 && (fullbot[sl] || allh(sl)))
657c478bd9Sstevel@tonic-gate ept=0;
667c478bd9Sstevel@tonic-gate else
677c478bd9Sstevel@tonic-gate if (sl>=0)
687c478bd9Sstevel@tonic-gate switch(midbar(sl,c))
697c478bd9Sstevel@tonic-gate {
707c478bd9Sstevel@tonic-gate case '-':
717c478bd9Sstevel@tonic-gate ext = ".5m"; break;
727c478bd9Sstevel@tonic-gate case '=':
737c478bd9Sstevel@tonic-gate ext= ".5m"; ept = -1; break;
747c478bd9Sstevel@tonic-gate default:
757c478bd9Sstevel@tonic-gate vm = 'm'; break;
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate else
787c478bd9Sstevel@tonic-gate ept = -4;
797c478bd9Sstevel@tonic-gate }
807c478bd9Sstevel@tonic-gate else if (start==0 && allh(0))
817c478bd9Sstevel@tonic-gate {
827c478bd9Sstevel@tonic-gate ept=0;
837c478bd9Sstevel@tonic-gate vm = 'm';
847c478bd9Sstevel@tonic-gate }
857c478bd9Sstevel@tonic-gate if (lwid>1)
867c478bd9Sstevel@tonic-gate switch(interh(start,c))
877c478bd9Sstevel@tonic-gate {
887c478bd9Sstevel@tonic-gate case THRU: ept += 1; break;
897c478bd9Sstevel@tonic-gate case LEFT: ept += (ln==0 ? 1 : -1); break;
907c478bd9Sstevel@tonic-gate case RIGHT: ept += (ln==1 ? 1 : -1); break;
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate else if (lwid==1)
937c478bd9Sstevel@tonic-gate switch(interh(start,c))
947c478bd9Sstevel@tonic-gate {
957c478bd9Sstevel@tonic-gate case THRU: ept += 1; break;
967c478bd9Sstevel@tonic-gate case LEFT: case RIGHT: ept -= 1; break;
977c478bd9Sstevel@tonic-gate }
987c478bd9Sstevel@tonic-gate if (exb)
997c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%s'", exb);
1007c478bd9Sstevel@tonic-gate if (epb)
1017c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%dp'", epb);
1027c478bd9Sstevel@tonic-gate fprintf(tabout, "\\s\\n(%d",LSIZE);
1037c478bd9Sstevel@tonic-gate if (linsize)
1047c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
1057c478bd9Sstevel@tonic-gate fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */
1067c478bd9Sstevel@tonic-gate fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u");
1077c478bd9Sstevel@tonic-gate if (ext)
1087c478bd9Sstevel@tonic-gate fprintf(tabout, "-(%s)",ext);
1097c478bd9Sstevel@tonic-gate if (exb)
1107c478bd9Sstevel@tonic-gate fprintf(tabout, "-(%s)", exb);
1117c478bd9Sstevel@tonic-gate pos = ept-epb;
1127c478bd9Sstevel@tonic-gate if (pos)
1137c478bd9Sstevel@tonic-gate fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos);
1147c478bd9Sstevel@tonic-gate /* the string #d is either "nl" or ".d" depending
1157c478bd9Sstevel@tonic-gate on diversions; on GCOS not the same */
1167c478bd9Sstevel@tonic-gate fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u");
1177c478bd9Sstevel@tonic-gate if (ext)
1187c478bd9Sstevel@tonic-gate fprintf(tabout, "+%s",ext);
1197c478bd9Sstevel@tonic-gate if (ept)
1207c478bd9Sstevel@tonic-gate fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept));
1217c478bd9Sstevel@tonic-gate fprintf(tabout, "'");
1227c478bd9Sstevel@tonic-gate if (linsize)
1237c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate }
1267c478bd9Sstevel@tonic-gate
127*b5514887Smuffin int
midbar(int i,int c)128*b5514887Smuffin midbar(int i, int c)
1297c478bd9Sstevel@tonic-gate {
1307c478bd9Sstevel@tonic-gate int k;
1317c478bd9Sstevel@tonic-gate k = midbcol(i,c);
1327c478bd9Sstevel@tonic-gate if (k==0 && c>0)
1337c478bd9Sstevel@tonic-gate k = midbcol(i, c-1);
1347c478bd9Sstevel@tonic-gate return(k);
1357c478bd9Sstevel@tonic-gate }
136*b5514887Smuffin
137*b5514887Smuffin int
midbcol(int i,int c)138*b5514887Smuffin midbcol(int i, int c)
1397c478bd9Sstevel@tonic-gate {
1407c478bd9Sstevel@tonic-gate int ct;
1417c478bd9Sstevel@tonic-gate while ( (ct=ctype(i,c)) == 's')
1427c478bd9Sstevel@tonic-gate c--;
1437c478bd9Sstevel@tonic-gate if (ct=='-' || ct == '=')
1447c478bd9Sstevel@tonic-gate return(ct);
1457c478bd9Sstevel@tonic-gate if (ct=barent(table[i][c].col))
1467c478bd9Sstevel@tonic-gate return(ct);
1477c478bd9Sstevel@tonic-gate return(0);
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate
150*b5514887Smuffin int
barent(char * s)151*b5514887Smuffin barent(char *s)
1527c478bd9Sstevel@tonic-gate {
1537c478bd9Sstevel@tonic-gate if (s==0) return (1);
1547c478bd9Sstevel@tonic-gate if (!point(s)) return(1);
1557c478bd9Sstevel@tonic-gate if (s[0]== '\\') s++;
1567c478bd9Sstevel@tonic-gate if (s[1]!= 0)
1577c478bd9Sstevel@tonic-gate return(0);
1587c478bd9Sstevel@tonic-gate switch(s[0])
1597c478bd9Sstevel@tonic-gate {
1607c478bd9Sstevel@tonic-gate case '_':
1617c478bd9Sstevel@tonic-gate return('-');
1627c478bd9Sstevel@tonic-gate case '=':
1637c478bd9Sstevel@tonic-gate return('=');
1647c478bd9Sstevel@tonic-gate }
1657c478bd9Sstevel@tonic-gate return(0);
1667c478bd9Sstevel@tonic-gate }
167