tv.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* tv.c: draw vertical lines */
  2. # include "t.h"
  3. void
  4. drawvert(int start, int end, int c, int lwid)
  5. {
  6. char *exb = 0, *ext = 0;
  7. int tp = 0, sl, ln, pos, epb, ept, vm;
  8. end++;
  9. vm = 'v';
  10. /* note: nr 35 has value of 1m outside of linesize */
  11. while (instead[end])
  12. end++;
  13. for (ln = 0; ln < lwid; ln++) {
  14. epb = ept = 0;
  15. pos = 2 * ln - lwid + 1;
  16. if (pos != tp)
  17. Bprint(&tabout, "\\h'%dp'", pos - tp);
  18. tp = pos;
  19. if (end < nlin) {
  20. if (fullbot[end] || (!instead[end] && allh(end)))
  21. epb = 2;
  22. else
  23. switch (midbar(end, c)) {
  24. case '-':
  25. exb = "1v-.5m";
  26. break;
  27. case '=':
  28. exb = "1v-.5m";
  29. epb = 1;
  30. break;
  31. }
  32. }
  33. if (lwid > 1)
  34. switch (interh(end, c)) {
  35. case THRU:
  36. epb -= 1;
  37. break;
  38. case RIGHT:
  39. epb += (ln == 0 ? 1 : -1);
  40. break;
  41. case LEFT:
  42. epb += (ln == 1 ? 1 : -1);
  43. break;
  44. }
  45. if (lwid == 1)
  46. switch (interh(end, c)) {
  47. case THRU:
  48. epb -= 1;
  49. break;
  50. case RIGHT:
  51. case LEFT:
  52. epb += 1;
  53. break;
  54. }
  55. if (start > 0) {
  56. sl = start - 1;
  57. while (sl >= 0 && instead[sl])
  58. sl--;
  59. if (sl >= 0 && (fullbot[sl] || allh(sl)))
  60. ept = 0;
  61. else if (sl >= 0)
  62. switch (midbar(sl, c)) {
  63. case '-':
  64. ext = ".5m";
  65. break;
  66. case '=':
  67. ext = ".5m";
  68. ept = -1;
  69. break;
  70. default:
  71. vm = 'm';
  72. break;
  73. }
  74. else
  75. ept = -4;
  76. } else if (start == 0 && allh(0)) {
  77. ept = 0;
  78. vm = 'm';
  79. }
  80. if (lwid > 1)
  81. switch (interh(start, c)) {
  82. case THRU:
  83. ept += 1;
  84. break;
  85. case LEFT:
  86. ept += (ln == 0 ? 1 : -1);
  87. break;
  88. case RIGHT:
  89. ept += (ln == 1 ? 1 : -1);
  90. break;
  91. }
  92. else if (lwid == 1)
  93. switch (interh(start, c)) {
  94. case THRU:
  95. ept += 1;
  96. break;
  97. case LEFT:
  98. case RIGHT:
  99. ept -= 1;
  100. break;
  101. }
  102. if (exb)
  103. Bprint(&tabout, "\\v'%s'", exb);
  104. if (epb)
  105. Bprint(&tabout, "\\v'%dp'", epb);
  106. Bprint(&tabout, "\\s\\n(%d", LSIZE);
  107. if (linsize)
  108. Bprint(&tabout, "\\v'-\\n(%dp/6u'", LSIZE);
  109. Bprint(&tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */
  110. Bprint(&tabout, "\\L'|\\n(#%cu-%s", linestop[start] + 'a' - 1,
  111. vm == 'v' ? "1v" : "\\n(35u");
  112. if (ext)
  113. Bprint(&tabout, "-(%s)", ext);
  114. if (exb)
  115. Bprint(&tabout, "-(%s)", exb);
  116. pos = ept - epb;
  117. if (pos)
  118. Bprint(&tabout, "%s%dp", pos >= 0 ? "+" : "", pos);
  119. /* the string #d is either "nl" or ".d" depending
  120. on diversions; on GCOS not the same */
  121. Bprint(&tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s",
  122. linestop[start] + 'a' - 1, vm == 'v' ? "1v" : "\\n(35u");
  123. if (ext)
  124. Bprint(&tabout, "+%s", ext);
  125. if (ept)
  126. Bprint(&tabout, "%s%dp", (-ept) > 0 ? "+" : "", (-ept));
  127. Bprint(&tabout, "'");
  128. if (linsize)
  129. Bprint(&tabout, "\\v'\\n(%dp/6u'", LSIZE);
  130. }
  131. }
  132. int
  133. midbar(int i, int c)
  134. {
  135. int k;
  136. k = midbcol(i, c);
  137. if (k == 0 && c > 0)
  138. k = midbcol(i, c - 1);
  139. return(k);
  140. }
  141. int
  142. midbcol(int i, int c)
  143. {
  144. int ct;
  145. while ( (ct = ctype(i, c)) == 's')
  146. c--;
  147. if (ct == '-' || ct == '=')
  148. return(ct);
  149. if (ct = barent(table[i][c].col))
  150. return(ct);
  151. return(0);
  152. }
  153. int
  154. barent(char *s)
  155. {
  156. if (s == 0)
  157. return (1);
  158. if (!point(s))
  159. return(0);
  160. if (s[0] == '\\')
  161. s++;
  162. if (s[1] != 0)
  163. return(0);
  164. switch (s[0]) {
  165. case '_':
  166. return('-');
  167. case '=':
  168. return('=');
  169. }
  170. return(0);
  171. }