t20.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * 20. Miscellaneous
  12. */
  13. /* .mc - margin character */
  14. /* .ig - ignore; treated like a macro in t7.c */
  15. /* .pm - print macros and strings */
  16. void
  17. r_pm(int argc, Rune **argv)
  18. {
  19. int i;
  20. if(argc == 1){
  21. printds(0);
  22. return;
  23. }
  24. if(runestrcmp(argv[1], L("t")) == 0){
  25. printds(1);
  26. return;
  27. }
  28. for(i=1; i<argc; i++)
  29. fprint(2, "%S: %S\n", argv[i], getds(argv[i]));
  30. }
  31. void
  32. r_tm(Rune *name)
  33. {
  34. Rune *line;
  35. USED(name);
  36. line = readline(CopyMode);
  37. fprint(2, "%S\n", line);
  38. free(line);
  39. }
  40. void
  41. r_ab(Rune *name)
  42. {
  43. USED(name);
  44. r_tm(L("ab"));
  45. exits(".ab");
  46. }
  47. void
  48. r_lf(int argc, Rune **argv)
  49. {
  50. if(argc == 1)
  51. return;
  52. if(argc == 2)
  53. setlinenumber(nil, eval(argv[1]));
  54. if(argc == 3)
  55. setlinenumber(argv[2], eval(argv[1]));
  56. }
  57. void
  58. r_fl(int argc, Rune **argv)
  59. {
  60. USED(argc);
  61. USED(argv);
  62. Bflush(&bout);
  63. }
  64. void
  65. t20init(void)
  66. {
  67. addreq(L("mc"), r_warn, -1);
  68. addraw(L("tm"), r_tm);
  69. addraw(L("ab"), r_ab);
  70. addreq(L("lf"), r_lf, -1);
  71. addreq(L("pm"), r_pm, -1);
  72. addreq(L("fl"), r_fl, 0);
  73. }