home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / gfa / gfaexprt.lzh / GFAXPERT.LIB / KEY.LST < prev    next >
Encoding:
File List  |  1986-10-19  |  5.5 KB  |  198 lines

  1. ' ***************
  2. ' *** KEY.LST ***
  3. ' ***************
  4. '
  5. DEFWRD "a-z"
  6. '
  7. > PROCEDURE return.key
  8.   ' *** wait for <Return>
  9.   ' *** after pressing any other key, flashing 'RETURN' is turned off
  10.   ' *** uses Standard-Globals
  11.   LOCAL w1$,w2$,temp$,in$
  12.   CLR in$
  13.   REPEAT
  14.   UNTIL INKEY$=""
  15.   GET 0,scrn.y.max-char.height,scrn.x.max,scrn.y.max,temp$
  16.   w1$="<RETURN>"
  17.   w2$=SPACE$(8)
  18.   PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;
  19.   WHILE in$=""                              ! wait for any key
  20.     PAUSE 30
  21.     SWAP w1$,w2$
  22.     PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;
  23.     in$=INKEY$
  24.   WEND
  25.   PUT 0,scrn.y.max-char.height,temp$,3    ! restore screen
  26.   WHILE in$<>return$                      ! wait for <Return>
  27.     in$=INKEY$
  28.   WEND
  29. RETURN
  30. ' **********
  31. '
  32. > PROCEDURE bell.return.key
  33.   ' *** same as Procedure Return.key, but with bell-sound
  34.   ' *** bell turned off after pressing any key
  35.   ' *** uses Standard-Globals and Procedure Return.key
  36.   LOCAL w1$,w2$,temp$,b1$,b2$,in$
  37.   CLR in$
  38.   REPEAT
  39.   UNTIL INKEY$=""
  40.   GET 0,scrn.y.max-char.height,scrn.x.max,scrn.y.max,temp$
  41.   w1$="<RETURN>"
  42.   w2$=SPACE$(8)
  43.   b1$=bel$
  44.   b2$=""
  45.   PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;b1$;
  46.   WHILE in$=""                ! wait for any key
  47.     PAUSE 30
  48.     SWAP w1$,w2$
  49.     SWAP b1$,b2$
  50.     PRINT AT(scrn.col.max/2-3,scrn.lin.max);w1$;b1$;
  51.     in$=INKEY$
  52.   WEND
  53.   PUT 0,scrn.y.max-char.height,temp$,3
  54.   IF in$<>return$
  55.     @return.key               ! switch bell off, but wait for <Return>
  56.   ENDIF
  57. RETURN
  58. ' **********
  59. '
  60. > PROCEDURE key.click(switch!)
  61.   ' *** switch key-click on/off
  62.   IF switch!
  63.     SPOKE &H484,BSET(PEEK(&H484),0)     ! keyclick on
  64.   ELSE
  65.     SPOKE &H484,BCLR(PEEK(&H484),0)     ! keyclick off
  66.   ENDIF
  67. RETURN
  68. ' **********
  69. '
  70. > PROCEDURE key.repeat(switch!)
  71.   ' *** switch key-repeat on/off
  72.   IF switch!
  73.     SPOKE &H484,BSET(PEEK(&H484),1)     ! key-repeat on
  74.   ELSE
  75.     SPOKE &H484,BCLR(PEEK(&H484),1)     ! key-repeat off
  76.   ENDIF
  77. RETURN
  78. ' **********
  79. '
  80. > PROCEDURE caps(switch!)
  81.   ' *** switch CapsLock on/off
  82.   IF switch!
  83.     ~BIOS(11,BSET(BIOS(11,-1),4))       ! CapsLock on
  84.   ELSE
  85.     ~BIOS(11,BCLR(BIOS(11,-1),4))       ! CapsLock off
  86.   ENDIF
  87. RETURN
  88. ' **********
  89. '
  90. > PROCEDURE stop.key
  91.   ' *** temporarily stop program after : <S> , <s> of <Control> <S>
  92.   ' *** continue program after any keypress or click
  93.   ' *** use in loop where this Procedure is called regularly
  94.   LOCAL in$
  95.   in$=INKEY$
  96.   IF INSTR("Ss"+CHR$(19),in$)>0
  97.     REPEAT
  98.     UNTIL INKEY$=""
  99.     PAUSE 10
  100.     REPEAT
  101.     UNTIL INKEY$<>"" OR MOUSEK
  102.   ENDIF
  103. RETURN
  104. ' **********
  105. '
  106. > PROCEDURE break.key
  107.   ' *** this Procedure is called after : <Alternate> <Shift> <Control>
  108.   ' *** activate with : On Break Gosub Break.key
  109.   ' *** after activating, you can't enter the GFA-editor from the program !
  110.   LOCAL m$,b$,k
  111.   ON BREAK CONT
  112.   m$=" abort this| program| or| continue ?"
  113.   b$="STOP|CONT"
  114.   ALERT 3,m$,2,b$,k
  115.   IF k=1
  116.     IF EXIST("\START.GFA")
  117.       CHAIN "\START.GFA"
  118.     ELSE IF EXIST("\STARTLOW.GFA")
  119.       CHAIN "\STARTLOW.GFA"
  120.     ELSE
  121.       EDIT
  122.     ENDIF
  123.   ENDIF
  124.   ON BREAK GOSUB break.key
  125. RETURN
  126. ' **********
  127. '
  128. > PROCEDURE initio.keyget
  129.   ' *** flexible processing of any keypress
  130.   ' *** in program : DO
  131.   '                    KEYGET get.code%
  132.   '                    @keyget           ! process keypress there
  133.   '                  LOOP
  134.   '
  135.   ABSOLUTE ascii|,V:get.code%+3 ! ASCII-code of key
  136.   ABSOLUTE scan|,V:get.code%+1  ! scan-code of key
  137.   ABSOLUTE status|,V:get.code%  ! bit 0 = Right <Shift>, 1 = Left <Shift>
  138.   '                               2 = <Control>, 3 = <Alternate>, 4 = <CapsLock>
  139. RETURN
  140. ' ***
  141. > PROCEDURE keyget
  142.   ' *** process keypress here
  143.   {XBIOS(14,1)+6}=0             ! empty keyboard-buffer before leaving
  144. RETURN
  145. ' **********
  146. '
  147. > PROCEDURE initio.macro
  148.   ' *** install strings as macro for function-keys
  149.   ' *** strings may not exceed 31 characters
  150.   LOCAL i,macro$
  151.   KEYPAD &X10000         ! KEYDEF without <Alternate> activated; in editor you
  152.   RESTORE initio.macro   !                    still have to press <Alternate> !
  153.   FOR i=1 TO 20
  154.     READ macro$
  155.     KEYDEF i,macro$
  156.   NEXT i
  157.   '
  158.   initio.macro:
  159.   ' *** switch to Overwrite-mode of GFA-editor before entering text
  160.   ' *** function-keys <F1> - <F10>
  161.   DATA "F1                             "
  162.   DATA "F2                             "
  163.   DATA "F3                             "
  164.   DATA "F4                             "
  165.   DATA "F5                             "
  166.   DATA "F6                             "
  167.   DATA "F7                             "
  168.   DATA "F8                             "
  169.   DATA "F9                             "
  170.   DATA "F10                            "
  171.   ' *** function-keys <Shift> <F1> - <Shift> <F10>
  172.   DATA "S F1                           "
  173.   DATA "S F2                           "
  174.   DATA "S F3                           "
  175.   DATA "S F4                           "
  176.   DATA "S F5                           "
  177.   DATA "S F6                           "
  178.   DATA "S F7                           "
  179.   DATA "S F8                           "
  180.   DATA "S F9                           "
  181.   DATA "S F10                          "
  182. RETURN
  183. ' **********
  184. '
  185. > PROCEDURE keypress(txt$)
  186.   ' *** simulates input of txt$ by user (including <Return>)
  187.   ' *** call this Procedure before INPUT, FILESELECT, ALERT, etc.
  188.   LOCAL i
  189.   REPEAT
  190.   UNTIL INKEY$=""               ! clear keyboard-buffer
  191.   FOR i=1 TO LEN(txt$)
  192.     KEYPRESS ASC(MID$(txt$,i))
  193.   NEXT i
  194.   KEYPRESS &H1C000D             ! <Return>
  195. RETURN
  196. ' **********
  197. '
  198.