home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
macros.seq
< prev
next >
Wrap
Text File
|
1991-02-05
|
9KB
|
245 lines
\ MACROS.SEQ Keyboard macros for F-PC by Tom Zimmer
\ anew macros
comment:
Keyboard macros for F-PC.
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.
To REPEAT a macro;
Press Alt-R \ We will be repeating a macro key
Enter a # between 0-999 \ The number of times to repeat the macro
Press Alt-1 \ the macro to repeat.
comment;
only forth also hidden also definitions
headerless
248 constant macbase \ Alt-1
8 constant #macros \ Through Alt-0
128 constant macsiz
#macros macsiz *D pointer macseg
headers
handle macfile \ make the macro file handle
macfile !hcb F-PC.MAC \ initialize macro file name
: %macinit ( -- )
macseg 0= abort" Couldn't allocate MACRO buffer!"
macseg 0 #macros macsiz * 0 lfill ;
%macinit \ initialize macros for use
: macinit ( --- )
defers initstuff
%macinit ;
' macinit is initstuff
headerless
: ms: ( n1 --- seg n1 )
macseg swap ;
variable curmac
\ 0 value ?doingmac \ moved down to UTILS.SEQ to make it available
\ to test if we are currently doing a macro.
\ useful in the editor to reduce the screen updates
\ while performing macros.
variable makingmac
: savemacs ( --- )
macfile hcreate
if 37 7 at
." \r Could not make Macro file! " beep
else 0 #macros macsiz * dup>r macfile macseg exhwrite
r> - 37 5 at >rev
if ." Write error to Macro file! " beep
else ." Macros Saved.\s14"
then >norm macfile hclose drop
then 1 seconds ;
: loadmacs ( --- )
macfile hopen dup 0=
if drop
#macros macsiz * \ length of read
0 over macfile macseg exhread - dup
\ clear out the buffer on read length wrong!
if macseg 0 #macros macsiz * 0 lfill
then macfile hclose drop
then ( --- f1 ) \ true if failed
37 5 at >rev
if ." No Macros to load.\s05\b"
else ." Macros Loaded.\s13"
then >norm 1 seconds ;
: viewmacs ( --- )
savescr
6 2 74 over #macros 2* + 3 + box&fill
." Press \r ESC \0 when done viewing macros."
bcr bcr macsiz 2/
#macros 0
do i 1+ 1 .r ." "
macseg macsiz i * 2 pick typeL bcr
." "
macseg macsiz i * 2 pick + 2 pick typeL bcr
loop drop
defers key drop
restscr ;
: .askmacro ( --- )
savecursor
cursor-off savescr
['] noop save!> dobutton
10 4 70 19 box&fill
." \r Making a MACRO... "
bcr bcr
." First press \r Alt-1 \0 through \r Alt-8 \0 to specify the macro"
bcr
." you are making, then; enter the keys of your macro,"
bcr
." finally; press Alt-M again to finish making a macro."
bcr
." ────────────────────────────────────────────────────────"
bcr
." To CANCEL making a macro press \r ESC \0 now."
bcr bcr
." To PERFORM a macro press \r Alt-1 \0 through \r Alt-8 \0 when "
bcr
." you are \r NOT \0 looking at this window."
bcr bcr
." Press \r V \0 to VIEW the currently defined macros."
bcr bcr
." Press \r L \0 to load macros, or \r S \0 to save macros."
defers key
27 over = if drop 178 then
'v' over bl or = if drop 178 viewmacs then
'l' over bl or = if drop 178 loadmacs then
's' over bl or = if drop 178 savemacs then
restore> dobutton
restscr
restcursor ;
: .repmac ( --- )
25 07 .box" Repeating a MACRO."
01 10 .box" Enter a # between 000 and 999 for the number of times to repeat the macro."
30 13 .box" "
17 16 .box" Enter the macro key Alt-1 to Alt-8"
32 14 at ;
: 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 off> ?doingmac
then curmac incr 2r> 2drop
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 on> ?doingmac macbase - setmac
curmac @ ms: c@l curmac incr ?dup 0=
if off> ?doingmac
curmac @ 1- macsiz / macbase +
then
then ;
variable mactimes \ number of times to perform a macro
variable repkey \ macro key we are repeating
: ?repmac ( --- <c1> )
mactimes @
if mactimes decr
repkey @ ?domac1 2r> 2drop
then ;
: ?repmac1 ( c1 --- c1 )
dup 147 = makingmac @ 0= and \ Alt-R = repeating
if drop
savecursor
savescr cursor-on .repmac
0
begin defers key dup '0' '9' between
while dup emit '0' - swap 10 * + 999 min
repeat
restscr
restcursor
swap 1- 0MAX 999 min mactimes !
dup repkey !
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 defers key
dup 178 = makingmac @ 0= and \ Alt-M = Make macro
if drop .askmacro
\ Alt-1 to Alt-5
dup macbase dup #macros 1- +
BETWEEN 0= \ macro key number
if exit
then
macbase - setmac
savecursor
savescr cursor-off
20 6 60 10 box&fill
bcr
." \s04\r Enter the keys of your macro \:03"
restscr
restcursor
curmac @ ms: macsiz 0 lfill
makingmac on
defers key
then dup 178 = makingmac @ and \ Alt-M and making
while drop makingmac off
savecursor
savescr cursor-off
20 6 60 10 box&fill
bcr ." \r *** Make Macro Completed *** \:10"
restscr
restcursor
repeat ;
headers
: mackey ( --- c1 ) \ This definition looks more like PASCAL
macseg 0=
if defers key
else ?domac ?repmac ?start/stopmac
?addmac ?repmac1 ?domac1
then ;
\ Alt-1 = 248, to Alt-5 = 252
' mackey is key
behead
only forth also definitions