t11.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include "a.h"
  2. /*
  3. * 11. Local Horizontal and Vertical Motions, and the Width Function.
  4. */
  5. int
  6. e_0(void)
  7. {
  8. /* digit-width space */
  9. return ' ';
  10. }
  11. int
  12. dv(int d)
  13. {
  14. Rune sub[6];
  15. d += getnr(L(".dv"));
  16. nr(L(".dv"), d);
  17. runestrcpy(sub, L("<sub>"));
  18. sub[0] = Ult;
  19. sub[4] = Ugt;
  20. if(d < 0){
  21. sub[3] = 'p';
  22. ihtml(L(".dv"), sub);
  23. }else if(d > 0)
  24. ihtml(L(".dv"), sub);
  25. else
  26. ihtml(L(".dv"), nil);
  27. return 0;
  28. }
  29. int
  30. e_v(void)
  31. {
  32. dv(eval(getqarg()));
  33. return 0;
  34. }
  35. int
  36. e_u(void)
  37. {
  38. dv(eval(L("-0.5m")));
  39. return 0;
  40. }
  41. int
  42. e_d(void)
  43. {
  44. dv(eval(L("0.5m")));
  45. return 0;
  46. }
  47. int
  48. e_r(void)
  49. {
  50. dv(eval(L("-1m")));
  51. return 0;
  52. }
  53. int
  54. e_h(void)
  55. {
  56. getqarg();
  57. return 0;
  58. }
  59. int
  60. e_w(void)
  61. {
  62. Rune *a;
  63. Rune buf[40];
  64. a = getqarg();
  65. runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
  66. pushinputstring(buf);
  67. nr(L("st"), 0);
  68. nr(L("sb"), 0);
  69. nr(L("ct"), 0);
  70. return 0;
  71. }
  72. int
  73. e_k(void)
  74. {
  75. getname();
  76. warn("%Ck not available", backslash);
  77. return 0;
  78. }
  79. void
  80. t11init(void)
  81. {
  82. addesc('|', e_nop, 0);
  83. addesc('^', e_nop, 0);
  84. addesc('v', e_v, 0);
  85. addesc('h', e_h, 0);
  86. addesc('w', e_w, 0);
  87. addesc('0', e_0, 0);
  88. addesc('u', e_u, 0);
  89. addesc('d', e_d, 0);
  90. addesc('r', e_r, 0);
  91. addesc('k', e_k, 0);
  92. }