t6.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * Section 6 - line length and indenting.
  12. */
  13. /* set line length */
  14. void
  15. ll(int v)
  16. {
  17. if(v == 0)
  18. v = getnr(L(".l0"));
  19. nr(L(".l0"), getnr(L(".l")));
  20. nr(L(".l"), v);
  21. }
  22. void
  23. r_ll(int argc, Rune **argv)
  24. {
  25. if(argc < 2)
  26. ll(0);
  27. else if(argv[1][0] == '+')
  28. ll(getnr(L(".l"))+evalscale(argv[1]+1, 'v'));
  29. else if(argv[1][0] == '-')
  30. ll(getnr(L(".l"))-evalscale(argv[1]+1, 'v'));
  31. else
  32. ll(evalscale(argv[1], 'm'));
  33. if(argc > 2)
  34. warn("extra arguments to .ll");
  35. }
  36. void
  37. in(int v)
  38. {
  39. nr(L(".i0"), getnr(L(".i")));
  40. nr(L(".i"), v);
  41. nr(L(".ti"), 0);
  42. /* XXX */
  43. }
  44. void
  45. r_in(int argc, Rune **argv)
  46. {
  47. br();
  48. if(argc < 2)
  49. in(getnr(L(".i0")));
  50. else if(argv[1][0] == '+')
  51. in(getnr(L(".i"))+evalscale(argv[1]+1, 'm'));
  52. else if(argv[1][0] == '-')
  53. in(getnr(L(".i"))-evalscale(argv[1]+1, 'm'));
  54. else
  55. in(evalscale(argv[1], 'm'));
  56. if(argc > 3)
  57. warn("extra arguments to .in");
  58. }
  59. void
  60. ti(int v)
  61. {
  62. nr(L(".ti"), v);
  63. }
  64. void
  65. r_ti(int argc, Rune **argv)
  66. {
  67. USED(argc);
  68. br();
  69. ti(evalscale(argv[1], 'm'));
  70. }
  71. void
  72. t6init(void)
  73. {
  74. addreq(L("ll"), r_ll, -1);
  75. addreq(L("in"), r_in, -1);
  76. addreq(L("ti"), r_ti, 1);
  77. nr(L(".l"), eval(L("6.5i")));
  78. }