home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / FPC35_5.ZIP / FPCSRC.ZIP / MACROS.SEQ < prev    next >
Encoding:
Text File  |  1989-09-21  |  9.1 KB  |  243 lines

  1. \ MACROS.SEQ    Keyboard macros for F-PC                  by Tom Zimmer
  2.  
  3. \ anew macros
  4.  
  5. comment:
  6.                         Keyboard macros for F-PC.
  7. To DEFINE a macro;
  8.         Press Alt-M             \ starts defining, waits for next key
  9.         Press Alt-1             \ tells it which macro to make, can be
  10.                                 \ Alt-1 through Alt-5, waits for first
  11.                                 \ key of macro
  12.         Start entering keys.    \ keys are passed on to program and saved too
  13.         Press Alt-M             \ Ends definition of the new macro
  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.         Thats all there is to DOING macros.
  20.  
  21. To REPEAT a macro;
  22.         Press Alt-R             \ We will be repeating a macro key
  23.         Enter a # between 0-999 \ The number of times to repeat the macro
  24.         Press Alt-1             \ the macro to repeat.
  25. comment;
  26.  
  27. only forth also hidden also definitions
  28.  
  29. headerless
  30.  
  31. 248 constant macbase            \ Alt-1
  32.   8 constant #macros            \ Through Alt-0
  33.  
  34. 128 constant macsiz
  35.   0 value macseg
  36.  
  37. headers
  38.  
  39. handle macfile                  \ make the macro file handle
  40.  
  41. macfile !hcb F-PC.MAC           \ initialize macro file name
  42.  
  43. : macinit       ( --- )
  44.                 defers initstuff
  45.                 off> macseg
  46.                 #macros macsiz * paragraph alloc
  47.                 if      2drop exit
  48.                 then    nip =: macseg
  49.                 macseg 0 #macros macsiz * 0 lfill ;
  50.  
  51. ' macinit is initstuff
  52.  
  53. headerless
  54.  
  55. : ms:           ( n1 --- seg n1 )
  56.                 macseg swap ;
  57.  
  58. variable curmac
  59. \ 0 value ?doingmac     \ moved down to UTILS.SEQ to make it available
  60.                         \ to test if we are currently doing a macro.
  61.                         \ useful in the editor to reduce the screen updates
  62.                         \ while performing macros.
  63. variable makingmac
  64.  
  65. : savemacs      ( --- )
  66.                 macfile hcreate
  67.                 if      37 7 at
  68.                         ." \r Could not make Macro file! " beep
  69.                 else    0 #macros macsiz * dup>r macfile macseg exhwrite
  70.                         r> -    37 5 at >rev
  71.                         if      ."  Write error to Macro file! " beep
  72.                         else    ."  Macros Saved.\s14"
  73.                         then    >norm macfile hclose drop
  74.                 then    1 seconds ;
  75.  
  76. : loadmacs      ( --- )
  77.                 macfile hopen dup 0=
  78.                 if      drop
  79.                         #macros macsiz *       \ length of read
  80.                         0 over macfile macseg exhread - dup
  81.                         \ clear out the buffer on read length wrong!
  82.                         if      macseg 0 #macros macsiz * 0 lfill
  83.                         then    macfile hclose drop
  84.                 then    ( --- f1 )      \ true if failed
  85.                 37 5 at >rev
  86.                 if      ."  No Macros to load.\s05\b"
  87.                 else    ."  Macros Loaded.\s13"
  88.                 then    >norm 1 seconds ;
  89.  
  90. : viewmacs      ( --- )
  91.                 savescr
  92.                 6 2 74 over #macros 2* + 3 + box&fill
  93.                 ." Press \r ESC \0 when done viewing macros."
  94.                 bcr bcr macsiz 2/
  95.                 #macros 0
  96.                 do      i 1+ 1 .r ." "
  97.                         macseg macsiz i * 2 pick          typeL bcr
  98.                         ."   "
  99.                         macseg macsiz i * 2 pick + 2 pick typeL bcr
  100.                 loop    drop
  101.                 defers key drop
  102.                 restscr ;
  103.  
  104. : .askmacro     ( --- )
  105.                 savecursor
  106.                 cursor-off savescr
  107.                 ['] noop save!> dobutton
  108.                 10  4 70 19 box&fill
  109.                 ."  \r Making a MACRO... "
  110.                 bcr bcr
  111.         ."  First press \r Alt-1 \0 through \r Alt-8 \0 to specify the macro"
  112.                 bcr
  113.         ."  you are making, then; enter the keys of your macro,"
  114.                 bcr
  115.         ."  finally; press Alt-M again to finish making a macro."
  116.                 bcr
  117.         ."  ────────────────────────────────────────────────────────"
  118.                 bcr
  119.         ."  To CANCEL making a macro press \r ESC \0 now."
  120.                 bcr bcr
  121.         ."  To PERFORM a macro press \r Alt-1 \0 through \r Alt-8 \0 when "
  122.                 bcr
  123.         ."  you are \r NOT \0 looking at this window."
  124.                 bcr bcr
  125.                 ."  Press \r V \0 to VIEW the currently defined macros."
  126.                 bcr bcr
  127.                 ."  Press \r L \0 to load macros, or \r S \0 to save macros."
  128.                 defers key
  129.                      27 over       = if drop 178            then
  130.                 'v' over bl or = if drop 178 viewmacs   then
  131.                 'l' over bl or = if drop 178 loadmacs   then
  132.                 's' over bl or = if drop 178 savemacs   then
  133.                 restore> dobutton
  134.                 restscr
  135.                 restcursor ;
  136.  
  137. : .repmac       ( --- )
  138. 25 07 .box" Repeating a MACRO."
  139. 01 10 .box" Enter a # between 000 and 999 for the number of times to repeat the macro."
  140. 30 13 .box"         "
  141. 17 16 .box" Enter the macro key Alt-1 to Alt-8"
  142. 32 14 at ;
  143.  
  144. : setmac        ( n1 --- )      \ set the current macro pointer.
  145.                 macsiz * curmac ! ;
  146.  
  147. : ?domac        ( --- <c1> )    \ Are we doing a macro, if so return a key.
  148.                 ?doingmac
  149.                 if      curmac @ ms: c@l curmac @ 1+ ms: c@l 0=
  150.                         if      off> ?doingmac
  151.                         then    curmac incr 2r> 2drop
  152.                 then    ;
  153.  
  154. : ?domac1       ( c1 --- c2 )   \ If a macro key, start macro and return
  155.                                  \ the first macro key if its good.
  156.                 dup macbase dup #macros 1- + BETWEEN
  157.         if      on> ?doingmac macbase - setmac
  158.                 curmac @ ms: c@l curmac incr ?dup 0=
  159.                 if      off> ?doingmac
  160.                         curmac @ 1- macsiz / macbase +
  161.                 then
  162.         then    ;
  163.  
  164. variable mactimes       \ number of times to perform a macro
  165. variable repkey         \ macro key we are repeating
  166.  
  167. : ?repmac       ( --- <c1> )
  168.                 mactimes @
  169.                 if      mactimes decr
  170.                         repkey @ ?domac1 2r> 2drop
  171.                 then    ;
  172.  
  173. : ?repmac1      ( c1 --- c1 )
  174.                 dup 147 = makingmac @ 0= and    \ Alt-R = repeating
  175.                 if      drop
  176.                         savecursor
  177.                         savescr cursor-on .repmac
  178.                         0
  179.                         begin   defers key dup '0' '9' between
  180.                         while   dup emit '0' - swap 10 * + 999 min
  181.                         repeat
  182.                         restscr
  183.                         restcursor
  184.                         swap 1- 0MAX 999 min mactimes !
  185.                         dup repkey !
  186.                 then    ;
  187.  
  188. : ?addmac       ( c1 --- c1 )   \ conditionally add a key to current macro.
  189.                 makingmac @
  190.                 if      dup curmac @ ms: c!l
  191.                         curmac incr
  192.                         0 curmac @ ms: !l
  193.                 then    ;
  194.  
  195. : ?start/stopmac ( --- c1 )     \ Conditionally start of stop making a macro.
  196.                 begin   defers key
  197.                         dup 178 = makingmac @ 0= and    \ Alt-M = Make macro
  198.                         if      drop .askmacro
  199.                                                         \ Alt-1 to Alt-5
  200.                                 dup macbase dup #macros 1- +
  201.                                 BETWEEN 0=              \ macro key number
  202.                                 if      exit
  203.                                 then
  204.                                 macbase - setmac
  205.                                 savecursor
  206.                                 savescr cursor-off
  207.                                 20  6 60 10 box&fill
  208.                                 bcr
  209.                                 ." \s04\r Enter the keys of your macro \:03"
  210.                                 restscr
  211.                                 restcursor
  212.                                 curmac @ ms: macsiz 0 lfill
  213.                                 makingmac on
  214.                                 defers key
  215.                         then    dup 178 = makingmac @ and \ Alt-M and making
  216.                 while   drop makingmac off
  217.                         savecursor
  218.                         savescr cursor-off
  219.                         20  6 60 10 box&fill
  220.                         bcr ."     \r *** Make Macro Completed *** \:10"
  221.                         restscr
  222.                         restcursor
  223.                 repeat  ;
  224.  
  225. headers
  226.  
  227. : mackey        ( --- c1 )      \ This definition looks more like PASCAL
  228.                 macseg 0=
  229.                 if      defers key
  230.                 else    ?domac  ?repmac  ?start/stopmac
  231.                         ?addmac ?repmac1 ?domac1
  232.                 then    ;
  233.  
  234.  
  235. \ Alt-1 = 248, to Alt-5 = 252
  236.  
  237. ' mackey is key
  238.  
  239. behead
  240.  
  241. only forth also definitions
  242.  
  243.