window20.sl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. % {DSK}WINDOW.PSL;1 4-MAR-83 16:25:00
  2. (GLISPOBJECTS
  3. (MENU (listobject (ITEMS (LISTOF ATOM))
  4. (window window))
  5. MSG ((SELECT MENU-select RESULT ATOM)))
  6. (MOUSE ANYTHING)
  7. (WINDOW (listobject (start vector)
  8. (size vector)
  9. (title string)
  10. (lastfilledline integer))
  11. PROP ((leftmargin (left + 1))
  12. (rightmargin (right - 2)))
  13. MSG ((CLEAR window-clear)
  14. (OPEN window-open)
  15. (CLOSE window-close)
  16. (movetoxy window-movetoxy)
  17. (invertvideo ((pbout escapechar)(pbout (char !p))))
  18. (normalvideo ((pbout escapechar)(pbout (char !q))))
  19. (graphicsmode (nil))
  20. (normalmode (nil))
  21. (eraseeol ((pbout escapechar)(pbout (char K))))
  22. (INVERTAREA WINDOW-INVERTAREA)
  23. (MOVETO WINDOW-MOVETO)
  24. (PRINTAT WINDOW-PRINTAT)
  25. (printatxy window-printatxy)
  26. (PRETTYPRINTAT WINDOW-PRETTYPRINTAT)
  27. (UNPRINTAT WINDOW-UNPRINTAT)
  28. (unprintatxy window-unprintatxy)
  29. (DRAWLINE WINDOW-DRAWLINE)
  30. (drawlinexy window-drawlinexy)
  31. (UNDRAWLINE WINDOW-UNDRAWLINE)
  32. (undrawlinexy window-undrawlinexy)
  33. (CENTEROFFSET WINDOW-CENTEROFFSET))
  34. supers (region) )
  35. )
  36. (GLISPGLOBALS
  37. (MOUSE MOUSE)
  38. )
  39. (glispconstants
  40. (windowcharwidth 8 integer)
  41. (windowlineyspacing 12 integer)
  42. (verticalbarchar 73 integer)
  43. (horizontalbarchar 33 integer)
  44. (escapechar 27 integer)
  45. (blankchar 32 integer)
  46. )
  47. % Initialize graphics routines.
  48. (dg window-init (w:window)
  49. )
  50. % Done with graphics
  51. (dg window-term (w:window)
  52. )
  53. % Open a graphics window.
  54. (dg window-open (w:window)
  55. (prog (ttl nbl)
  56. (send w movetoxy w:left + 1 w:top)
  57. (ttl _ w:title or " ")
  58. (l _ ttl:length)
  59. (send w invertvideo)
  60. (if ttl:length > w:width - 2
  61. then (ttl _ (substring ttl 1 w:width - 2)))
  62. (nbl _ (w:width - ttl:length)/2 - 1)
  63. (printnc nbl blankchar)
  64. (prin2 ttl)
  65. (printnc (w:width - ttl:length - nbl - 2) blankchar)
  66. (send w normalvideo)
  67. (terpri)
  68. (w:lastfilledline _ w:bottom + 1)
  69. (send w movetoxy w:left w:top)
  70. (pbout verticalbarchar)
  71. (send w movetoxy w:right - 1 w:top)
  72. (pbout verticalbarchar)
  73. (send w movetoxy w:left w:bottom)
  74. (pbout verticalbarchar)
  75. (printnc w:width - 2 horizontalbarchar)
  76. (pbout verticalbarchar)
  77. (terpri)
  78. (send w clear)
  79. (send w movetoxy 0 2))
  80. )
  81. % Close a graphics window.
  82. (dg window-close (w:window)
  83. )
  84. % GSN 2-FEB-83 13:57
  85. (DG WINDOW-CENTEROFFSET (W:WINDOW V:VECTOR)
  86. (SEND W:REGION CENTEROFFSET V))
  87. % GSN 28-FEB-83 16:10
  88. (DG WINDOW-DRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  89. (if from:y=to:y then (send w moveto from)
  90. (printnc (to:x - from:x + 1) horizontalbarchar)))
  91. % GSN 28-FEB-83 16:58
  92. (DG WINDOW-INVERTAREA (W:WINDOW AREA:REGION)
  93. nil)
  94. % GSN 13-JAN-83 15:29
  95. (DG WINDOW-MOVETO (W:WINDOW POS:VECTOR)
  96. (send w movetoxy pos:x pos:y))
  97. % Move to position specified as separate x and y coordinates.
  98. (dg window-movetoxy (w:window x:integer y:integer)
  99. (if x < 0 then (x _ 0) elseif x > 79 then (x _ 79))
  100. (if y < 0 then (y _ 0) elseif Y > 23 then (y _ 23))
  101. (pbout escapechar)
  102. (pbout (char Y))
  103. (pbout (55 - y))
  104. (pbout (32 + x)))
  105. % GSN 2-MAR-83 13:58
  106. (DG WINDOW-PRETTYPRINTAT (W:WINDOW VALUE POSITION:VECTOR)
  107. (send w printat value position))
  108. % GSN 13-JAN-83 16:25
  109. (DG WINDOW-PRINTAT (W:WINDOW S:STRING POS:VECTOR)
  110. (send w moveto pos)
  111. (prin2 s))
  112. % GSN 28-FEB-83 16:10
  113. (DG WINDOW-unDRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
  114. (if from:y=to:y then (send w moveto from)
  115. (printnc (to:x - from:x + 1) blankchar)))
  116. % GSN 13-JAN-83 16:24
  117. (DG WINDOW-UNPRINTAT (W:WINDOW S:STRING POS:VECTOR)
  118. (send w moveto pos)
  119. (printnc s:length " "))
  120. % Present a pop-up menu and select an item from it. GSN 14 March 83
  121. (dg menu-select (m:menu)
  122. (prog (maxw i n)
  123. (maxw _ 0)
  124. (for x in m:items do (maxw _ (max maxw x:pname:length)))
  125. (maxw _ (min maxw 20))
  126. (m:window _ (a window with start = menustart
  127. size = (a vector with x = (maxw + 5)* windowcharwidth
  128. y = (min (length n:items) 19) * windowlineyspacing)
  129. title = "Menu"))
  130. (send m:window open)
  131. (I _ 0)
  132. (for x in m:items do
  133. (i _+ 1)
  134. (send m:window printatxy (concat (gevstringify i)
  135. (if i<10 then " " else " ")
  136. (gevstringify x))))
  137. (send m:window movetoxy 0 2)
  138. (send m:window eraseeol)
  139. lp
  140. (send m:window movetoxy 0 2)
  141. (prin2 "Menu:")
  142. (n _ (read))
  143. (if n is integer and n > 0 and n <= (length m:items)
  144. then (return (nth m:items n))
  145. else (prin1 n)
  146. (prin2 " ?")
  147. (send m:window eraseeol)
  148. (go lp) )))
  149. % Print the same character n times.
  150. (dg printnc (n:integer c:integer)
  151. (while n > 0 do (n _- 1) (prin2 c)))
  152. (dg window-clear (w:window)
  153. (prog (y)
  154. (y _ w:top - 1)
  155. (while y >= w:lastfilledline do
  156. (send w movetoxy w:left y)
  157. (prin2 verticalbarchar)
  158. (send w eraseeol)
  159. (send w movetoxy w:right - 1 y)
  160. (prin2 verticalbarchar)
  161. (y _- 1))
  162. ))