frame.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 <stdio.h>
  10. #include <stdlib.h>
  11. #include "grap.h"
  12. #include "y.tab.h"
  13. double frame_ht; /* default frame height */
  14. double frame_wid; /* and width */
  15. int nsides = 0; /* how many sides given on this frame */
  16. char *sides[] = {
  17. "\tline from Frame.nw to Frame.ne",
  18. "\tline from Frame.sw to Frame.se",
  19. "\tline from Frame.sw to Frame.nw",
  20. "\tline from Frame.se to Frame.ne"
  21. };
  22. char *newsides[4] = { 0, 0, 0, 0 }; /* filled in later */
  23. void frame(void) /* pump out frame definition, reset for next */
  24. {
  25. int i;
  26. fprintf(tfd, "\tframeht = %g\n", frame_ht);
  27. fprintf(tfd, "\tframewid = %g\n", frame_wid);
  28. fprintf(tfd, "Frame:\tbox ht frameht wid framewid with .sw at 0,0 ");
  29. if (nsides == 0)
  30. fprintf(tfd, "\n");
  31. else {
  32. fprintf(tfd, "invis\n");
  33. for (i = 0; i < 4; i++) {
  34. if (newsides[i]) {
  35. fprintf(tfd, "%s\n", newsides[i]);
  36. free(newsides[i]);
  37. newsides[i] = 0;
  38. } else
  39. fprintf(tfd, "%s\n", sides[i]);
  40. }
  41. nsides = 0;
  42. }
  43. }
  44. void frameht(double f) /* set height of frame */
  45. {
  46. frame_ht = f;
  47. }
  48. void framewid(double f) /* set width of frame */
  49. {
  50. frame_wid = f;
  51. }
  52. void frameside(int type, Attr *desc) /* create and remember sides */
  53. {
  54. int n;
  55. char buf[100];
  56. nsides++;
  57. n = 0;
  58. switch (type) {
  59. case 0: /* no side specified; kludge up all */
  60. frameside(TOP, desc);
  61. frameside(BOT, desc);
  62. frameside(LEFT, desc);
  63. frameside(RIGHT, desc);
  64. return;
  65. case TOP: n = 0; break;
  66. case BOT: n = 1; break;
  67. case LEFT: n = 2; break;
  68. case RIGHT: n = 3; break;
  69. }
  70. sprintf(buf, "%s %s", sides[n], desc_str(desc));
  71. newsides[n] = tostring(buf);
  72. }