t11.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "a.h"
  10. /*
  11. * 11. Local Horizontal and Vertical Motions, and the Width Function.
  12. */
  13. int
  14. e_0(void)
  15. {
  16. /* digit-width space */
  17. return ' ';
  18. }
  19. int
  20. dv(int d)
  21. {
  22. Rune sub[6];
  23. d += getnr(L(".dv"));
  24. nr(L(".dv"), d);
  25. runestrcpy(sub, L("<sub>"));
  26. sub[0] = Ult;
  27. sub[4] = Ugt;
  28. if(d < 0){
  29. sub[3] = 'p';
  30. ihtml(L(".dv"), sub);
  31. }else if(d > 0)
  32. ihtml(L(".dv"), sub);
  33. else
  34. ihtml(L(".dv"), nil);
  35. return 0;
  36. }
  37. int
  38. e_v(void)
  39. {
  40. dv(eval(getqarg()));
  41. return 0;
  42. }
  43. int
  44. e_u(void)
  45. {
  46. dv(eval(L("-0.5m")));
  47. return 0;
  48. }
  49. int
  50. e_d(void)
  51. {
  52. dv(eval(L("0.5m")));
  53. return 0;
  54. }
  55. int
  56. e_r(void)
  57. {
  58. dv(eval(L("-1m")));
  59. return 0;
  60. }
  61. int
  62. e_h(void)
  63. {
  64. getqarg();
  65. return 0;
  66. }
  67. int
  68. e_w(void)
  69. {
  70. Rune *a;
  71. Rune buf[40];
  72. a = getqarg();
  73. runesnprint(buf, sizeof buf, "%ld", runestrlen(a));
  74. pushinputstring(buf);
  75. nr(L("st"), 0);
  76. nr(L("sb"), 0);
  77. nr(L("ct"), 0);
  78. return 0;
  79. }
  80. int
  81. e_k(void)
  82. {
  83. getname();
  84. warn("%Ck not available", backslash);
  85. return 0;
  86. }
  87. void
  88. t11init(void)
  89. {
  90. addesc('|', e_nop, 0);
  91. addesc('^', e_nop, 0);
  92. addesc('v', e_v, 0);
  93. addesc('h', e_h, 0);
  94. addesc('w', e_w, 0);
  95. addesc('0', e_0, 0);
  96. addesc('u', e_u, 0);
  97. addesc('d', e_d, 0);
  98. addesc('r', e_r, 0);
  99. addesc('k', e_k, 0);
  100. }