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 15*b5514887Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate /* tv.c: draw vertical lines */ 187c478bd9Sstevel@tonic-gate # include "t..c" 19*b5514887Smuffin 20*b5514887Smuffin void 21*b5514887Smuffin drawvert(int start, int end, int c, int lwid) 227c478bd9Sstevel@tonic-gate { 237c478bd9Sstevel@tonic-gate char *exb=0, *ext=0; 247c478bd9Sstevel@tonic-gate int tp=0, sl, ln, pos, epb, ept, vm; 257c478bd9Sstevel@tonic-gate end++; 267c478bd9Sstevel@tonic-gate vm='v'; 277c478bd9Sstevel@tonic-gate /* note: nr 35 has value of 1m outside of linesize */ 287c478bd9Sstevel@tonic-gate while (instead[end]) end++; 297c478bd9Sstevel@tonic-gate for(ln=0; ln<lwid; ln++) 307c478bd9Sstevel@tonic-gate { 317c478bd9Sstevel@tonic-gate epb=ept=0; 327c478bd9Sstevel@tonic-gate pos = 2*ln-lwid+1; 337c478bd9Sstevel@tonic-gate if (pos!=tp) fprintf(tabout, "\\h'%dp'", pos-tp); 347c478bd9Sstevel@tonic-gate tp = pos; 357c478bd9Sstevel@tonic-gate if (end<nlin) 367c478bd9Sstevel@tonic-gate { 377c478bd9Sstevel@tonic-gate if (fullbot[end]|| (!instead[end] && allh(end))) 387c478bd9Sstevel@tonic-gate epb=2; 397c478bd9Sstevel@tonic-gate else 407c478bd9Sstevel@tonic-gate switch (midbar(end,c)) 417c478bd9Sstevel@tonic-gate { 427c478bd9Sstevel@tonic-gate case '-': 437c478bd9Sstevel@tonic-gate exb = "1v-.5m"; break; 447c478bd9Sstevel@tonic-gate case '=': 457c478bd9Sstevel@tonic-gate exb = "1v-.5m"; 467c478bd9Sstevel@tonic-gate epb = 1; break; 477c478bd9Sstevel@tonic-gate } 487c478bd9Sstevel@tonic-gate } 497c478bd9Sstevel@tonic-gate if (lwid>1) 507c478bd9Sstevel@tonic-gate switch(interh(end, c)) 517c478bd9Sstevel@tonic-gate { 527c478bd9Sstevel@tonic-gate case THRU: epb -= 1; break; 537c478bd9Sstevel@tonic-gate case RIGHT: epb += (ln==0 ? 1 : -1); break; 547c478bd9Sstevel@tonic-gate case LEFT: epb += (ln==1 ? 1 : -1); break; 557c478bd9Sstevel@tonic-gate } 567c478bd9Sstevel@tonic-gate if (lwid==1) 577c478bd9Sstevel@tonic-gate switch(interh(end,c)) 587c478bd9Sstevel@tonic-gate { 597c478bd9Sstevel@tonic-gate case THRU: epb -= 1; break; 607c478bd9Sstevel@tonic-gate case RIGHT: case LEFT: epb += 1; break; 617c478bd9Sstevel@tonic-gate } 627c478bd9Sstevel@tonic-gate if (start>0) 637c478bd9Sstevel@tonic-gate { 647c478bd9Sstevel@tonic-gate sl = start-1; 657c478bd9Sstevel@tonic-gate while (sl>=0 && instead[sl]) sl--; 667c478bd9Sstevel@tonic-gate if (sl>=0 && (fullbot[sl] || allh(sl))) 677c478bd9Sstevel@tonic-gate ept=0; 687c478bd9Sstevel@tonic-gate else 697c478bd9Sstevel@tonic-gate if (sl>=0) 707c478bd9Sstevel@tonic-gate switch(midbar(sl,c)) 717c478bd9Sstevel@tonic-gate { 727c478bd9Sstevel@tonic-gate case '-': 737c478bd9Sstevel@tonic-gate ext = ".5m"; break; 747c478bd9Sstevel@tonic-gate case '=': 757c478bd9Sstevel@tonic-gate ext= ".5m"; ept = -1; break; 767c478bd9Sstevel@tonic-gate default: 777c478bd9Sstevel@tonic-gate vm = 'm'; break; 787c478bd9Sstevel@tonic-gate } 797c478bd9Sstevel@tonic-gate else 807c478bd9Sstevel@tonic-gate ept = -4; 817c478bd9Sstevel@tonic-gate } 827c478bd9Sstevel@tonic-gate else if (start==0 && allh(0)) 837c478bd9Sstevel@tonic-gate { 847c478bd9Sstevel@tonic-gate ept=0; 857c478bd9Sstevel@tonic-gate vm = 'm'; 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate if (lwid>1) 887c478bd9Sstevel@tonic-gate switch(interh(start,c)) 897c478bd9Sstevel@tonic-gate { 907c478bd9Sstevel@tonic-gate case THRU: ept += 1; break; 917c478bd9Sstevel@tonic-gate case LEFT: ept += (ln==0 ? 1 : -1); break; 927c478bd9Sstevel@tonic-gate case RIGHT: ept += (ln==1 ? 1 : -1); break; 937c478bd9Sstevel@tonic-gate } 947c478bd9Sstevel@tonic-gate else if (lwid==1) 957c478bd9Sstevel@tonic-gate switch(interh(start,c)) 967c478bd9Sstevel@tonic-gate { 977c478bd9Sstevel@tonic-gate case THRU: ept += 1; break; 987c478bd9Sstevel@tonic-gate case LEFT: case RIGHT: ept -= 1; break; 997c478bd9Sstevel@tonic-gate } 1007c478bd9Sstevel@tonic-gate if (exb) 1017c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%s'", exb); 1027c478bd9Sstevel@tonic-gate if (epb) 1037c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'%dp'", epb); 1047c478bd9Sstevel@tonic-gate fprintf(tabout, "\\s\\n(%d",LSIZE); 1057c478bd9Sstevel@tonic-gate if (linsize) 1067c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); 1077c478bd9Sstevel@tonic-gate fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */ 1087c478bd9Sstevel@tonic-gate fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u"); 1097c478bd9Sstevel@tonic-gate if (ext) 1107c478bd9Sstevel@tonic-gate fprintf(tabout, "-(%s)",ext); 1117c478bd9Sstevel@tonic-gate if (exb) 1127c478bd9Sstevel@tonic-gate fprintf(tabout, "-(%s)", exb); 1137c478bd9Sstevel@tonic-gate pos = ept-epb; 1147c478bd9Sstevel@tonic-gate if (pos) 1157c478bd9Sstevel@tonic-gate fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos); 1167c478bd9Sstevel@tonic-gate /* the string #d is either "nl" or ".d" depending 1177c478bd9Sstevel@tonic-gate on diversions; on GCOS not the same */ 1187c478bd9Sstevel@tonic-gate fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u"); 1197c478bd9Sstevel@tonic-gate if (ext) 1207c478bd9Sstevel@tonic-gate fprintf(tabout, "+%s",ext); 1217c478bd9Sstevel@tonic-gate if (ept) 1227c478bd9Sstevel@tonic-gate fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept)); 1237c478bd9Sstevel@tonic-gate fprintf(tabout, "'"); 1247c478bd9Sstevel@tonic-gate if (linsize) 1257c478bd9Sstevel@tonic-gate fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); 1267c478bd9Sstevel@tonic-gate } 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate 129*b5514887Smuffin int 130*b5514887Smuffin midbar(int i, int c) 1317c478bd9Sstevel@tonic-gate { 1327c478bd9Sstevel@tonic-gate int k; 1337c478bd9Sstevel@tonic-gate k = midbcol(i,c); 1347c478bd9Sstevel@tonic-gate if (k==0 && c>0) 1357c478bd9Sstevel@tonic-gate k = midbcol(i, c-1); 1367c478bd9Sstevel@tonic-gate return(k); 1377c478bd9Sstevel@tonic-gate } 138*b5514887Smuffin 139*b5514887Smuffin int 140*b5514887Smuffin midbcol(int i, int c) 1417c478bd9Sstevel@tonic-gate { 1427c478bd9Sstevel@tonic-gate int ct; 1437c478bd9Sstevel@tonic-gate while ( (ct=ctype(i,c)) == 's') 1447c478bd9Sstevel@tonic-gate c--; 1457c478bd9Sstevel@tonic-gate if (ct=='-' || ct == '=') 1467c478bd9Sstevel@tonic-gate return(ct); 1477c478bd9Sstevel@tonic-gate if (ct=barent(table[i][c].col)) 1487c478bd9Sstevel@tonic-gate return(ct); 1497c478bd9Sstevel@tonic-gate return(0); 1507c478bd9Sstevel@tonic-gate } 1517c478bd9Sstevel@tonic-gate 152*b5514887Smuffin int 153*b5514887Smuffin barent(char *s) 1547c478bd9Sstevel@tonic-gate { 1557c478bd9Sstevel@tonic-gate if (s==0) return (1); 1567c478bd9Sstevel@tonic-gate if (!point(s)) return(1); 1577c478bd9Sstevel@tonic-gate if (s[0]== '\\') s++; 1587c478bd9Sstevel@tonic-gate if (s[1]!= 0) 1597c478bd9Sstevel@tonic-gate return(0); 1607c478bd9Sstevel@tonic-gate switch(s[0]) 1617c478bd9Sstevel@tonic-gate { 1627c478bd9Sstevel@tonic-gate case '_': 1637c478bd9Sstevel@tonic-gate return('-'); 1647c478bd9Sstevel@tonic-gate case '=': 1657c478bd9Sstevel@tonic-gate return('='); 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate return(0); 1687c478bd9Sstevel@tonic-gate } 169