
#include	"sysdef.h"

#define	SPACE	040
#define	then
#include	"scerrd.h"

vtkpswitch()
{
	extern int kpstatus ;

	if ( kpstatus )
	  then	{
		kpnormal() ;
		ceol24() ;
		putbin("Keypad turned off",0) ;
		kpstatus = 0 ;
		}
	  else	{
		kpapplication() ;
		ceol24() ;
		putbin("Keypad turned on",0) ;
		kpstatus = 1 ;
		} ;
	goback() ;
}



vtchcase()
{
	extern int doxla ;
	if ( doxla )
	  then	{
		ledoff( l_xlate ) ;
		doxla = 0 ;
		}
	  else	{
		ledon(  l_xlate ) ;
		doxla = 1 ;
		}
}

vttime() 
{
	extern int chposition ;

	CHAR s[30] ;
	gettim(s) ;
	svinsert(chposition,s,strlen(s)) ;
	chposition = chposition + strlen(s) ;
	fixposition() ;
	scmove() ;
	retype() ;
}

vtlreverse()
{
	revline() ;
	creset() ;
	scmove() ;
	retype() ;
}
	





vtsetcommand()
{

/*	25-JUN-1985 10:14  BDN	Remove call to MALLOC()		*/

	CHAR junk[64] ;
	register CHAR *cp ;
	register int size ;
	CHAR *cpsave ;

	cp = junk ;
	ceol24() ;
	if ( ( size = cvtstring(cp,getprm(cp,"SET> ",64),044) ) != 0 )
	  then	{
		*(cp+size) = 0 ;
		if ( instr(cp,strlen(cp),"SET",3) == 1 )
		  then	{
			while (*cp != 0 && isletter(*cp) ) cp++ ;
			while (*cp != 0 && *cp == SPACE  ) cp++ ;
			}
		dosetcmd(cp) ;
		}
	goback() ;
	return(1) ;
}



vtccase()
{
	extern int *curline,cut_st,*loclow,worklength,rept ;
	register int i,times ;

	if ( cut_st )
	  then	{
		if ( ( times = *curline-cut_st ) > 0 )
		  then	{
			scunloadline() ;
			if ( cut_st < *loclow ) then cnpage(cut_st) ;
			*curline = cut_st ;
			cut_st = 0 ;
			for ( ; times > 0 ; times-- ) {
			  creset() ;
			  scloadline() ;
			  scmove() ;
			  for ( i=worklength; i>0; i-- ) ccase(0) ;
			  creset() ;
			  vtmvdown() ;
			  }
			}
		cut_st = 0 ;
		ledoff(l_select) ;
		}
	  else	{
		if ( (times = rept) <= 0 ) then times = 1 ;
		for (; times > 0; times--) ccase(1) ;
		}
}


static ccase(mode)
int mode ;
{
	extern CHAR workbuffer[] ;
	extern int chposition ;
	register CHAR *cp ;
	register int status ;

	cp = &workbuffer[chposition] ;
	if ( atcrlf() == 0 && isletter(*cp) )
	  then	{
		if ( islower(*cp) )
		  then	*cp = toupper(*cp) ;
		  else	*cp = tolower(*cp) ;
		txtmod() ;
		putbin(cp,1) ;
		scmove() ;
		status = 1 ;
		}
	  else	status = 0 ;
	if (mode)
	  then	vter() ;
	  else	if ( atcrlf() == 0 ) then vter() ;
	return( status ) ;
}


	
