home *** CD-ROM | disk | FTP | other *** search
- \ MACROS.SEQ Keyboard macros for DF by Tom Zimmer
-
- ?dark
- .comment:
- Keyboard macros for DF.
- To DEFINE a macro;
- Press Alt-M \ starts defining, waits for next key
- Press Alt-1 \ tells it which macro to make, can be
- \ Alt-1 through Alt-5, waits for first
- \ key of macro
- Start entering keys. \ keys are passed on to program and saved too
- Press Alt-M \ Ends definition of the new macro
-
- Thats all there is to MAKING macros.
-
- To PERFORM a macro;
- Press Alt-1 \ Macro processor passes back all keys
- \ one for each call to key until empty
-
- Thats all there is to DOING macros.
-
- comment;
-
- only forth also hidden also definitions
-
- 248 constant macbase \ Alt-1
- 10 constant #macros \ Through Alt-0
- \ 187 constant macbase \ F1
- \ 10 constant #macros \ Through F10
-
- 128 constant macsiz
- 0 constant macseg
-
- : ms: ( n1 --- seg n1 )
- macseg swap ;
-
- : macreset ( --- ) \ Clear macros segment pointer.
- defers initstuff
- 0 =: macseg ;
-
- ' macreset is initstuff
-
- : macinit ( --- )
- macseg if exit then
- #macros macsiz * alloc
- if 2drop exit
- then nip =: macseg ;
-
- variable curmac
- variable doingmac
- variable makingmac
-
- : setmac ( n1 --- ) \ set the current macro pointer.
- macsiz * curmac ! ;
-
- : ?domac ( --- <c1> ) \ Are we doing a macro, if so return a key.
- doingmac @
- if curmac @ ms: c@l curmac @ 1+ ms: c@l 0=
- if doingmac off
- then curmac incr r> drop
- then ;
-
- : ?domac1 ( c1 --- c2 ) \ If a macro key, start macro and return
- \ the first macro key if its good.
- dup macbase dup #macros 1- + BETWEEN
- if doingmac on macbase - setmac
- curmac @ ms: c@l curmac incr ?dup 0=
- if doingmac off
- curmac @ 1- macsiz / macbase +
- then
- then ;
-
- : ?addmac ( c1 --- c1 ) \ conditionally add a key to current macro.
- makingmac @
- if dup curmac @ ms: c!l curmac incr 0 curmac @ ms: !l
- then ;
-
- : ?start/stopmac ( --- c1 ) \ Conditionally start of stop making a macro.
- begin udefers key
- dup 178 = makingmac @ 0= and \ Alt-M = Make macro
- if drop udefers key \ Alt-1 to Alt-5
- dup macbase dup #macros 1- +
- BETWEEN 0= \ macro key number
- if exit
- then macbase - setmac 0 curmac @ ms: !l
- makingmac on
- udefers key
- then dup 178 = makingmac @ and \ Alt-M and making
- while drop makingmac off
- repeat ;
-
-
- : mackey ( --- c1 ) \ This definition looks more like PASCAL
- macinit macseg 0=
- if udefers key
- else ?domac ?start/stopmac ?addmac ?domac1
- then ;
-
-
- \ Alt-1 = 248, to Alt-5 = 252
-
- ' mackey is key
-
- only forth also definitions
-
- 300 tillkey