windowcrt.sl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. % WINDOWCRT.SL.11 07 April 83
  2. % derived from <NOVAK>WINDOWCRT.PSL.1 20-Mar-83 12:40:45
  3. % Written by Gordon Novak Jr.
  4. % Copyright (c) 1983 Hewlett-Packard
  5. (GLOBAL '(MENUSTART))
  6. (GLISPOBJECTS
  7. (MENU (LISTOBJECT (ITEMS (LISTOF ATOM))
  8. (WINDOW WINDOW))
  9. MSG ((SELECT MENU-SELECT RESULT ATOM)))
  10. (MOUSE ANYTHING)
  11. (WINDOW (LISTOBJECT (START VECTOR)
  12. (SIZE VECTOR)
  13. (TITLE STRING)
  14. (LASTFILLEDLINE INTEGER))
  15. PROP ((YPOSITION (LASTFILLEDLINE))
  16. (LEFTMARGIN (1))
  17. (RIGHTMARGIN (WIDTH - 2)))
  18. MSG ((CLEAR WINDOW-CLEAR)
  19. (OPEN WINDOW-OPEN)
  20. (CLOSE WINDOW-CLOSE)
  21. (INVERTAREA WINDOW-INVERTAREA OPEN T)
  22. (MOVETOXY WINDOW-MOVETOXY OPEN T)
  23. (MOVETO WINDOW-MOVETO OPEN T)
  24. (PRINTAT WINDOW-PRINTAT OPEN T)
  25. (PRETTYPRINTAT WINDOW-PRETTYPRINTAT OPEN T)
  26. (UNPRINTAT WINDOW-UNPRINTAT OPEN T)
  27. (DRAWLINE WINDOW-DRAWLINE OPEN T)
  28. (UNDRAWLINE WINDOW-UNDRAWLINE OPEN T)
  29. (CENTEROFFSET WINDOW-CENTEROFFSET OPEN T))
  30. SUPERS (REGION))
  31. )
  32. (GLISPGLOBALS
  33. (MOUSE MOUSE)
  34. )
  35. (GLISPCONSTANTS
  36. (WINDOWCHARWIDTH 1 INTEGER)
  37. (WINDOWLINEYSPACING 1 INTEGER)
  38. )
  39. (SETQ MOUSE 'MOUSE)
  40. (SETQ GEVMENUWINDOW NIL)
  41. (SETQ MENUSTART (A VECTOR WITH X = 50 Y = 3))
  42. % edited: 16-Mar-83 15:04
  43. % Select an item from a pop-up menu.
  44. (DG MENU-SELECT (M:MENU)
  45. (PROG (MAXW I N SAVEESC SAVEGLQ SAVEGCG RESULT)
  46. (if ~gevactiveflg then (geventer))
  47. (SAVEGLQ _ GLQUIETFLG)
  48. (GLQUIETFLG _ T)
  49. (MAXW_0)
  50. (FOR X IN M:ITEMS DO (MAXW_ (MAX MAXW X:PNAME:LENGTH)))
  51. (IF MAXW > 20 THEN (MAXW _ 20))
  52. (M:WINDOW _ (A WINDOW WITH START = MENUSTART SIZE =
  53. (A VECTOR WITH X = (MAXW + 5)
  54. *WINDOWCHARWIDTH Y = (MIN (LENGTH M:ITEMS)
  55. + 1 19)
  56. *WINDOWLINEYSPACING)
  57. TITLE = "Menu"))
  58. (SEND M:WINDOW OPEN)
  59. (I_0)
  60. (FOR X IN M:ITEMS DO (I _+ 1)
  61. (SEND M:WINDOW PRINTAT (CONCAT (GEVSTRINGIFY I)
  62. (concat (IF I<10 THEN " " ELSE " ")
  63. (gevstringify X)))
  64. (A VECTOR WITH X = 1 Y = M:WINDOW:HEIGHT - I)))
  65. (SEND M:WINDOW MOVETOXY 0 -1)
  66. (SEND TERMINAL ERASEEOL)
  67. LP
  68. (SEND M:WINDOW MOVETOXY 0 -1)
  69. (SEND TERMINAL PRINTSTRING "Menu: ")
  70. (SEND TERMINAL ERASEEOL)
  71. (echoon)
  72. (N _ (READ))
  73. (echooff)
  74. (IF N IS INTEGER AND N>0 AND N<= (LENGTH M:ITEMS)
  75. THEN
  76. (RESULT _ (CAR (PNth M:ITEMS N)))
  77. (GO OUT)
  78. ELSEIF N = 'Q
  79. THEN
  80. (RESULT _ NIL)
  81. (GO OUT)
  82. ELSE
  83. (PRIN1 N)
  84. (SPACES 1)
  85. (SEND TERMINAL PRINTSTRING "?")
  86. (SEND TERMINAL ERASEEOL)
  87. (GO LP))
  88. OUT
  89. (SEND M:WINDOW CLOSE)
  90. (SEND M:WINDOW MOVETOXY 0 -1)
  91. (TERPRI)
  92. (SEND TERMINAL ERASEEOL)
  93. (SETQ GLQUIETFLG SAVEGLQ)
  94. (if ~gevactiveflg then (gevexit))
  95. (RETURN RESULT)))
  96. % edited: 11-Mar-83 22:42
  97. % Print a character N times.
  98. (DG PRINTNC (N:INTEGER C:STRING)
  99. (WHILE N > 0 DO (N _- 1)
  100. (SEND TERMINAL PRINTCHAR C)))
  101. % edited: 16-Mar-83 14:02
  102. % Open a window in a H-19 terminal.
  103. (DG WINDOW-CLEAR (W:WINDOW)
  104. (PROG (TTL NBL Y NLINES)
  105. (NLINES_0)
  106. (SEND TERMINAL GRAPHICSMODE)
  107. (Y _ W:HEIGHT - 1)
  108. (WHILE Y >= W:LASTFILLEDLINE DO (SEND W MOVETOXY 0 Y)
  109. (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
  110. (IF Y<W:TOP THEN (SEND TERMINAL ERASEEOL))
  111. (SEND W MOVETOXY W:WIDTH - 1 Y)
  112. (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
  113. (IF (NLINES _+ 1)
  114. >3 THEN (TERPRI)
  115. (NLINES_0))
  116. (Y_-1))
  117. (SEND TERMINAL NORMALMODE)
  118. (SEND W MOVETOXY 0 -1)
  119. (TERPRI)
  120. (W:LASTFILLEDLINE _ W:HEIGHT)
  121. (SEND W MOVETOXY 0 -1)))
  122. (DG WINDOW-CLOSE (W:WINDOW)
  123. (PROG (Y NLINES)
  124. (Y _ W:HEIGHT)
  125. (NLINES _ 0)
  126. (WHILE Y >= 0 DO (SEND W MOVETOXY 0 Y)
  127. (SEND TERMINAL ERASEEOL)
  128. (IF (NLINES _+ 1)
  129. > 8 THEN (TERPRI)
  130. (NLINES _ 0))
  131. (Y _- 1))
  132. (TERPRI)))
  133. % edited: 12-Mar-83 15:22
  134. (DG WINDOW-DRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  135. (IF FROM:Y=TO:Y THEN (SEND W MOVETO FROM)
  136. (PRINTNC (TO:X - FROM:X + 1)
  137. HORIZONTALLINECHAR)
  138. (IF FROM:Y < W:LASTFILLEDLINE THEN (W:LASTFILLEDLINE _ FROM:Y))))
  139. % edited: 12-Mar-83 15:17
  140. (DG WINDOW-INVERTAREA (W:WINDOW AREA:REGION)
  141. NIL)
  142. % edited: 12-Mar-83 15:18
  143. (DG WINDOW-MOVETO (W:WINDOW POS:VECTOR)
  144. (SEND W MOVETOXY POS:X POS:Y))
  145. % edited: 19-Mar-83 20:25
  146. % Move cursor to X-Y position relative to window.
  147. (DG WINDOW-MOVETOXY (W:WINDOW X:INTEGER Y:INTEGER)
  148. (SEND TERMINAL MOVETOXY X+W:LEFT Y+W:BOTTOM))
  149. % edited: 19-Mar-83 20:39
  150. % Open a window on a H-19 terminal.
  151. (DG WINDOW-OPEN (W:WINDOW)
  152. (PROG (TTL NBL L)
  153. (SEND W MOVETOXY 1 W:HEIGHT)
  154. (TTL _ W:TITLE OR " ")
  155. (L_TTL:LENGTH)
  156. (SEND TERMINAL INVERTVIDEO)
  157. (IF TTL:LENGTH > W:WIDTH - 2 THEN
  158. (TTL _ (SUBSTRING TTL 1 W:WIDTH - 2)))
  159. (NBL _ (W:WIDTH - TTL:LENGTH)
  160. /2 - 1)
  161. (PRINTNC NBL BLANKCHAR)
  162. (SEND TERMINAL PRINTSTRING TTL)
  163. (PRINTNC (W:WIDTH - TTL:LENGTH - NBL - 2)
  164. BLANKCHAR)
  165. (SEND TERMINAL NORMALVIDEO)
  166. (TERPRI)
  167. (SEND TERMINAL GRAPHICSMODE)
  168. (W:LASTFILLEDLINE _ 1)
  169. (SEND W MOVETOXY 0 W:HEIGHT)
  170. (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
  171. (SEND W MOVETOXY W:WIDTH - 1 W:HEIGHT)
  172. (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
  173. (SEND W MOVETOXY 0 0)
  174. (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
  175. (PRINTNC W:WIDTH - 2 HORIZONTALBARCHAR)
  176. (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
  177. (send terminal eraseeol)
  178. (SEND TERMINAL NORMALMODE)
  179. (TERPRI)
  180. (SEND W CLEAR)
  181. (SEND W MOVETOXY 0 -1)))
  182. % edited: 12-Mar-83 17:03
  183. (DG WINDOW-PRETTYPRINTAT (W:WINDOW VALUE POSITION:VECTOR)
  184. (SEND W MOVETO POSITION)(RESETLST (RESETSAVE SYSPRETTYFLG T)
  185. (RESETSAVE TTYLINELENGTH
  186. (W:WIDTH - POSITION:X - 1))
  187. (SHOWPRINT VALUE)
  188. (W:LASTFILLEDLINE _ 1)))
  189. % edited: 16-Mar-83 14:18
  190. (DG WINDOW-PRINTAT (W:WINDOW S:STRING POS:VECTOR)
  191. (IF POS:Y > 0 THEN (SEND W MOVETO POS)
  192. (SEND TERMINAL PRINTSTRING S)
  193. (TERPRI)
  194. (IF POS:Y < W:LASTFILLEDLINE THEN (W:LASTFILLEDLINE _ POS:Y))))
  195. % edited: 12-Mar-83 15:23
  196. (DG WINDOW-UNDRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  197. (IF FROM:Y=TO:Y THEN (SEND W MOVETO FROM)
  198. (PRINTNC (TO:X - FROM:X + 1)
  199. BLANKCHAR)))
  200. % edited: 16-Mar-83 14:19
  201. (DG WINDOW-UNPRINTAT (W:WINDOW S:STRING POS:VECTOR)
  202. (IF POS:Y > 0 THEN (SEND W MOVETO POS)
  203. (PRINTNC S:LENGTH BLANKCHAR)))