/*  Edits								*/
/*									*/
/*  6-MAR-1985	SCPAGE	Cut QIO overhead for screen dumps  by 70%	*/
/*  6-MAR-1985  SCCUTP	Added GOLD 3 to allow the selection of paste	*/
/*			buffers 0,1,2 or 3. Changes also to DISKIO	*/
/*  6-MAR-1985	SCROOT	Fixed off by one in repeat counts for char	*/
/*			insertion.					*/
/*  6-MAR-1985	SCFILE	Gold S to print the filename used.		*/
/*  6-MAR-1985	EDEND	Don't exit to DCL if command line was SED	*/
/*			and GOLD F was used to exit. This of course	*/
/*			allows the saving of internal buffers for reuse	*/
/*			with other files (not wildcarded).		*/
/* 11-MAR-1985  TEMPIO	Allow multiple editing windows. Minor changes	*/
/*			to most modules (convert some int to pointers	*/
/*			to ints. Selected via GOLD B			*/
/* 13-MAR-1985	DISKIO	Do $PARSE on filename that is saved in the log	*/
/*			TED_LAST_FILE_EDITED so we get the directory	*/
/*			path inserted. Also always strip any version	*/
/*			number out.					*/
/* 13-MAR-1985	SCLOOK	Stop searching if EOF record is hit		*/
/* 13-MAR-1985	SCDSP	Map vt220 CSI24~ to be same as BS key on VT100	*/
/*			(i.e., the F12 key)				*/
/* 13-MAR-1985	SCROOT	Insure CTRL-P resets keypad mode		*/
/* 13-MAR-1985	EDSET	Added SET AST ANY and SET AST PAGE to control	*/
/*			what to do if a command is typed while a new	*/
/*			screen is being put up.				*/
/* 19-MAR-1985	DISKIO	Properly handle diskquota going into overdraft.	*/
/*			Also get EXQUOTA (if installed with EXQUOTA) for*/
/*			each workfile write and drop it after the write	*/
/*			if the user does not have EXQUOTA in the sysuaf	*/
/* 19-MAR-1985	SCMARK	Reset cursor (GOLD GOLD Uparrow)		*/
/* 19-MAR-1985	SCDEL	Allow UndelLine (Gold PF4) to work on the <EOF>	*/
/*			line (insert a new line).			*/
/* 20-MAR-1985	EDCMD	Added ZAP filename and DIR filespec commands.	*/
/* 20-MAR-1985	EDVMS	Spawn DCL for ZAP and DIR commands.		*/
/* 27-MAR-1985	SCFILE	If GOLD G (insert file) fails, print something	*/
/*			reasonable for an error message.		*/
/* 27-MAR-1985	SCROOT	Added GOLD * for a '999' repeat count.		*/
/* 27-MAR-1985	EDSET	Added SET DELETE PREVIOUS/CURRENT to control if	*/
/*			RUB deletes the current char or the one to the	*/
/*			left of the cursor in VT/SED mode. Setable via	*/
/*			CTRL/V or SYS$LOGIN:TEDINIT.INI			*/
/* 27-MAR-85	SCPAGE	Fix printing of trailing ESC on line.		*/
/* 27-MAR-85	SCROOT	Set 'escprint' flag if escape entered by SPCINS	*/
/*			forcing escapes to be printed via graphic char.	*/
/* 28-MAR-85	SCDUMP	Fix dumping of <EOF> marker for GOLD O and Z.	*/
/* 28-MAR-85	SCFILE	Fix GOLD W off by one line, also protect <EOF>	*/
/*			from CENTER (gold KP5) command.			*/
/* 28-MAR-85	various	Add calls to KPNORMAL() and KPAPPLICATION() to	*/
/*			let ENTER to act as RETURN where it makes sense	*/
/*			as in spawning and so forth.			*/
/* 28-MAR-85	SCDEL	If delete and on <EOF>, move up and delete prev	*/
/*			line (the last real line in file).		*/
/* 31-MAR-85	EDEND	Fix error message display for SED wildcardname	*/
/*			and no files matching at all.			*/
/* 03-APR-85	SCLOOK	Added call to TESTCC() in flast() (find last).	*/
/*			Added working timer ast's to flast()		*/
/* 12-APR-85	EDCMD	Added PURGE and ERASE commands (spawn DCL).	*/
/* 23-APR-85	EDEND	Force ^Z to exit wildcard filename response.	*/
/* 23-APR-85	EDPLCD	Fix CDELETE not to overrun short lines.		*/
/* 23-APR-85	SCLOOK	Fix REPNEXT to not skip adjacent matching pat.	*/
/* 09-MAY-85	EDMAIN	Add call to CLOTMP() to insure temp files go	*/
/* 13-MAY-85	DISKIO	Fix close errors on cut/paste buffers		*/
/* 15-MAY-85	EDINS	Insert command can hose file up			*/
/*			away.						*/
/* 21-MAY-85	SCUPDO	Bug in reverse scrolling for VT2xx series	*/
/* 11-JUN-85	EDLOOK	Fix TRIM command to work right			*/
/* 11-JUN-85	SCROOT	Fix SET DELETE PREVIOUS to work correctly at	*/
/*			end of line.					*/
/* 12-JUN-85	SCCMD	Added definitions for f10 and f17-f20 on LK201	*/
/*			keyboards (vt2xx, Rainbow, Pro/3xx). F10 does	*/
/*			a GOLD F (exit), where F17-F20 switch to the	*/
/*			alternate edit windows				*/
/* 24-JUN-85	EDEND	Call SAVEFILENAME() to set the saved name to be	*/
/*			that which we wrote out always			*/
/* 01-JUL-85	SCINIT	Don't turn a VT2xx into a VT100 at exit if VMS	*/
/*			thinks it's a VT2xx.				*/
/* 08-JUL-85	SCINIT	Added SET HEADER [update][fast] to control the	*/
/*		EDSET	top header line for VT/SED command.		*/
/* 08-JUL-85	EDSET	Added SET LINE [eoln][next] to control how the	*/
/*		SCUPDO	KP2 key works.					*/
/* 08-JUL-85	DISKIO	Leave keypad application mode on in RSTTER() if	*/
/*			VMS thinks it's supposed to be on.		*/
/* 12-AUG-85	EDVMS	Redo spawning to execute a command file instead	*/
/*			and leave the spawned subprocess out there until*/
/*			TED exits. The command proc and TED will switch	*/
/*			back and forth via ATTACH and LIB$ATTACH.	*/
/* 12-AUG-85	DISKIO	Removed DCLCOMMAND ept, now in EDVMS.C		*/
/* XX-AUG-85	......	Many small mods to facilitate moving to PDP-11.	*/
/*			Broke some larger modules up to better fit in	*/
/*			overlays for the PDP-11.			*/
/* 17-SEP-85	EDIFL	(1) Fix EDIFL to call PAGEOFF(window_number) and*/
/*			PAGEON(...) properly.				*/
/*		EDPAGR	(2) Fix PAGEOF() to allocate no more than 61440	*/
/*			bytes for a page if caching is disabled for the	*/
/*			initial file load (RAB$W_RSZ is 16 bits please)	*/
/* 27-SEP-85	DISKIO	Look for ESC[5 or ESC[6 when checking to cancel	*/
/*			a screen print (vt220 Prev and Next Screen)	*/
/* 27-SEP-85	SCINIT	Added ESC(B to terinit() to turn off graphics	*/
/* 03-OCT-85	EDSTAR	Do something reasonable if user trys to edit a	*/
/*		DISKIO	directory file, either explicity or via wild-	*/
/*			card spec. EP added to DISKIO calling ACP to 	*/
/*			check if a file is a directory.			*/
/* 04-oct-85	PDPIO	The PRO/350 does not do char insert like a 220	*/
/* 29-oct-85	DISKIO	Added QIO to ept putbin to use IO$M_NOFORMAT	*/
/*			to increase performance on DHU11 and DMF.	*/
/* 29-oct-85	SCREM	Fix bug in delete word at end of line.		*/
/* 30-oct-85	various	Add intermediate terminal QIO buffering to get	*/
/*			better silo i/o and sometimes even get into DMA	*/
/*			I/O, also cuts number of QIO's by 60%. VMS only	*/
/* 30-oct-85	EDVMS	F14 (on vt2xx) prints VMS stats, GOLD F14 does	*/
/*			stats from PUTBIN qio's (used for screen editor)*/
/* 26-Nov-85    TEMPIO	Add lookahead for the next bucket, saves quite	*/
/*			a bit of cpu time for searchs.			*/
/* 26-Nov-85    EDFIND	Use MOVTC, LOCC and MATCHC to speed up case in-	*/
/*			sensitive matching on VAX.			*/
/* 20-Jan-85	various	Hooks for multiple macro buffers, currently is	*/
/*			defined at 8. On VMS, simply return pointer to	*/
/*			512 bytes offset in static area. On PDP11, add	*/
/*			2KW to dynamic region and map/unmap as needed.	*/
/*			That incurrs high overhead of MAP$S, but given	*/
/*			how often macros are used, who cares.		*/
/* 29-Jan-85	PD*.MAC	A few small fixes for P/OS and RSTS/E		*/
/* 29-Jan-85	PDPIO	Support dropping of privileges for RSTS/E so an	*/
/*			user lacking INSTAL priv can create the dynamic	*/
/*			region.						*/


#include	"sysdef.h"

#define	then

static char inifile[_FILESIZE] ;

main()
{
	extern int indlun,cmdlun ;
	if ( checkterminal() == 0 )
	  then	xprintf("Current output device is not a terminal\n") ;
	  else	{
		inistats() ;
		xinit() ;
		chkrmt() ;
		setcc() ;
		scdainit() ;
		gethomedir(inifile) ;
		strcpy(&inifile[strlen(inifile)],"TEDINIT.INI") ;
		if ( flookup(inifile) && openfi(inifile,indlun) )
		  then cmdlun = indlun ;
		if ( edstart() )
		  then while ( opennext() ) execommand() ;
		clotmp() ;
		delspawn() ;
		}
}


prsys_error()
{
	char s[80] ;
	geterror(s) ;
	xprintf("%s\n",s) ;
}

scwarning(number)
int number ;
{

	char txt[64] ;

	getwarn(txt,number) ;
	putwarn(txt) ;
}	
