Gribnif@UMass.BITNET (Dan Wilga) (11/23/88)
For those Mark Williams C users who do not like to use uEMACS and would rather be able to use a GEM-based text editor with the -A option (to automatically call the editor when the compiler finds an error), I have written the following small shell program. Read the comments for info on how to compile and set it up. (By the way, it works great from NeoDesk and the new NeoDesk 2.0 <blatant plug>) <snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip> /* editshel.c This program is used in conjunction with the -A option of by the Mark Williams C compiler for the ST. It allows the Dan Wilga user to automatically have an editor of his choice pop-up with the source file and an error file everytime the 11/19/88 compiler detects an error. This program was designed with GEM-based editors in mind, especially Tempus. Compiling: Use the line "cc editshel.c -VSMALL". Omit the -VSMALL if your version of MWC is less than 3.0. Remember to use "strip" afterward to get rid of the symbol table. Use: When MWC encounters an error in compilation, it looks for the EDITOR environmental variable. If it does not find one it searches PATH for "me.prg", the micro-EMACS editor. This program is a shell that gets called by way of the EDITOR variable and then calls *your* editor. To use it, create two environmental variables, one called EDITOR which points to this compiled program and the other GEMEDIT which points to your editor. */ #include "osbind.h" main( argc, argv ) int argc; char *argv[]; { int i, olddrv; char argbuf[100]=" ", oldpath[100], newpath[100], *prgptr, *ptr, *letr="x:"; extern char *getenv(), *rindex(); if( !(prgptr=getenv("GEMEDIT")) ) /* check for environmental var */ { Cconws( "Error! EDITSHEL could not find the GEMEDIT environmental variable!\r\n" ); exit(1); } /* Because this is most likely a GEM-based editor we are running, the default path must be set to the editor's location before it is run or it may not be able to find config or resource files. Of course, the path must be restored afterward or cc won't be able to do its thing. */ olddrv = Dgetdrv(); *letr = olddrv+'A'; Dgetpath( oldpath, olddrv+1 ); /* Scan through the list of arguments. Because cc thinks this is uEMACS, it passes a '-E' option which we must ignore. Also, since we are changing the default path, each filename passed to the editor must be the *full* path. */ for( i=1; i<argc; i++ ) if( argv[i][0] != '-' ) /* omit any options */ { if( argv[i][1] != ':' ) /* does this filename have the full path? */ { strcat( argbuf, letr ); /* append the drive letter */ strcat( argbuf, oldpath ); /* append the path */ strcat( argbuf, "\\" ); /* append a slash */ } strcat( argbuf, argv[i] ); /* append the filename */ strcat( argbuf, " " ); /* and a space */ } argbuf[0] = strlen(argbuf+1); /* first char of the tail contains length */ Cconws( "\033f\033v\r\nCompilation errors were encountered.\ \r\nPress any key to execute " ); /* turn-off the cursor, set autowrap */ Cconws( prgptr ); Cconws( " with " ); Cconws( argbuf+1 ); Cconws( "\r\nor press Ctrl-C to exit and stop cc\r\n" ); if( (Crawcin() & 0xFFFF) == 0x03 ) exit(-32); /* check for Ctrl-C */ strcpy( newpath, prgptr+2*(*(prgptr+1)==':') ); /* get just the path */ if( ptr = rindex(newpath,'\\') ) *(ptr+1) = '\0'; /* chop-off any filename */ if( *(prgptr+1) == ':' ) /* if drive of editor differs from current, */ Dsetdrv( (*prgptr&0x5F) - 'A' ); /* set it here */ if( !(i=Dsetpath(newpath)) ) i = Pexec( 0, prgptr, argbuf, 0L ); /* run it */ Cconws( "\033E\033e" ); /* turn cursor back on for cc */ Dsetdrv(olddrv); /* restore old drive and path */ Dsetpath(oldpath); exit( i<0 ? i : 0 ); /* return an error code, if necessary */ } <snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip><snip> Dan Wilga Gribnif@UMASS.BitNet Gribnif Software Gribnif%UMASS.BitNet@forsythe.stanford.EDU "My other program is also a Porsche"