123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- % WINDOWCRT.SL.11 07 April 83
- % derived from <NOVAK>WINDOWCRT.PSL.1 20-Mar-83 12:40:45
- % Written by Gordon Novak Jr.
- % Copyright (c) 1983 Hewlett-Packard
- (GLOBAL '(MENUSTART))
- (GLISPOBJECTS
- (MENU (LISTOBJECT (ITEMS (LISTOF ATOM))
- (WINDOW WINDOW))
- MSG ((SELECT MENU-SELECT RESULT ATOM)))
- (MOUSE ANYTHING)
- (WINDOW (LISTOBJECT (START VECTOR)
- (SIZE VECTOR)
- (TITLE STRING)
- (LASTFILLEDLINE INTEGER))
- PROP ((YPOSITION (LASTFILLEDLINE))
- (LEFTMARGIN (1))
- (RIGHTMARGIN (WIDTH - 2)))
- MSG ((CLEAR WINDOW-CLEAR)
- (OPEN WINDOW-OPEN)
- (CLOSE WINDOW-CLOSE)
- (INVERTAREA WINDOW-INVERTAREA OPEN T)
- (MOVETOXY WINDOW-MOVETOXY OPEN T)
- (MOVETO WINDOW-MOVETO OPEN T)
- (PRINTAT WINDOW-PRINTAT OPEN T)
- (PRETTYPRINTAT WINDOW-PRETTYPRINTAT OPEN T)
- (UNPRINTAT WINDOW-UNPRINTAT OPEN T)
- (DRAWLINE WINDOW-DRAWLINE OPEN T)
- (UNDRAWLINE WINDOW-UNDRAWLINE OPEN T)
- (CENTEROFFSET WINDOW-CENTEROFFSET OPEN T))
- SUPERS (REGION))
- )
- (GLISPGLOBALS
- (MOUSE MOUSE)
- )
- (GLISPCONSTANTS
- (WINDOWCHARWIDTH 1 INTEGER)
- (WINDOWLINEYSPACING 1 INTEGER)
- )
- (SETQ MOUSE 'MOUSE)
- (SETQ GEVMENUWINDOW NIL)
- (SETQ MENUSTART (A VECTOR WITH X = 50 Y = 3))
- % edited: 16-Mar-83 15:04
- % Select an item from a pop-up menu.
- (DG MENU-SELECT (M:MENU)
- (PROG (MAXW I N SAVEESC SAVEGLQ SAVEGCG RESULT)
- (if ~gevactiveflg then (geventer))
- (SAVEGLQ _ GLQUIETFLG)
- (GLQUIETFLG _ T)
- (MAXW_0)
- (FOR X IN M:ITEMS DO (MAXW_ (MAX MAXW X:PNAME:LENGTH)))
- (IF MAXW > 20 THEN (MAXW _ 20))
- (M:WINDOW _ (A WINDOW WITH START = MENUSTART SIZE =
- (A VECTOR WITH X = (MAXW + 5)
- *WINDOWCHARWIDTH Y = (MIN (LENGTH M:ITEMS)
- + 1 19)
- *WINDOWLINEYSPACING)
- TITLE = "Menu"))
- (SEND M:WINDOW OPEN)
- (I_0)
- (FOR X IN M:ITEMS DO (I _+ 1)
- (SEND M:WINDOW PRINTAT (CONCAT (GEVSTRINGIFY I)
- (concat (IF I<10 THEN " " ELSE " ")
- (gevstringify X)))
- (A VECTOR WITH X = 1 Y = M:WINDOW:HEIGHT - I)))
- (SEND M:WINDOW MOVETOXY 0 -1)
- (SEND TERMINAL ERASEEOL)
- LP
- (SEND M:WINDOW MOVETOXY 0 -1)
- (SEND TERMINAL PRINTSTRING "Menu: ")
- (SEND TERMINAL ERASEEOL)
- (echoon)
- (N _ (READ))
- (echooff)
- (IF N IS INTEGER AND N>0 AND N<= (LENGTH M:ITEMS)
- THEN
- (RESULT _ (CAR (PNth M:ITEMS N)))
- (GO OUT)
- ELSEIF N = 'Q
- THEN
- (RESULT _ NIL)
- (GO OUT)
- ELSE
- (PRIN1 N)
- (SPACES 1)
- (SEND TERMINAL PRINTSTRING "?")
- (SEND TERMINAL ERASEEOL)
- (GO LP))
- OUT
- (SEND M:WINDOW CLOSE)
- (SEND M:WINDOW MOVETOXY 0 -1)
- (TERPRI)
- (SEND TERMINAL ERASEEOL)
- (SETQ GLQUIETFLG SAVEGLQ)
- (if ~gevactiveflg then (gevexit))
- (RETURN RESULT)))
- % edited: 11-Mar-83 22:42
- % Print a character N times.
- (DG PRINTNC (N:INTEGER C:STRING)
- (WHILE N > 0 DO (N _- 1)
- (SEND TERMINAL PRINTCHAR C)))
- % edited: 16-Mar-83 14:02
- % Open a window in a H-19 terminal.
- (DG WINDOW-CLEAR (W:WINDOW)
- (PROG (TTL NBL Y NLINES)
- (NLINES_0)
- (SEND TERMINAL GRAPHICSMODE)
- (Y _ W:HEIGHT - 1)
- (WHILE Y >= W:LASTFILLEDLINE DO (SEND W MOVETOXY 0 Y)
- (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
- (IF Y<W:TOP THEN (SEND TERMINAL ERASEEOL))
- (SEND W MOVETOXY W:WIDTH - 1 Y)
- (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
- (IF (NLINES _+ 1)
- >3 THEN (TERPRI)
- (NLINES_0))
- (Y_-1))
- (SEND TERMINAL NORMALMODE)
- (SEND W MOVETOXY 0 -1)
- (TERPRI)
- (W:LASTFILLEDLINE _ W:HEIGHT)
- (SEND W MOVETOXY 0 -1)))
- (DG WINDOW-CLOSE (W:WINDOW)
- (PROG (Y NLINES)
- (Y _ W:HEIGHT)
- (NLINES _ 0)
- (WHILE Y >= 0 DO (SEND W MOVETOXY 0 Y)
- (SEND TERMINAL ERASEEOL)
- (IF (NLINES _+ 1)
- > 8 THEN (TERPRI)
- (NLINES _ 0))
- (Y _- 1))
- (TERPRI)))
- % edited: 12-Mar-83 15:22
- (DG WINDOW-DRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
- (IF FROM:Y=TO:Y THEN (SEND W MOVETO FROM)
- (PRINTNC (TO:X - FROM:X + 1)
- HORIZONTALLINECHAR)
- (IF FROM:Y < W:LASTFILLEDLINE THEN (W:LASTFILLEDLINE _ FROM:Y))))
- % edited: 12-Mar-83 15:17
- (DG WINDOW-INVERTAREA (W:WINDOW AREA:REGION)
- NIL)
- % edited: 12-Mar-83 15:18
- (DG WINDOW-MOVETO (W:WINDOW POS:VECTOR)
- (SEND W MOVETOXY POS:X POS:Y))
- % edited: 19-Mar-83 20:25
- % Move cursor to X-Y position relative to window.
- (DG WINDOW-MOVETOXY (W:WINDOW X:INTEGER Y:INTEGER)
- (SEND TERMINAL MOVETOXY X+W:LEFT Y+W:BOTTOM))
- % edited: 19-Mar-83 20:39
- % Open a window on a H-19 terminal.
- (DG WINDOW-OPEN (W:WINDOW)
- (PROG (TTL NBL L)
- (SEND W MOVETOXY 1 W:HEIGHT)
- (TTL _ W:TITLE OR " ")
- (L_TTL:LENGTH)
- (SEND TERMINAL INVERTVIDEO)
- (IF TTL:LENGTH > W:WIDTH - 2 THEN
- (TTL _ (SUBSTRING TTL 1 W:WIDTH - 2)))
- (NBL _ (W:WIDTH - TTL:LENGTH)
- /2 - 1)
- (PRINTNC NBL BLANKCHAR)
- (SEND TERMINAL PRINTSTRING TTL)
- (PRINTNC (W:WIDTH - TTL:LENGTH - NBL - 2)
- BLANKCHAR)
- (SEND TERMINAL NORMALVIDEO)
- (TERPRI)
- (SEND TERMINAL GRAPHICSMODE)
- (W:LASTFILLEDLINE _ 1)
- (SEND W MOVETOXY 0 W:HEIGHT)
- (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
- (SEND W MOVETOXY W:WIDTH - 1 W:HEIGHT)
- (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
- (SEND W MOVETOXY 0 0)
- (SEND TERMINAL PRINTCHAR LVERTICALBARCHAR)
- (PRINTNC W:WIDTH - 2 HORIZONTALBARCHAR)
- (SEND TERMINAL PRINTCHAR RVERTICALBARCHAR)
- (send terminal eraseeol)
- (SEND TERMINAL NORMALMODE)
- (TERPRI)
- (SEND W CLEAR)
- (SEND W MOVETOXY 0 -1)))
- % edited: 12-Mar-83 17:03
- (DG WINDOW-PRETTYPRINTAT (W:WINDOW VALUE POSITION:VECTOR)
- (SEND W MOVETO POSITION)(RESETLST (RESETSAVE SYSPRETTYFLG T)
- (RESETSAVE TTYLINELENGTH
- (W:WIDTH - POSITION:X - 1))
- (SHOWPRINT VALUE)
- (W:LASTFILLEDLINE _ 1)))
- % edited: 16-Mar-83 14:18
- (DG WINDOW-PRINTAT (W:WINDOW S:STRING POS:VECTOR)
- (IF POS:Y > 0 THEN (SEND W MOVETO POS)
- (SEND TERMINAL PRINTSTRING S)
- (TERPRI)
- (IF POS:Y < W:LASTFILLEDLINE THEN (W:LASTFILLEDLINE _ POS:Y))))
- % edited: 12-Mar-83 15:23
- (DG WINDOW-UNDRAWLINE (W:WINDOW FROM:VECTOR TO:VECTOR)
- (IF FROM:Y=TO:Y THEN (SEND W MOVETO FROM)
- (PRINTNC (TO:X - FROM:X + 1)
- BLANKCHAR)))
- % edited: 16-Mar-83 14:19
- (DG WINDOW-UNPRINTAT (W:WINDOW S:STRING POS:VECTOR)
- (IF POS:Y > 0 THEN (SEND W MOVETO POS)
- (PRINTNC S:LENGTH BLANKCHAR)))
|