home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 427.lha / VLT_FKeys / VLT_FKeys.vlt < prev    next >
Text File  |  1990-10-07  |  7KB  |  272 lines

  1. /************************************************************************/
  2. /*                              VLT_FKeys v0.51        08/16/90                                */
  3. /*                                                                                                */
  4. /*                VLT_FKeys - (c) Copyright Michael Scott Velez 1990.            */
  5. /*                                                                                                */
  6. /* You may distribute this program as long as it is not sold for            */
  7. /* profit, and is contained in the original archive.                            */
  8. /*                                                                                                */
  9. /* VLT_FKeys enables to you to interactively edit 50 of VLT's           */
  10. /* function keys definitions (normal, shifted, alt, ctrl & user).            */
  11. /* Place this in your REXX: directory, start VLT, and run as                */
  12. /* an 'Arexx Script'. Have fun...                                                    */
  13. /*                                                                                                */
  14. /*                                                                                                */
  15. /* Questions, suggestions or complaints may be sent to:                        */
  16. /*                                                                                                */
  17. /*         BIX: mvelez  or        Michael Scott Velez                                    */
  18. /*                                    1014 West 7th Ave.                                    */
  19. /*                                    Vancouver, BC                                            */
  20. /*                                    V6H 1B3                                                    */
  21. /*                                                                                                */
  22. /************************************************************************/
  23. Title        = 'VLT_FKeys v0.51'
  24. Author    = 'Michael Scott Velez'
  25.  
  26. TRUE    = 1
  27. FALSE = ~TRUE
  28.  
  29. /* we need these libraries */
  30. if (~show('l', "rexxarplib.library")) then do
  31.     call addlib('rexxarplib.library', 0, -30, 0)
  32. end
  33. if (~show('l', "rexxsupport.library")) then do
  34.     call addlib('rexxsupport.library', 0, -30, 0)
  35. end
  36.  
  37. /* you don't *need* WShell to run this, but get it. It's worth it!    */
  38. if (exists("C:RunWSH")) then
  39.     Shell = 'C:RunWSH'
  40. else
  41.     Shell = 'C:Run'
  42.  
  43. /* start host    */
  44. if (ScreenCols('VLT') == -1) then        /* running in Workbench window    */
  45.     xhost = 'rx "call CreateHost(FHOST, FPORT,)"'
  46. else
  47.     xhost = 'rx "call CreateHost(FHOST, FPORT, ' || address() || ')"'
  48. address command Shell xhost
  49.  
  50. /* wait for it to load and init itself */
  51. do 50 while ~show('Ports', 'FHOST')
  52.     call delay(10)        /* 1/10th sec    */
  53. end
  54.  
  55.  
  56. /* set up our boolean gadgets */
  57. Boolean.Num = 5
  58. do i = 1 to Boolean.Num
  59.     Boolean.LeftEdge.i    = ((i - 1) * 96) + 36
  60.     Boolean.TopEdge.i = 15
  61.     Boolean.GadgetID.i    = i                    /* how we tell one gadget from another */
  62. end
  63. Boolean.Text.1 = ' Normal  '
  64. Boolean.Type.1 = 'f'
  65. Boolean.Text.2 = ' Shifted '
  66. Boolean.Type.2        = 'F'
  67. Boolean.Text.3 = '   CTRL  '
  68. Boolean.Type.3 = 'C'
  69. Boolean.Text.4 = '   ALT   '
  70. Boolean.Type.4        = 'A'
  71. Boolean.Text.5 = '   User  '
  72. Boolean.Type.5        = 'U'
  73. FType            = 1
  74.  
  75.  
  76. /* set up our string gadgets    */
  77. String.Num    = 10
  78. do i = 1 to String.Num
  79.     String.LeftEdge.i = 32
  80.     String.TopEdge.i    = i * 16 + 15
  81.     String.Width.i        = 59 * 8
  82.     String.GadgetID.i = i + 5                        /* how we tell one gadget from another */
  83. end
  84. do i = 1 to (Boolean.Num * 10)
  85.     String.Buffer.i        = ''                            /* null string */
  86. end
  87.  
  88. /* open window */
  89. w.LeftEdge        = 0
  90. w.TopEdge        = 0
  91. w.Width            = 520
  92. w.Height            = 190
  93. w.IDCMPFlags    = 'CLOSEWINDOW + MENUPICK + GADGETUP'
  94. w.Flags            = 'WINDOWCLOSE + WINDOWDRAG + ACTIVATE + NOCAREFRESH + SMARTREFRESH'
  95. w.Title            = Title || '  by  ' || Author
  96. call OpenWindow(FHOST, w.LeftEdge, w.TopEdge, w.Width, w.Height, w.IDCMPFlags, w.Flags, w.Title)
  97.  
  98. /* first menu    */
  99. call AddMenu(FHOST, Title)
  100. call AddItem(FHOST, 'Save', 'SAVE', 'S',,)
  101. call AddItem(FHOST, 'Quit', 'QUIT', 'Q',,)
  102.  
  103. /* add text */
  104. call SetAPen(FHOST, 1)
  105. call SetBPen(FHOST, 0)
  106. call SetDrMd(FHOST, 'JAM2')
  107. call WhichFKeys(FType)
  108.  
  109. /* read old function key definitions    */
  110. call    ReadFKeys()
  111.  
  112. /* open port    */
  113. call    OpenPort(FPORT)
  114.  
  115. /* add gadgets */
  116. do i = 1 to Boolean.Num
  117.     call AddGadget(FHOST, Boolean.LeftEdge.i, Boolean.TopEdge.i, Boolean.GadgetID.i, Boolean.Text.i, Boolean.GadgetID.i)
  118. end
  119. do i = 1 to String.Num
  120.     call AddGadget(FHOST, String.LeftEdge.i, String.TopEdge.i, String.GadgetID.i, String.Buffer.i, '%0'||String.GadgetID.i||'%1%g', String.Width.i)
  121. end
  122. call ActivateGadget(FHOST, String.GadgetID.1)
  123.  
  124.  
  125. /* event loop & no we don't busy wait :-)    */
  126. looping    = TRUE
  127. do while (looping)
  128.  
  129.     /* wait for something to happen    */
  130.     call    waitpkt(FPORT)
  131.  
  132.     /* loop until no more messages    */
  133.     do forever
  134.  
  135.         packet    = getpkt(FPORT)
  136.         if (packet = NULL()) then
  137.             break
  138.         msg        = getarg(packet, 0)
  139.         arg1        = getarg(packet, 1)        /* some msg won't have this    */
  140.         call Reply(packet, 0)
  141.  
  142.         /* find out what    */
  143.         select
  144.  
  145.             /* check for boolean gadget    */
  146.             when    ((msg >= 1) & (msg <= 5)) then do    /* 1-Normal, 2-Shift, 3-CTRL, 4-ALT, 5-User    */
  147.                 FType = msg
  148.                 do i = 1 to String.Num
  149.                     call RemoveGadget(FHOST, String.GadgetID.i)
  150.                     x    = i + ((FType - 1) * String.Num)
  151.                     call AddGadget(FHOST, String.LeftEdge.i, String.TopEdge.i, String.GadgetID.i, String.Buffer.x, '%0'||String.GadgetID.i||'%1%g', String.Width.i)
  152.                 end
  153.                 call WhichFKeys(msg)
  154.                 call ActivateGadget(FHOST, String.GadgetID.1)
  155.             end
  156.  
  157.             /* check for string gadget */
  158.             when    ((msg >= '6') & (msg <= '16')) then do
  159.                 /* copy gadget buffer to array    */
  160.                 i    = msg - 5
  161.                 x    = i + ((FType - 1) * String.Num)
  162.                 String.Buffer.x = arg1
  163.                 /* activate the correct gadget    */
  164.                 if (msg < '15') then
  165.                     call ActivateGadget(FHOST, String.GadgetID.i + 1)
  166.                 else
  167.                     call ActivateGadget(FHOST, String.GadgetID.1)
  168.             end
  169.  
  170.             /* check for exit */
  171.             when    (msg = 'SAVE') then do
  172.                 call WriteFKeys()
  173.                 looping    = FALSE
  174.                 end
  175.  
  176.             /* geez, user wants out!    */
  177.             when    ((msg = 'CLOSEWINDOW') | (msg = 'QUIT')) then
  178.                 looping    = FALSE
  179.  
  180.             otherwise
  181.                 nop
  182.         end
  183.     end
  184. end
  185.  
  186. /* close down    */
  187. do i = 1 to 5
  188.     call RemoveGadget(FHOST, i)                    /* boolean gadgets    */
  189. end
  190. do i = 1 to String.Num
  191.     call RemoveGadget(FHOST, String.GadgetID.i)    /* string gadgets        */
  192.     end
  193. call RemoveMenu(FHOST)
  194. call CloseWindow(FHOST)
  195.  
  196. exit
  197.  
  198. /************************************************************************/
  199. /*                                        WhichFKeys                                            */
  200. /************************************************************************/
  201. WhichFKeys: procedure expose FHOST Boolean. String.Num
  202.     arg Functype
  203.  
  204.     do i = 1 to String.Num
  205.         call Move(FHOST, 4, i * 16 + 22)
  206.         call Text(FHOST, Boolean.Type.Functype || i)
  207.     end
  208. return
  209.  
  210. /************************************************************************/
  211. /*                                        ReadFKeys                                            */
  212. /************************************************************************/
  213. ReadFKeys:    procedure expose String.
  214.  
  215.     'EXTRACT [FUNCTIONKEY]'
  216.     do i = 1 to String.Num
  217.         j = i + 0
  218.         String.Buffer.j = VLT.FUNCTIONKEY.i
  219.     end
  220.  
  221.     'EXTRACT [FUNCTIONKEYSHIFT]'
  222.     do i = 1 to String.Num
  223.         j = i + 10
  224.         String.Buffer.j = VLT.FUNCTIONKEYSHIFT.i
  225.     end
  226.  
  227.     'EXTRACT [FUNCTIONKEYCTRL]'
  228.     do i = 1 to String.Num
  229.         j = i + 20
  230.         String.Buffer.j = VLT.FUNCTIONKEYCTRL.i
  231.     end
  232.  
  233.     'EXTRACT [FUNCTIONKEYALT]'
  234.     do i = 1 to String.Num
  235.         j = i + 30
  236.         String.Buffer.j = VLT.FUNCTIONKEYALT.i
  237.     end
  238.  
  239.     'EXTRACT [FUNCTIONUSERMENU]'
  240.     do i = 1 to String.Num
  241.         j = i + 40
  242.         String.Buffer.j = VLT.FUNCTIONUSERMENU.i
  243.     end
  244.  
  245. return
  246.  
  247. /************************************************************************/
  248. /*                                        WriteFKeys                                            */
  249. /************************************************************************/
  250. WriteFKeys: procedure expose String.
  251.  
  252.     /* tell VLT about the new definitions    */
  253.     call PostMsg(0, 0, "Please Wait... Programming definitions", address())
  254.     do i = 1 to 50
  255.  
  256.         /* build VLT command */
  257.         fkeycmd    = 'F ' || i || ' [' || String.Buffer.i || ']'
  258.  
  259.  
  260.         /* tell VLT to do something!    */
  261.         '""' || fkeycmd
  262.     end
  263.     call PostMsg()
  264.  
  265.     msg    =            "New definitions are active. Use <Save Configuration> permanently store."
  266.     call PostMsg(0, 0, msg, address())
  267.     call Delay(250)
  268.     call PostMsg()
  269.  
  270. return
  271.  
  272.