page@swan.ulowell.edu (Bob Page) (10/22/88)
Submitted-by: dillon@cory.berkeley.edu (Matt Dillon) Posting-number: Volume 2, Issue 13 Archive-name: editors/dme131.5of6 # This is a shell archive. Remove anything before this line # then unpack it by saving it in a file and typing "sh file" # (Files unpacked will be owned by you and have default permissions). # This archive contains the following files: # ./rexmacs/swish2.dme # ./rexmacs/xyz1.dme # ./rexmacs/args.dme # ./rexmacs/second.dme # ./rexmacs/yy.dme # ./rexmacs/one.dme # ./rexmacs/putd.dme # ./rexmacs/two.dme # ./rexmacs/interr2.dme # ./rexmacs/swish.dme # ./rexmacs/xx.dme # ./rexmacs/three.dme # ./rexmacs/alley.dme # ./rexmacs/save.dme # ./rexmacs/xyz2.dme # ./rexmacs/rxtop.dme # ./rexmacs/addr.dme # ./rexmacs/zz.dme # ./rexmacs/bot.dme # ./rexmacs/cat.dme # ./rexmacs/get.dme # ./rexmacs/findrexx.dme # ./rexmacs/qq.dme # ./rexmacs/rxbot.dme # ./rexmacs/findbaz.dme # ./rexmacs/put.dme # ./rexmacs/interr.dme # ./src/rexx.h # ./src/defs.h # ./src/cmd1.c # if `test ! -d ./rexmacs` then mkdir ./rexmacs echo "mkdir ./rexmacs" fi if `test ! -s ./rexmacs/swish2.dme` then echo "writing ./rexmacs/swish2.dme" cat > ./rexmacs/swish2.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ swish bottom top bottom top bottom top bottom top bottom top find "........" exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/swish2.dme" fi if [ `wc -c ./rexmacs/swish2.dme | awk '{printf $1}'` -ne 151 ] then echo `wc -c ./rexmacs/swish2.dme | awk '{print "Got " $1 ", Expected " 151}'` fi if `test ! -s ./rexmacs/xyz1.dme` then echo "writing ./rexmacs/xyz1.dme" cat > ./rexmacs/xyz1.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say xyz1 say "xyz1 - calling xyz2" xyz2 j k l m n o exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/xyz1.dme" fi if [ `wc -c ./rexmacs/xyz1.dme | awk '{printf $1}'` -ne 218 ] then echo `wc -c ./rexmacs/xyz1.dme | awk '{print "Got " $1 ", Expected " 218}'` fi if `test ! -s ./rexmacs/args.dme` then echo "writing ./rexmacs/args.dme" cat > ./rexmacs/args.dme << '\Rogue\Monster\' /* test to look at what dme is passing to ARexx .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg a1 a2 a3 a4 a5 a6 say a1 a2 a3 a4 a5 a6 exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/args.dme" fi if [ `wc -c ./rexmacs/args.dme | awk '{printf $1}'` -ne 168 ] then echo `wc -c ./rexmacs/args.dme | awk '{print "Got " $1 ", Expected " 168}'` fi if `test ! -s ./rexmacs/second.dme` then echo "writing ./rexmacs/second.dme" cat > ./rexmacs/second.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o cat exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/second.dme" fi if [ `wc -c ./rexmacs/second.dme | awk '{printf $1}'` -ne 169 ] then echo `wc -c ./rexmacs/second.dme | awk '{print "Got " $1 ", Expected " 169}'` fi if `test ! -s ./rexmacs/yy.dme` then echo "writing ./rexmacs/yy.dme" cat > ./rexmacs/yy.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ zz bottom top bottom top bottom top bottom top bottom top find "........" zz exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/yy.dme" fi if [ `wc -c ./rexmacs/yy.dme | awk '{printf $1}'` -ne 151 ] then echo `wc -c ./rexmacs/yy.dme | awk '{print "Got " $1 ", Expected " 151}'` fi if `test ! -s ./rexmacs/one.dme` then echo "writing ./rexmacs/one.dme" cat > ./rexmacs/one.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "one ... calling two" two say "back to one" top three bottom exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/one.dme" fi if [ `wc -c ./rexmacs/one.dme | awk '{printf $1}'` -ne 230 ] then echo `wc -c ./rexmacs/one.dme | awk '{print "Got " $1 ", Expected " 230}'` fi if `test ! -s ./rexmacs/putd.dme` then echo "writing ./rexmacs/putd.dme" cat > ./rexmacs/putd.dme << '\Rogue\Monster\' /* Saves the marked block as a file with the filename specified by */ /* the 1st argument, and then deletes it from the file being edited. */ /* If no name is specified, the block is written to file "t:$bsave". */ /* Arguments following the 1st one are ignored. */ /* */ /* Kim DeVaughn 12/28/87 */ options failat 5 rc = 0 parse arg filename junk if filename = "" then bsave "t:$bsave" else bsave filename bdelete exit rc \Rogue\Monster\ else echo "will not over write ./rexmacs/putd.dme" fi if [ `wc -c ./rexmacs/putd.dme | awk '{printf $1}'` -ne 589 ] then echo `wc -c ./rexmacs/putd.dme | awk '{print "Got " $1 ", Expected " 589}'` fi if `test ! -s ./rexmacs/two.dme` then echo "writing ./rexmacs/two.dme" cat > ./rexmacs/two.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "two ... calling three" three say "back to two" exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/two.dme" fi if [ `wc -c ./rexmacs/two.dme | awk '{printf $1}'` -ne 217 ] then echo `wc -c ./rexmacs/two.dme | awk '{print "Got " $1 ", Expected " 217}'` fi if `test ! -s ./rexmacs/interr2.dme` then echo "writing ./rexmacs/interr2.dme" cat > ./rexmacs/interr2.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "do an else all by itself ..." else say "shoulda caused an error ..." exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/interr2.dme" fi if [ `wc -c ./rexmacs/interr2.dme | awk '{printf $1}'` -ne 239 ] then echo `wc -c ./rexmacs/interr2.dme | awk '{print "Got " $1 ", Expected " 239}'` fi if `test ! -s ./rexmacs/swish.dme` then echo "writing ./rexmacs/swish.dme" cat > ./rexmacs/swish.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ bottom top bottom top bottom top bottom top bottom top find "rexx" exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/swish.dme" fi if [ `wc -c ./rexmacs/swish.dme | awk '{printf $1}'` -ne 141 ] then echo `wc -c ./rexmacs/swish.dme | awk '{print "Got " $1 ", Expected " 141}'` fi if `test ! -s ./rexmacs/xx.dme` then echo "writing ./rexmacs/xx.dme" cat > ./rexmacs/xx.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ yy bottom top bottom top bottom top bottom top bottom top find "rexx" yy exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/xx.dme" fi if [ `wc -c ./rexmacs/xx.dme | awk '{printf $1}'` -ne 147 ] then echo `wc -c ./rexmacs/xx.dme | awk '{print "Got " $1 ", Expected " 147}'` fi if `test ! -s ./rexmacs/three.dme` then echo "writing ./rexmacs/three.dme" cat > ./rexmacs/three.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "three here" exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/three.dme" fi if [ `wc -c ./rexmacs/three.dme | awk '{printf $1}'` -ne 182 ] then echo `wc -c ./rexmacs/three.dme | awk '{print "Got " $1 ", Expected " 182}'` fi if `test ! -s ./rexmacs/alley.dme` then echo "writing ./rexmacs/alley.dme" cat > ./rexmacs/alley.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ say "Gee ... I really did get called!!!" say address() options failat 4 shit say "RC = " RC damn say "RC = " RC and hell say "RC = " RC it say "RC = " RC dont say "RC = " RC matter to me say "RC = " RC exit(69) \Rogue\Monster\ else echo "will not over write ./rexmacs/alley.dme" fi if [ `wc -c ./rexmacs/alley.dme | awk '{printf $1}'` -ne 277 ] then echo `wc -c ./rexmacs/alley.dme | awk '{print "Got " $1 ", Expected " 277}'` fi if `test ! -s ./rexmacs/save.dme` then echo "writing ./rexmacs/save.dme" cat > ./rexmacs/save.dme << '\Rogue\Monster\' /* Saves the file with the filename specified by the 1st argument. */ /* If no name is specified, the file is saved with it's original */ /* filename. Arguments following the 1st one are ignored. */ /* */ /* Kim DeVaughn 12/21/87 */ options failat 5 rc = 0 parse arg filename junk if filename = "" then saveold else saveas filename exit rc \Rogue\Monster\ else echo "will not over write ./rexmacs/save.dme" fi if [ `wc -c ./rexmacs/save.dme | awk '{printf $1}'` -ne 487 ] then echo `wc -c ./rexmacs/save.dme | awk '{print "Got " $1 ", Expected " 487}'` fi if `test ! -s ./rexmacs/xyz2.dme` then echo "writing ./rexmacs/xyz2.dme" cat > ./rexmacs/xyz2.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "back to xyz1.dme" exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/xyz2.dme" fi if [ `wc -c ./rexmacs/xyz2.dme | awk '{printf $1}'` -ne 188 ] then echo `wc -c ./rexmacs/xyz2.dme | awk '{print "Got " $1 ", Expected " 188}'` fi if `test ! -s ./rexmacs/rxtop.dme` then echo "writing ./rexmacs/rxtop.dme" cat > ./rexmacs/rxtop.dme << '\Rogue\Monster\' /* give 'em a TOP command */ top say "RC for TOP = " RC exit \Rogue\Monster\ else echo "will not over write ./rexmacs/rxtop.dme" fi if [ `wc -c ./rexmacs/rxtop.dme | awk '{printf $1}'` -ne 62 ] then echo `wc -c ./rexmacs/rxtop.dme | awk '{print "Got " $1 ", Expected " 62}'` fi if `test ! -s ./rexmacs/addr.dme` then echo "writing ./rexmacs/addr.dme" cat > ./rexmacs/addr.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o second fee fi foe foo second say Back to addr.dme exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/addr.dme" fi if [ `wc -c ./rexmacs/addr.dme | awk '{printf $1}'` -ne 215 ] then echo `wc -c ./rexmacs/addr.dme | awk '{print "Got " $1 ", Expected " 215}'` fi if `test ! -s ./rexmacs/zz.dme` then echo "writing ./rexmacs/zz.dme" cat > ./rexmacs/zz.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ bottom top bottom top bottom top bottom top bottom top find "ARexx" say foo parse source a b c d e f g h i say a b c d e f g h i exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/zz.dme" fi if [ `wc -c ./rexmacs/zz.dme | awk '{printf $1}'` -ne 203 ] then echo `wc -c ./rexmacs/zz.dme | awk '{print "Got " $1 ", Expected " 203}'` fi if `test ! -s ./rexmacs/bot.dme` then echo "writing ./rexmacs/bot.dme" cat > ./rexmacs/bot.dme << '\Rogue\Monster\' /* Just make "bot" a synonym/alias for "bottom". */ /* */ /* Kim DeVaughn 12/21/87 */ bottom exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/bot.dme" fi if [ `wc -c ./rexmacs/bot.dme | awk '{printf $1}'` -ne 184 ] then echo `wc -c ./rexmacs/bot.dme | awk '{print "Got " $1 ", Expected " 184}'` fi if `test ! -s ./rexmacs/cat.dme` then echo "writing ./rexmacs/cat.dme" cat > ./rexmacs/cat.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o options failat 100 shit damn and hell it dont matter to me exit(69) \Rogue\Monster\ else echo "will not over write ./rexmacs/cat.dme" fi if [ `wc -c ./rexmacs/cat.dme | awk '{printf $1}'` -ne 230 ] then echo `wc -c ./rexmacs/cat.dme | awk '{print "Got " $1 ", Expected " 230}'` fi if `test ! -s ./rexmacs/get.dme` then echo "writing ./rexmacs/get.dme" cat > ./rexmacs/get.dme << '\Rogue\Monster\' /* Inserts the file specified by the 1st argument immediately above */ /* the line the cursor is on. If no filename is specified, the file */ /* "t:$bsave" is used if it exists. Arguments following the 1st one */ /* are ignored. */ /* */ /* Kim DeVaughn 12/21/87 */ options failat 5 rc = 0 parse arg filename junk if filename = "" then if exists("t:$bsave") then insfile "t:$bsave" else nop else insfile filename exit rc \Rogue\Monster\ else echo "will not over write ./rexmacs/get.dme" fi if [ `wc -c ./rexmacs/get.dme | awk '{printf $1}'` -ne 477 ] then echo `wc -c ./rexmacs/get.dme | awk '{print "Got " $1 ", Expected " 477}'` fi if `test ! -s ./rexmacs/findrexx.dme` then echo "writing ./rexmacs/findrexx.dme" cat > ./rexmacs/findrexx.dme << '\Rogue\Monster\' /* findrexx */ options failat 5 find "rexx" exit RC \Rogue\Monster\ else echo "will not over write ./rexmacs/findrexx.dme" fi if [ `wc -c ./rexmacs/findrexx.dme | awk '{printf $1}'` -ne 53 ] then echo `wc -c ./rexmacs/findrexx.dme | awk '{print "Got " $1 ", Expected " 53}'` fi if `test ! -s ./rexmacs/qq.dme` then echo "writing ./rexmacs/qq.dme" cat > ./rexmacs/qq.dme << '\Rogue\Monster\' /* Just make "qq" a synonym/alias for "quit". */ /* */ /* Kim DeVaughn 03/27/88 */ quit exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/qq.dme" fi if [ `wc -c ./rexmacs/qq.dme | awk '{printf $1}'` -ne 115 ] then echo `wc -c ./rexmacs/qq.dme | awk '{print "Got " $1 ", Expected " 115}'` fi if `test ! -s ./rexmacs/rxbot.dme` then echo "writing ./rexmacs/rxbot.dme" cat > ./rexmacs/rxbot.dme << '\Rogue\Monster\' /* give 'em a BOTTOM command */ bottom say "RC for BOTTOM = " RC exit \Rogue\Monster\ else echo "will not over write ./rexmacs/rxbot.dme" fi if [ `wc -c ./rexmacs/rxbot.dme | awk '{printf $1}'` -ne 71 ] then echo `wc -c ./rexmacs/rxbot.dme | awk '{print "Got " $1 ", Expected " 71}'` fi if `test ! -s ./rexmacs/findbaz.dme` then echo "writing ./rexmacs/findbaz.dme" cat > ./rexmacs/findbaz.dme << '\Rogue\Monster\' /* findbaz */ find baz exit \Rogue\Monster\ else echo "will not over write ./rexmacs/findbaz.dme" fi if [ `wc -c ./rexmacs/findbaz.dme | awk '{printf $1}'` -ne 29 ] then echo `wc -c ./rexmacs/findbaz.dme | awk '{print "Got " $1 ", Expected " 29}'` fi if `test ! -s ./rexmacs/put.dme` then echo "writing ./rexmacs/put.dme" cat > ./rexmacs/put.dme << '\Rogue\Monster\' /* Saves the marked block as a file with the filename specified by */ /* the 1st argument. If no name is specified, the block is written */ /* to file "t:$bsave". Arguments following the 1st one are ignored. */ /* */ /* Kim DeVaughn 12/21/87 */ options failat 5 rc = 0 parse arg filename junk if filename = "" then bsave "t:$bsave" else bsave filename exit rc \Rogue\Monster\ else echo "will not over write ./rexmacs/put.dme" fi if [ `wc -c ./rexmacs/put.dme | awk '{printf $1}'` -ne 399 ] then echo `wc -c ./rexmacs/put.dme | awk '{print "Got " $1 ", Expected " 399}'` fi if `test ! -s ./rexmacs/interr.dme` then echo "writing ./rexmacs/interr.dme" cat > ./rexmacs/interr.dme << '\Rogue\Monster\' /* test to see if we can invoke ARexx from inside of dme .... */ parse source a b c d e f g h i say a b c d e f g h i parse arg j k l m n o say j k l m n o say "do an else all by itself ..." /* else */ say "shoulda caused an error ..." interr2 poo poo exit 0 \Rogue\Monster\ else echo "will not over write ./rexmacs/interr.dme" fi if [ `wc -c ./rexmacs/interr.dme | awk '{printf $1}'` -ne 261 ] then echo `wc -c ./rexmacs/interr.dme | awk '{print "Got " $1 ", Expected " 261}'` fi if `test ! -d ./src` then mkdir ./src echo "mkdir ./src" fi if `test ! -s ./src/rexx.h` then echo "writing ./src/rexx.h" cat > ./src/rexx.h << '\Rogue\Monster\' /* * REXX.H * * (c) Copyright 1988 Kim DeVaughn, All Rights Reserved * * Definitions for the ARexx interface, in addition to the ARexx includes. * */ #ifndef REXX_STORAGE_H #include <rexx/storage.h> #endif #ifndef REXX_H #define REXX_H /* More RexxMsg field definitions, to make life a little easier. */ #define ACTION(rmp) (rmp->rm_Action) /* command (action) code */ #define RESULT1(rmp) (rmp->rm_Result1) /* primary result (return code) */ #define RESULT2(rmp) (rmp->rm_Result2) /* secondary result */ #define COMM_ADDR(rmp) (rmp->rm_CommAddr) /* host address (port name) */ #define FILE_EXT(rmp) (rmp->rm_FileExt) /* file extension */ /* * Error Level Definitions [ PRELIMINARY - SUBJECT TO CHANGE ] * * Definitions for internal (dme) error reporting begin with CMD_ * Definitions for external (ARexx) error reporting begin with MAC_ * * * 0 - command execution successful [normal] (i.e., title = OK) * 1 - command execution successful [alternate] (i.e., title = OK) * 2 - command execution successful [normal] (don't alter title) * 3 - command execution successful [alternate] (don't alter title) * 4 - reserved * 5 - command could not complete requested function * 10 - command was unable to process correctly * 20 - command failure detected - data integrity in question * 50 - internal error detected by dme or ARexx * * Only levels 0 and 1 allow the ARexx interface code to explicitly set title. * * * Eg: 0 - the normal case ("OK") * 1 - a secondary succeeful result ("OK") * 2 - normal, but may have put up an informational message * 3 - secondary normal, but may have informational message * 4 - * 5 - "find" didn't find, "file not found", "block not marked", etc. * 10 - "command not found", "syntax error", etc. * 15 - a sever failure; "write failed", "unable to open write file", etc. * 20 - maybe a sequence of commands that failed; may have modified data * 50 - dunno, but definitely bad shit */ #define CMD_VALID0 0 #define CMD_VALID1 1 #define CMD_VALID2 2 #define CMD_VALID3 3 #define CMD_VALID4 4 #define CMD_FAILED 5 #define CMD_ERROR 10 #define CMD_SEVERE 15 #define CMD_ABORT 20 #define CMD_MALFUNCTION 50 /* Similar to the internal command error levels above, for the moment. */ #define MAC_VALID0 0 #define MAC_VALID1 1 #define MAC_VALID2 2 #define MAC_VALID3 3 #define MAC_VALID4 4 #define MAC_FAILED 5 #define MAC_ERROR 10 #define MAC_SEVERE 15 #define MAC_ABORT 20 #define MAC_MALFUNCTION 50 #define CMD_INITIAL 0 #define TITLE_THRESHHOLD CMD_VALID1 #endif \Rogue\Monster\ else echo "will not over write ./src/rexx.h" fi if [ `wc -c ./src/rexx.h | awk '{printf $1}'` -ne 2817 ] then echo `wc -c ./src/rexx.h | awk '{print "Got " $1 ", Expected " 2817}'` fi if `test ! -s ./src/defs.h` then echo "writing ./src/defs.h" cat > ./src/defs.h << '\Rogue\Monster\' /* * DEFS.H * * (C)Copyright 1987 by Matthew Dillon, All Rights Reserved * * ARexx support added 03/19/88 - Kim DeVaughn * */ #define AREXX 1 #include <exec/types.h> #include <exec/io.h> #include <devices/keymap.h> #include <devices/console.h> #include <exec/memory.h> #include <intuition/intuition.h> #include <workbench/icon.h> #include <workbench/startup.h> #include <workbench/workbench.h> #include <local/typedefs.h> #include <local/xmisc.h> #if AREXX #include "rexx/storage.h" #include "rexx/rxslib.h" #include "rexx/rexxio.h" #include "rexx/errors.h" #endif #define MAXTOGGLE 256 #define QMOVE (0x6B|0x80) #define COLT(n) (XTbase + (n) * Xsize) #define ROWT(n) (YTbase + (n) * Ysize) #define COL(n) (Xbase + (n) * Xsize) #define ROW(n) (Ybase + (n) * Ysize) typedef struct WBStartup WBS; typedef struct DiskObject DISKOBJ; extern WBS *Wbs; extern DISKOBJ *Do; extern short Xsize, Ysize; extern short XTbase, YTbase; extern short Rows, Columns; extern short Xbase, Ybase; extern short Xpixs, Ypixs; extern ubyte *av[]; extern char Wdisable; typedef struct _ED { MNODE Node; WIN *Win; FONT *Font; /* da font, da font! */ long Topline, Topcolumn; long Line, Column; long Lines, Maxlines; ubyte **List; ubyte Name[64]; ubyte Wtitle[130]; char Modified; ubyte Tabstop; ubyte Margin; char Insertmode; char IgnoreCase; char Wordwrap; char iconmode; /* window in icon mode */ short Winx; /* save state of non-icon window */ short Winy; short Winwidth; short Winheight; short IWinx, IWiny; /* save state of icon window */ long dirlock; /* directory lock */ } ED; extern long BSline, BEline; extern short BSchar, BEchar; extern ED *BEp; #ifndef NULL #define NULL 0 #endif #ifdef E #undef E #endif extern MLIST DBase; extern MLIST PBase; extern ED *Ep; extern char Overide; extern char Savetabs; extern char memoryfail, Nsu, Msgchk; extern ubyte CtlC; extern ubyte Current[256]; extern ubyte Space[32]; extern short Clen; extern char Abortcommand, MShowTitle; extern char Comlinemode; extern RP *Rp; extern WIN *Win; extern char *Partial; extern char *String; extern ubyte *allocl(), *allocb(); extern char *keyspectomacro(); extern char *menutomacro(); extern char *getvar(); extern char *GetDEnv(); extern ED *finded(); extern void search_operation(); extern void *malloc(), *AllocMem(), *strcpy(); extern long Dirlock; extern PORT *IPCPort; extern long DResBase; \Rogue\Monster\ else echo "will not over write ./src/defs.h" fi if [ `wc -c ./src/defs.h | awk '{printf $1}'` -ne 2549 ] then echo `wc -c ./src/defs.h | awk '{print "Got " $1 ", Expected " 2549}'` fi if `test ! -s ./src/cmd1.c` then echo "writing ./src/cmd1.c" cat > ./src/cmd1.c << '\Rogue\Monster\' /* * CMD1.C (was TEXT1.C) * * (C)Copyright 1987 by Matthew Dillon, All Rights Reserved */ #include "defs.h" #define nomemory() { memoryfail = 1; } char RecallBuf[256]; setpen(line) { register short pen = (Ep == BEp && line >= BSline && line <= BEline) ? 2 : 1; if (Comlinemode) pen = 1; if (pen != Rp->FgPen) SetAPen(Rp, pen); } text_init() { register ED *e; register ED *ep = Ep; text_switch(NULL); e = (ED *)allocb(sizeof(ED)); if (e == NULL) return(0); bzero(e, sizeof(ED)); e->Win = Win; if (ep) { e->dirlock = DupLock(ep->dirlock); e->Insertmode = ep->Insertmode; e->IgnoreCase = ep->IgnoreCase; e->Tabstop = ep->Tabstop; e->Wordwrap = ep->Wordwrap; if (ep->Font) { e->Font = ep->Font; ++e->Font->tf_Accessors; SetFont(Win->RPort, e->Font); } } else { PROC *proc = (PROC *)FindTask(NULL); e->dirlock = DupLock(proc->pr_CurrentDir); e->Insertmode = 1; e->Tabstop = 4; } e->Lines = 1; e->Maxlines = 32; e->List = (ubyte **)allocl(e->Maxlines); e->List[0] = allocb(1); e->List[0][0] = Current[0] = Clen = 0; e->IWiny = 16; AddHead(&DBase, e); strcpy(e->Name, "unnamed"); Ep = e; text_cursor(1); return(1); } text_switch(win) WIN *win; { register ED *e; if (win) text_sync(); if (win) { for (e = (ED *)DBase.mlh_Head; e->Node.mln_Succ; e = (ED *)e->Node.mln_Succ) { if (e->Win == win) { Ep = e; Win = win; Rp = Win->RPort; text_load(); if (!Ep->iconmode) { set_window_params(); window_title(); } return(1); } } return(0); } } text_sync() { register ED *ep = Ep; char redraw = 0; short len; ubyte *ptr; for (len = strlen(Current) - 1; len >= 0 && Current[len] == ' '; --len) Current[len] = '\0'; Clen = len + 1; if (!Comlinemode) { if (strlen(ep->List[ep->Line]) != Clen) { if (ptr = allocb(Clen+1)) { ep->Modified = 1; Overide = 0; FreeMem(ep->List[ep->Line], strlen(ep->List[ep->Line])+1); ep->List[ep->Line] = ptr; } else { nomemory(); strcpy(Current, ep->List[ep->Line]); Clen = strlen(Current); } } else { if (strcmp(ep->List[ep->Line], Current)) { ep->Modified = 1; Overide = 0; } } strcpy(ep->List[ep->Line], Current); } if (Nsu == 0) { if (ep->Column - ep->Topcolumn >= Columns || ep->Column < ep->Topcolumn) { redraw = 1; ep->Topcolumn = ep->Column - (Columns>>1); if (ep->Topcolumn < 0) ep->Topcolumn = 0; } if (ep->Line - ep->Topline >= Rows || ep->Line < ep->Topline) { redraw = 1; ep->Topline = ep->Line - (Rows>>1); if (ep->Topline < 0) ep->Topline = 0; } } while (ep->Column > Clen) Current[Clen++] = ' '; Current[Clen] = '\0'; if (redraw) text_redisplay(); return((int)redraw); } text_load() { if (Comlinemode) return(0); strcpy(Current, Ep->List[Ep->Line]); Clen = strlen(Current); while (Ep->Column > Clen) Current[Clen++] = ' '; Current[Clen] = '\0'; } text_colno() { return(Ep->Column); } text_lineno() { return(Ep->Line+1); } text_lines() { return(Ep->Lines); } text_cols() { return((int)Clen); } text_imode() { return(Ep->Insertmode); } text_tabsize() { return((int)Ep->Tabstop); } ubyte * text_name() { return(Ep->Name); } text_uninit() { register int i; register ED *ep = Ep; PMKill(ep); freelist(ep->List, ep->Lines); FreeMem(ep->List, ep->Maxlines * sizeof(char *)); if (BEp == ep) { BEp = NULL; BSline = BEline = -1; } Remove(ep); if (ep->Font) { SetFont(ep->Win->RPort, ep->Win->WScreen->RastPort.Font); CloseFont(ep->Font); } UnLock(ep->dirlock); FreeMem(ep, sizeof(ED)); if (((ED *)DBase.mlh_Head)->Node.mln_Succ) { Ep = (ED *)DBase.mlh_Head; text_load(); } else { Ep = NULL; } } inversemode(n) { if (n) { SetAPen(Rp, 3); SetDrMd(Rp, JAM2|INVERSVID); } else { setpen(Ep->Line); SetDrMd(Rp, JAM2); } } text_cursor(n) { movetocursor(); inversemode(n); if (Current[Ep->Column]) Text(Rp, Current+Ep->Column, 1); else Text(Rp, " ", 1); inversemode(0); } text_position(col, row) { register ED *ep = Ep; text_sync(); if (col == 0) col = -1; ep->Column = ep->Topcolumn + col; if (ep->Column > 254) ep->Column = 254; if (ep->Column < 0) ep->Column = 0; ep->Line = ep->Topline + row; if (ep->Line >= ep->Lines) ep->Line = ep->Lines - 1; if (ep->Line < 0) ep->Line = 0; text_load(); text_sync(); } displayblock(on) { register long start = Ep->Topline; register long lines = BEline - BSline + 1; if (start < BSline) start = BSline; if (!on) { BSline = BEline = -1; BEp = NULL; } if (Ep == BEp) text_displayseg(start - Ep->Topline, lines); } text_redrawblock(ok) { WIN *savewin = NULL; if (BEp) { if (BEp != Ep) { savewin = Ep->Win; text_switch(BEp->Win); } if (BSline <= BEline && BSline >= 0 && BEline < Ep->Lines) { if (!ok) { BEp = NULL; BSline = BEline = -1; } text_displayseg(0, Rows); } if (savewin) text_switch(savewin); } if (!ok) { BEp = NULL; BSline = BEline = -1; } } text_displayseg(start, n) { register short i, c; register ubyte *ptr; register ED *ep = Ep; char ib; if (Nsu) return(0); for (i = start; i < start + n && i < Rows && ep->Topline + i < ep->Lines; ++i) { if (Comlinemode) { if (ep->Topline + i != ep->Line) continue; ptr = Current; SetAPen(Rp, 1); } else { ptr = ep->List[ep->Topline + i]; setpen(i+ep->Topline); } for (c = ep->Topcolumn; c && *ptr; ++ptr, --c); c = strlen(ptr); if (c) { Move(Rp, COLT(0), ROWT(i)); Text(Rp, ptr, (c > Columns) ? Columns : c); } } } text_redisplay() { if (Nsu) return(0); SetAPen(Rp, 0); if (Comlinemode) RectFill(Rp, COL(0), ROW(Rows-1), Xbase+Xpixs, Ybase+Ypixs); else RectFill(Rp, Xbase, Ybase, Xbase + Xpixs, Ybase + Ypixs); text_displayseg(0,Rows); } text_redisplaycurrline() { int row = Ep->Line - Ep->Topline; if (Nsu) return(0); SetAPen(Rp, 0); RectFill(Rp, COL(0), ROW(row), Xbase+Xpixs, ROW(row+1)-1); text_displayseg(row, 1); } text_write(str) ubyte *str; { register short len = strlen(str); register short i; register ED *ep = Ep; if (Clen + len >= 255) { text_sync(); text_load(); } if (ep->Insertmode == 0) { if (ep->Column + len >= 255) goto fail; bmov(str, Current + ep->Column, len); if (ep->Column + len >= Clen) Clen = ep->Column + len; Current[Clen] = 0; } else { if (Clen + len >= 255) goto fail; bmov(Current + ep->Column, Current + ep->Column + len, Clen+1-ep->Column); bmov(str, Current + ep->Column, len); Clen += len; if (len < Columns - (ep->Column - ep->Topcolumn)) { ScrollRaster(Rp, -len * Xsize, 0 , COL(ep->Column - ep->Topcolumn), ROW(ep->Line - ep->Topline), COL(Columns) - 1, ROW(ep->Line - ep->Topline + 1) - 1 ); } } i = (ep->Column - ep->Topcolumn + len > Columns) ? Columns - ep->Column + ep->Topcolumn : len; setpen(ep->Line); Move(Rp, COLT(ep->Column - ep->Topcolumn), ROWT(ep->Line - ep->Topline)); Text(Rp, str, i); ep->Column += len; if (ep->Column - ep->Topcolumn >= Columns) text_sync(); fail: if (Comlinemode == 0 && ep->Wordwrap) do_reformat(0); } do_up() { if (Ep->Line) { text_sync(); --Ep->Line; text_load(); if (Ep->Line < Ep->Topline) { if (Nsu == 0) { ScrollRaster(Rp,0,-Ysize,COL(0),ROW(0),COL(Columns)-1,ROW(Rows)-1); --Ep->Topline; text_displayseg(0, 1); } } } else { Abortcommand = 1; } } do_scrolldown() { if (Ep->Topline + Rows < Ep->Lines) { if (Nsu == 0) { text_sync(); ScrollRaster(Rp,0,Ysize,COL(0),ROW(0),COL(Columns)-1,ROW(Rows)-1); ++Ep->Topline; ++Ep->Line; text_load(); text_displayseg(Rows-1, 1); } } else { Abortcommand = 1; } } do_scrollup() { if (Ep->Topline) { if (Nsu == 0) { text_sync(); ScrollRaster(Rp,0,-Ysize,COL(0),ROW(0),COL(Columns)-1,ROW(Rows)-1); --Ep->Topline; --Ep->Line; text_load(); text_displayseg(0, 1); } } else { Abortcommand = 1; } } do_down() { if (Ep->Line + 1 < Ep->Lines) { text_sync(); ++Ep->Line; text_load(); if (Ep->Line - Ep->Topline >= Rows) { if (Nsu == 0) { ScrollRaster(Rp,0,Ysize,COL(0),ROW(0),COL(Columns)-1,ROW(Rows)-1); ++Ep->Topline; text_displayseg(Rows-1, 1); } } } else { Abortcommand = 1; } } /* * PAGEUP * PAGEDOWN * PAGESET n (n = 0 to 100 for percentage of #rows to scroll, minimum 1) * can be > 100. */ do_page() { register int n, multiplier = 1; register ED *ep = Ep; static short pctg = 80; switch(av[0][4]) { case 'u': multiplier = -1; case 'd': n = multiplier * Rows * pctg / 100; if (!n) n = multiplier; if (n > 0 && ep->Topline >= ep->Lines - Rows) return(0); text_sync(); ep->Line += n; ep->Topline += n; if (ep->Line >= ep->Lines) ep->Line = ep->Lines - 1; if (ep->Line < 0) ep->Line = 0; if (ep->Topline >= ep->Lines) ep->Topline = ep->Lines - Rows - 1; if (ep->Topline < 0) ep->Topline = 0; text_load(); if (!text_sync()) text_redisplay(); break; case 's': pctg = atoi(av[1]); break; } } do_downadd() { ubyte *ptr; if (Ep->Line + 1 == Ep->Lines) { Ep->Modified = 1; if (makeroom(32) && (ptr = allocb(1))) { Ep->List[Ep->Lines] = ptr; *ptr = 0; ++Ep->Lines; } else { nomemory(); } } do_down(); } do_left() { if (Ep->Column) { --Ep->Column; if (Ep->Column < Ep->Topcolumn) text_sync(); } else { Abortcommand = 1; } } do_right() { if (Ep->Column != 254) { if (Current[Ep->Column] == 0) { Current[Ep->Column] = ' '; Current[Ep->Column+1]= '\0'; ++Clen; } ++Ep->Column; if (Ep->Column - Ep->Topcolumn >= Columns) text_sync(); } else { Abortcommand = 1; } } do_tab() { register short n; for (n = Ep->Tabstop-(Ep->Column % Ep->Tabstop); n > 0; --n) do_right(); } do_backtab() { register short n; n = Ep->Column % Ep->Tabstop; if (!n) n = Ep->Tabstop; for (; n > 0; --n) do_left(); } do_return() { ubyte buf[256]; char *partial; if (Comlinemode) { strcpy(buf, Current); strcpy(RecallBuf, Current); partial = Partial; Partial = NULL; escapecomlinemode(); if (partial) { if (do_command(buf)) do_command(partial); free(partial); } else { do_command(buf); } } else { Ep->Column = 0; text_sync(); do_downadd(); } } do_bs() { register ED *ep = Ep; if (ep->Column) { bmov(Current + ep->Column, Current + ep->Column - 1, Clen - ep->Column + 1); --ep->Column; --Clen; if (ep->Column < ep->Topcolumn) { text_sync(); } else { ScrollRaster(Rp, Xsize, 0, COL(ep->Column - ep->Topcolumn), ROW(ep->Line - ep->Topline), COL(Columns)-1, ROW(ep->Line - ep->Topline + 1)-1 ); if (Clen >= ep->Topcolumn + Columns) { setpen(ep->Line); Move(Rp, COLT(Columns-1), ROWT(ep->Line - ep->Topline)); Text(Rp, Current + ep->Topcolumn + Columns - 1, 1); } } if (Comlinemode == 0 && ep->Wordwrap) do_reformat(0); } else { Abortcommand = 1; } } /* * esc, escimm */ int Savetopline, Savecolumn, Savetopcolumn; do_recall() { av[0] = (ubyte *)"escimm"; av[1] = (ubyte *)RecallBuf; do_esc(); } do_esc() { register ED *ep = Ep; if (Comlinemode) return(escapecomlinemode()); text_sync(); if (av[0][3] == 'i') strcpy(Current, av[1]); else Current[0] = 0; Clen = strlen(Current); Comlinemode = 1; returnoveride(1); Savetopline = ep->Topline; Savecolumn = ep->Column; Savetopcolumn = ep->Topcolumn; ep->Column = Clen; ep->Topcolumn = 0; ep->Topline = ep->Line - Rows + 1; SetAPen(Rp, 0); RectFill(Rp, COL(0), ROW(Rows-1), Xbase+Xpixs, Ybase+Ypixs); SetAPen(Rp, 1); Move(Rp, COL(0), ROW(Rows-1) - 1); Draw(Rp, Xbase + Xpixs, ROW(Rows-1) - 1); text_displayseg(Rows-1,1); } escapecomlinemode() { register ED *ep = Ep; if (Partial) { free(Partial); Partial = NULL; } if (Comlinemode) { strcpy(RecallBuf, Current); Comlinemode = 0; returnoveride(0); ep->Topline = Savetopline; ep->Column = Savecolumn; ep->Topcolumn = Savetopcolumn; text_load(); SetAPen(Rp, 0); RectFill(Rp, COL(0), ROW(Rows-1)-1, Xbase+Xpixs, Ybase+Ypixs); SetAPen(Rp, 1); text_displayseg(Rows-2,2); } } do_del() { register ED *ep = Ep; if (Current[ep->Column]) { bmov(Current + ep->Column + 1, Current + ep->Column, Clen - ep->Column); --Clen; ScrollRaster(Rp, Xsize, 0, COL(ep->Column - ep->Topcolumn), ROW(ep->Line - ep->Topline), COL(Columns)-1, ROW(ep->Line - ep->Topline + 1) - 1 ); if (Clen >= ep->Topcolumn + Columns) { setpen(ep->Line); Move(Rp, COLT(Columns-1), ROWT(ep->Line-ep->Topline)); Text(Rp, Current+ep->Topcolumn+Columns-1, 1); } if (Comlinemode == 0 && ep->Wordwrap) do_reformat(0); } } do_top() { text_sync(); Ep->Line = 0; text_load(); text_sync(); } do_bottom() { text_sync(); Ep->Line = Ep->Lines - 1; text_load(); text_sync(); } do_firstcolumn() { if (Ep->Column) { Ep->Column = 0; text_sync(); } } do_firstnb() { for (Ep->Column = 0; Current[Ep->Column] == ' '; ++Ep->Column); if (Current[Ep->Column] == 0) Ep->Column = 0; text_sync(); } do_lastcolumn() { short i; text_sync(); i = (Comlinemode) ? Clen : strlen(Ep->List[Ep->Line]); if (i != Ep->Column) { Ep->Column = i; text_sync(); } } /* * GOTO [+/-]N * GOTO BLOCK start of block * GOTO START start of block * GOTO END end of block */ do_goto() { register short n, i; register ubyte *ptr = av[1]; i = 0; n = -1; switch(*ptr) { case 'b': case 's': case 'B': case 'S': n = -1; if (Ep == BEp) n = BSline; break; case 'e': case 'E': n = -1; if (Ep == BEp) n = BEline; break; case '+': i = 1; case '-': n = Ep->Line; default: n += atoi(ptr+i); } if (n >= Ep->Lines) n = Ep->Lines - 1; if (n < 0) n = 0; text_sync(); Ep->Line = n; text_load(); text_sync(); } do_screentop() { text_sync(); Ep->Line = Ep->Topline; text_load(); text_sync(); } do_screenbottom() { text_sync(); Ep->Line = Ep->Topline + Rows - 1; if (Ep->Line < 0 || Ep->Line >= Ep->Lines) Ep->Line = Ep->Lines - 1; text_load(); text_sync(); } static ubyte Fstr[256]; static ubyte Rstr[256]; static short Srch_sign; static char Doreplace; /* * findstr, repstr */ do_findstr() { if (av[0][0] == 'f') strcpy(Fstr, av[1]); else strcpy(Rstr, av[1]); } /* * findr, nextr, prevr */ do_findr() { Doreplace = 1; Srch_sign = 1; switch(av[0][0]) { case 'f': strcpy(Fstr, av[1]); strcpy(Rstr, av[2]); break; case 'p': Srch_sign = -1; break; } search_operation(); } /* * find, next, prev */ do_find() { Doreplace = 0; Srch_sign = 1; switch(av[0][0]) { case 'f': strcpy(Fstr, av[1]); break; case 'p': Srch_sign = -1; break; } search_operation(); } static char CaseIgnore; void search_operation() { int flen = strlen(Fstr); int rlen = strlen(Rstr); char senabled = 0; register ubyte *ptr; register int i, col; register ED *ep = Ep; CaseIgnore = ep->IgnoreCase; text_sync(); if (!flen) { title("No find pattern"); Abortcommand = 1; return; } col = ep->Column; if (col >= strlen(ep->List[ep->Line])) col = strlen(ep->List[ep->Line]); for (i = ep->Line;;) { ptr = ep->List[i]; if (Srch_sign > 0) { while (ptr[col]) { if (senabled && case_strncmp(Fstr,ptr+col,flen) == 0) goto found; senabled = 1; ++col; } senabled = 1; if (++i >= ep->Lines) break; col = 0; } else { while (col >= 0) { if (senabled && case_strncmp(Fstr,ptr+col,flen) == 0) goto found; senabled = 1; --col; } senabled = 1; if (--i < 0) break; col = strlen(ep->List[i]); } } title("Pattern Not Found"); Abortcommand = 1; return; found: ep->Line = i; ep->Column = col; text_load(); if (Doreplace) { if (rlen > flen && rlen-flen+strlen(ptr) > 254) { title("Replace: Line Too Long"); Abortcommand = 1; return; } if (Clen-col-flen >= 0) { bmov(Current+col+flen, Current+col+rlen, Clen-col-flen+1); bmov(Rstr, Current+col, rlen); Clen += rlen-flen; } text_sync(); text_redisplaycurrline(); } else { text_sync(); } } #asm ; NOTE: assumes that one of the strings is at least ; 'len' bytes long, and contains no nulls. Also, ; returns only 0=success, 1=fail. NOT A TRUE ; CASE COMPARE... can get confused by control ; chars. ; ; 4(sp) = s1 ; 8(sp) = s2 ; 12(sp) = len _case_strncmp: movem.l 4(sp),A0/A1 move.l 12(sp),D0 move.l D2,-(sp) tst.b _CaseIgnore bne .csc100 moveq.l #0,D1 ;set Z bit case sensitive bra .csc20 .csc10 cmpm.b (A0)+,(A1)+ .csc20 dbne D0,.csc10 bne .cscfail .cscsucc moveq.l #0,D0 ;return true move.l (sp)+,D2 rts .csc100 moveq.l #0,D1 ;set Z bit case sensitive bra .csc120 .csc110 move.b (A0)+,D1 ;XOR two bytes together move.b (A1)+,D2 eor.b D2,D1 and.b #$DF,D1 ;forget bit 5 (the case) .csc120 dbne D0,.csc110 beq .cscsucc .cscfail moveq.l #1,D0 ;return failure move.l (sp)+,D2 rts #endasm \Rogue\Monster\ else echo "will not over write ./src/cmd1.c" fi if [ `wc -c ./src/cmd1.c | awk '{printf $1}'` -ne 17766 ] then echo `wc -c ./src/cmd1.c | awk '{print "Got " $1 ", Expected " 17766}'` fi echo "Finished archive 5 of 6" # if you want to concatenate archives, remove anything after this line exit -- Bob Page, U of Lowell CS Dept. page@swan.ulowell.edu ulowell!page Have five nice days.