home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / FFA.ZIP / MACROS.SEQ < prev    next >
Encoding:
Text File  |  1988-01-11  |  3.6 KB  |  107 lines

  1. \ MACROS.SEQ    Keyboard macros for DF                  by Tom Zimmer
  2.  
  3. ?dark
  4. .comment:
  5.                         Keyboard macros for DF.
  6. To DEFINE a macro;
  7.         Press Alt-M             \ starts defining, waits for next key
  8.         Press Alt-1             \ tells it which macro to make, can be
  9.                                 \ Alt-1 through Alt-5, waits for first
  10.                                 \ key of macro
  11.         Start entering keys.    \ keys are passed on to program and saved too
  12.         Press Alt-M             \ Ends definition of the new macro
  13.  
  14.         Thats all there is to MAKING macros.
  15.  
  16. To PERFORM a macro;
  17.         Press Alt-1             \ Macro processor passes back all keys
  18.                                 \ one for each call to key until empty
  19.  
  20.         Thats all there is to DOING macros.
  21.  
  22. comment;
  23.  
  24. only forth also hidden also definitions
  25.  
  26. 248 constant macbase            \ Alt-1
  27.  10 constant #macros            \ Through Alt-0
  28. \ 187 constant macbase            \ F1
  29. \  10 constant #macros            \ Through F10
  30.  
  31. 128 constant macsiz
  32.   0 constant macseg
  33.  
  34. : ms:           ( n1 --- seg n1 )
  35.                 macseg swap ;
  36.  
  37. : macreset      ( --- )                 \ Clear macros segment pointer.
  38.                 defers initstuff
  39.                 0 =: macseg ;
  40.  
  41. ' macreset is initstuff
  42.  
  43. : macinit       ( --- )
  44.                 macseg if exit then
  45.                 #macros macsiz * alloc
  46.                 if      2drop exit
  47.                 then    nip =: macseg ;
  48.  
  49. variable curmac
  50. variable doingmac
  51. variable makingmac
  52.  
  53. : setmac        ( n1 --- )      \ set the current macro pointer.
  54.                 macsiz * curmac ! ;
  55.  
  56. : ?domac        ( --- <c1> )    \ Are we doing a macro, if so return a key.
  57.                 doingmac @
  58.                 if      curmac @ ms: c@l curmac @ 1+ ms: c@l 0=
  59.                         if      doingmac off
  60.                         then    curmac incr r> drop
  61.                 then    ;
  62.  
  63. : ?domac1       ( c1 --- c2 )   \ If a macro key, start macro and return
  64.                                  \ the first macro key if its good.
  65.                 dup macbase dup #macros 1- + BETWEEN
  66.         if      doingmac on macbase - setmac
  67.                 curmac @ ms: c@l curmac incr ?dup 0=
  68.                 if      doingmac off
  69.                         curmac @ 1- macsiz / macbase +
  70.                 then
  71.         then    ;
  72.  
  73. : ?addmac       ( c1 --- c1 )   \ conditionally add a key to current macro.
  74.                 makingmac @
  75.                 if      dup curmac @ ms: c!l curmac incr 0 curmac @ ms: !l
  76.                 then    ;
  77.  
  78. : ?start/stopmac ( --- c1 )     \ Conditionally start of stop making a macro.
  79.                 begin   udefers key
  80.                         dup 178 = makingmac @ 0= and    \ Alt-M = Make macro
  81.                         if      drop udefers key        \ Alt-1 to Alt-5
  82.                                 dup macbase dup #macros 1- +
  83.                                 BETWEEN 0=  \ macro key number
  84.                                 if      exit
  85.                                 then    macbase - setmac 0 curmac @ ms: !l
  86.                                 makingmac on
  87.                                 udefers key
  88.                         then    dup 178 = makingmac @ and \ Alt-M and making
  89.                 while   drop makingmac off
  90.                 repeat  ;
  91.  
  92.  
  93. : mackey        ( --- c1 )      \ This definition looks more like PASCAL
  94.                 macinit macseg 0=
  95.                 if      udefers key
  96.                 else    ?domac ?start/stopmac ?addmac ?domac1
  97.                 then    ;
  98.  
  99.  
  100. \ Alt-1 = 248, to Alt-5 = 252
  101.  
  102. ' mackey is key
  103.  
  104. only forth also definitions
  105.  
  106. 300 tillkey
  107.