windowhrd.sl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. % WINDOWHRD.SL.7 07 April 83
  2. % Window package for Methius display on HP 9836
  3. % derived from <NOVAK>WINDOWCRT.PSL.1 20-Mar-83 12:40:45
  4. (GLOBAL '(MENUSTART))
  5. (GLISPOBJECTS
  6. (MENU (LISTOBJECT (ITEMS (LISTOF ATOM))
  7. (WINDOW WINDOW))
  8. MSG ((SELECT MENU-SELECT RESULT ATOM)))
  9. (MOUSE ANYTHING)
  10. (WINDOW (LISTOBJECT (START VECTOR)
  11. (SIZE VECTOR)
  12. (TITLE STRING)
  13. (LASTFILLEDLINE INTEGER))
  14. PROP ((YPOSITION (LASTFILLEDLINE))
  15. (LEFTMARGIN (1))
  16. (RIGHTMARGIN (WIDTH - 2)))
  17. MSG ((CLEAR WINDOW-CLEAR)
  18. (OPEN WINDOW-OPEN)
  19. (CLOSE WINDOW-CLOSE)
  20. (INVERTAREA WINDOW-INVERTAREA OPEN T)
  21. (MOVETOXY WINDOW-MOVETOXY OPEN T)
  22. (MOVETO WINDOW-MOVETO OPEN T)
  23. (PRINTAT WINDOW-PRINTAT OPEN T)
  24. (PRETTYPRINTAT WINDOW-PRETTYPRINTAT OPEN T)
  25. (UNPRINTAT WINDOW-UNPRINTAT OPEN T)
  26. (DRAWLINE WINDOW-DRAWLINE OPEN T)
  27. (UNDRAWLINE WINDOW-UNDRAWLINE OPEN T)
  28. (PRINTCHAR WINDOW-PRINTCHAR OPEN T)
  29. (PRINTSTRING WINDOW-PRINTSTRING)
  30. (PRINTNC WINDOW-PRINTNC)
  31. (CENTEROFFSET WINDOW-CENTEROFFSET OPEN T))
  32. SUPERS (REGION))
  33. )
  34. (GLISPGLOBALS
  35. (MOUSE MOUSE)
  36. )
  37. (GLISPCONSTANTS
  38. (WINDOWCHARWIDTH 8 INTEGER)
  39. (WINDOWLINEYSPACING 16 INTEGER)
  40. )
  41. (SETQ MOUSE 'MOUSE)
  42. (SETQ GEVMENUWINDOW NIL)
  43. (SETQ MENUSTART (A VECTOR WITH X = 500 Y = 1))
  44. % edited: 16-Mar-83 15:04
  45. % Select an item from a pop-up menu.
  46. (DG MENU-SELECT (M:MENU)
  47. (PROG (MAXW I N SAVEESC SAVEGLQ SAVEGCG RESULT)
  48. (if ~gevactiveflg then (geventer))
  49. (SAVEGLQ _ GLQUIETFLG)
  50. (GLQUIETFLG _ T)
  51. (MAXW_0)
  52. (FOR X IN M:ITEMS DO (MAXW_ (MAX MAXW X:PNAME:LENGTH)))
  53. (IF MAXW > 20 THEN (MAXW _ 20))
  54. (M:WINDOW _ (A WINDOW WITH START = MENUSTART SIZE =
  55. (A VECTOR WITH X = (MAXW + 5)
  56. *WINDOWCHARWIDTH Y = (MIN (LENGTH M:ITEMS)
  57. + 1 19)
  58. *WINDOWLINEYSPACING)
  59. TITLE = "Menu"))
  60. (SEND M:WINDOW OPEN)
  61. (I_0)
  62. (FOR X IN M:ITEMS DO (I _+ 1)
  63. (SEND M:WINDOW PRINTAT (CONCAT (GEVSTRINGIFY I)
  64. (concat (IF I<10 THEN " " ELSE " ")
  65. (gevstringify X)))
  66. (A VECTOR WITH X = 1 Y = M:WINDOW:HEIGHT
  67. - I * windowlineyspacing)))
  68. LP
  69. (PRIN1 "Menu: ")
  70. (N _ (READ))
  71. (IF N IS INTEGER AND N>0 AND N<= (LENGTH M:ITEMS)
  72. THEN
  73. (RESULT _ (CAR (PNth M:ITEMS N)))
  74. (GO OUT)
  75. ELSEIF N = 'Q
  76. THEN
  77. (RESULT _ NIL)
  78. (GO OUT)
  79. ELSE
  80. (PRIN1 N)
  81. (SPACES 1)
  82. (PRINC "?")
  83. (terpri)
  84. (GO LP))
  85. OUT
  86. (SEND M:WINDOW CLOSE)
  87. (TERPRI)
  88. (SETQ GLQUIETFLG SAVEGLQ)
  89. (if ~gevactiveflg then (gevexit))
  90. (RETURN RESULT)))
  91. % edited: 16-Mar-83 14:02
  92. % Open a window in a H-19 terminal.
  93. (DG WINDOW-CLEAR (W:WINDOW)
  94. (PROG ()
  95. (M-ERASE W:LEFT W:BOTTOM W:RIGHT W:TOP)
  96. (M-RECT-OUTLINE W:LEFT W:BOTTOM W:RIGHT W:TOP) ))
  97. (DG WINDOW-CLOSE (W:WINDOW)
  98. (M-ERASE W:LEFT W:BOTTOM W:RIGHT W:TOP)
  99. )
  100. % edited: 12-Mar-83 15:22
  101. (DG WINDOW-DRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  102. (M-VECTOR FROM:X FROM:Y TO:X TO:Y))
  103. % edited: 12-Mar-83 15:17
  104. (DG WINDOW-INVERTAREA (W:WINDOW AREA:REGION)
  105. NIL)
  106. % edited: 12-Mar-83 15:18
  107. (DG WINDOW-MOVETO (W:WINDOW POS:VECTOR)
  108. (SEND W MOVETOXY POS:X POS:Y))
  109. % edited: 19-Mar-83 20:25
  110. % Move cursor to X-Y position relative to window.
  111. (DG WINDOW-MOVETOXY (W:WINDOW X:INTEGER Y:INTEGER)
  112. (M-MOVEP1 X+W:LEFT Y+W:BOTTOM))
  113. % edited: 19-Mar-83 20:39
  114. % Open a window on a terminal.
  115. (DG WINDOW-OPEN (W:WINDOW)
  116. (SEND W CLEAR))
  117. % edited: 12-Mar-83 17:03
  118. (DG WINDOW-PRETTYPRINTAT (W:WINDOW VALUE POSITION:VECTOR)
  119. (SEND W PRINTAT VALUE POSITION))
  120. % edited: 16-Mar-83 14:18
  121. (DG WINDOW-PRINTAT (W:WINDOW S:STRING POS:VECTOR)
  122. (IF POS:Y > 0 THEN (SEND W MOVETO POS)
  123. (SEND W PRINTSTRING S)
  124. (IF POS:Y < W:LASTFILLEDLINE THEN (W:LASTFILLEDLINE _ POS:Y))))
  125. % edited: 12-Mar-83 15:23
  126. (DG WINDOW-UNDRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  127. NIL)
  128. % edited: 16-Mar-83 14:19
  129. (DG WINDOW-UNPRINTAT (W:WINDOW S:STRING POS:VECTOR)
  130. (IF POS:Y > 0 THEN (SEND W MOVETO POS)
  131. (SEND W PRINTNC S:LENGTH " ")))
  132. % edited: 11-Mar-83 22:42
  133. % Print a character N times.
  134. (DG WINDOW-PRINTNC (W:WINDOW N:INTEGER C:STRING)
  135. (WHILE N > 0 DO (N _- 1)
  136. (SEND W PRINTCHAR C)))
  137. % Print a character on the display
  138. (DG WINDOW-PRINTCHAR (W:WINDOW S:STRING)
  139. (M-CHAR (INDX S 0)))
  140. % Print a string on the display.
  141. (DG WINDOW-PRINTSTRING (W:WINDOW S:STRING)
  142. (PROG (L:INTEGER I)
  143. (S _ (GEVSTRINGIFY S))
  144. (L _ (SIZE S))
  145. (I _ 0)
  146. (WHILE I <= L DO (M-CHAR (INDX S I))
  147. (I _+ 1)) ))