Ejemplo n.º 1
0
/*
 * Delete nchunk line(s) from "row", replacing the
 * bottom line on the screen with a blank line.
 * Unless we're using the scrolling region, this is
 * done with a crafty sequences of insert and delete
 * lines.  The presence of the echo area makes a
 * boundry condition go away.
 */
ttdell(row, bot, nchunk)
{
    register int	i, nl;

    if (row == bot) {		/* One line special case	*/
	ttmove(row, 0);
	tteeol();
	return;
    }
    if (CS) {			/* scrolling region	*/
	nl = bot - row;
	ttwindow(row, bot);
	ttmove(bot, 0);
	while (nchunk--) putpad(SF, nl);
	ttnowindow();
    }
    else if(insdel) {
	ttmove(row, 0);			/* Else use insert/delete line	*/
	nl = nrow - ttrow;
	if (pDL) putpad(tgoto(pDL, 0, nchunk), nl);
	else for (i=0; i<nchunk; i++)	/* For all lines in the chunk	*/
		putpad(DL, nl);
	ttmove(1+bot-nchunk,0);
	nl = nrow - ttrow;	/* ttmove() changes ttrow */
	if (pAL) putpad(tgoto(pAL, 0, nchunk), nl);
	else for (i=0; i<nchunk; i++)	/* For all lines in the chunk	*/
		putpad(AL, nl);
	ttrow = HUGE;
	ttcol = HUGE;
    } else panic("ttdell: Can't insert/delete line");
}
Ejemplo n.º 2
0
/*
 * Insert nchunk blank line(s) onto the
 * screen, scrolling the last line on the
 * screen off the bottom.  Use the scrolling
 * region if possible for a smoother display.
 * If no scrolling region, use a set
 * of insert and delete line sequences
 */
ttinsl(row, bot, nchunk) {
    register int	i, nl;

    if (row == bot) {		/* Case of one line insert is	*/
	ttmove(row, 0);		/*	special			*/
	tteeol();
	return;
    }
    if (CS && SR) {		/* Use scroll region and back index	*/
	nl = bot - row;
	ttwindow(row,bot);
	ttmove(row, 0);
	while (nchunk--) putpad(SR, nl);
	ttnowindow();
	return;
    } else if (insdel) {
	ttmove(1+bot-nchunk, 0);
	nl = nrow - ttrow;
	if (pDL) putpad(tgoto(pDL, 0, nchunk), nl);
	else for (i=0; i<nchunk; i++)	/* For all lines in the chunk	*/
		putpad(DL, nl);
	ttmove(row, 0);
	nl = nrow - ttrow;	/* ttmove() changes ttrow */
	if (pAL) putpad(tgoto(pAL, 0, nchunk), nl);
	else for (i=0; i<nchunk; i++)	/* For all lines in the chunk	*/
		putpad(AL, nl);
	ttrow = HUGE;
	ttcol = HUGE;
    } else panic("ttinsl: Can't insert/delete line");
}
Ejemplo n.º 3
0
/*
 * Tidy up the virtual display system
 * in anticipation of a return back to the host
 * operating system. Right now all we do is position
 * the cursor to the last line, erase the line, and
 * close the terminal channel.
 */
void
vttidy (void)
{
  ttcolor (CTEXT);
  ttnowindow ();		/* No scroll window.    */
  ttmove (nrow - 1, 0);		/* Echo line.           */
  tteeol ();
  tttidy ();
  ttflush ();
  ttclose ();
}
Ejemplo n.º 4
0
/*
 * Insert nchunk blank line(s) onto the screen, scrolling the last line on
 * the screen off the bottom.  Use the scrolling region if possible for a
 * smoother display.  If there is no scrolling region, use a set of insert
 * and delete line sequences.
 */
void
ttinsl(int row, int bot, int nchunk)
{
	int	i, nl;

	/* Case of one line insert is special. */
	if (row == bot) {
		ttmove(row, 0);
		tteeol();
		return;
	}
	if (change_scroll_region && scroll_reverse) {
		/* Use scroll region and back index	 */
		nl = bot - row;
		ttwindow(row, bot);
		ttmove(row, 0);
		while (nchunk--)
			putpad(scroll_reverse, nl);
		ttnowindow();
		return;
	} else if (insdel) {
		ttmove(1 + bot - nchunk, 0);
		nl = nrow - ttrow;
		if (parm_delete_line)
			putpad(tgoto(parm_delete_line, 0, nchunk), nl);
		else
			/* For all lines in the chunk... */
			for (i = 0; i < nchunk; i++)
				putpad(delete_line, nl);
		ttmove(row, 0);

		/* ttmove() changes ttrow */
		nl = nrow - ttrow;

		if (parm_insert_line)
			putpad(tgoto(parm_insert_line, 0, nchunk), nl);
		else
			/* For all lines in the chunk */
			for (i = 0; i < nchunk; i++)
				putpad(insert_line, nl);
		ttrow = HUGE;
		ttcol = HUGE;
	} else
		panic("ttinsl: Can't insert/delete line");
}
Ejemplo n.º 5
0
/*
 * Delete nchunk line(s) from "row", replacing the bottom line on the
 * screen with a blank line.  Unless we're using the scrolling region,
 * this is done with crafty sequences of insert and delete lines.  The
 * presence of the echo area makes a boundary condition go away.
 */
void
ttdell(int row, int bot, int nchunk)
{
	int	i, nl;

	/* One line special cases */
	if (row == bot) {
		ttmove(row, 0);
		tteeol();
		return;
	}
	/* scrolling region */
	if (change_scroll_region) {
		nl = bot - row;
		ttwindow(row, bot);
		ttmove(bot, 0);
		while (nchunk--)
			putpad(scroll_fwd, nl);
		ttnowindow();
	/* else use insert/delete line */
	} else if (insdel) {
		ttmove(row, 0);
		nl = nrow - ttrow;
		if (parm_delete_line)
			putpad(tgoto(parm_delete_line, 0, nchunk), nl);
		else
			/* For all lines in the chunk	 */
			for (i = 0; i < nchunk; i++)
				putpad(delete_line, nl);
		ttmove(1 + bot - nchunk, 0);

		/* ttmove() changes ttrow */
		nl = nrow - ttrow;
		if (parm_insert_line)
			putpad(tgoto(parm_insert_line, 0, nchunk), nl);
		else
			/* For all lines in the chunk */
			for (i = 0; i < nchunk; i++)
				putpad(insert_line, nl);
		ttrow = HUGE;
		ttcol = HUGE;
	} else
		panic("ttdell: Can't insert/delete line");
}
Ejemplo n.º 6
0
spawncli(f, n)
{
       fortran void comlv$();
       ttcolor(CTEXT);
       ttnowindow();
       ttmove(nrow-1, 0);
       if (epresf != FALSE) {
	       tteeol();
	       epresf = FALSE;
       }
       ttclose();
       comlv$();
       sgarbf = TRUE;		/* Force repaint.	*/
       ttopen();
#ifndef NO_DIR
       (void) dirinit();	/* current directory may have changed */
#endif
       return (TRUE);
}
Ejemplo n.º 7
0
/*ARGSUSED*/
spawncli(f, n) {
	register void	(*oisig)();
	int		status;
#ifdef	EXTD_DIR
	ensurecwd();
#endif

	if (shellp == NULL) {
		shellp = getenv("SHELL");
		if (shellp == NULL)
			shellp = getenv("shell");
		if (shellp == NULL)
			shellp = "command.x";	/* Safer.		*/
	}
	ttcolor(CTEXT);
	ttnowindow();
	ttmove(nrow-1, 0);
	if (epresf != FALSE) {
		tteeol();
		epresf = FALSE;
	}
	ttclose();
	sgarbf = TRUE;				/* Force repaint.	*/
	oisig = signal(SIGINT,  SIG_IGN);
#ifdef	EXTD_DIR
	dirend();
#endif
	if (spawnlp(P_WAIT, shellp, shellp, NULL) == -1) {
		status = FALSE;
	} else {
		status = TRUE;
	}
	(VOID) signal(SIGINT,  oisig);
	ttopen();
	if(status == FALSE) {
		ewprintf("Failed to run %s", shellp);
		sleep(2);		/* Show this message for 2 sec	*/
					/* before refresh screen.	*/
	}
	dirinit();
	return (status);
}
Ejemplo n.º 8
0
/*
 * Delete nchunk line(s) from "row", replacing the
 * bottom line on the screen with a blank line. 
 * Unless we're using the scrolling region, this is 
 * done with a crafty sequences of insert and delete 
 * lines.  The presence of the echo area makes a
 * boundry condition go away.
 */
void
ttdell (int row, int bot, int nchunk)
{
  register int i;

  if (row == bot)
    {				/* One line special case        */
      ttmove (row, 0);
      tteeol ();
      return;
    }
  if (CS)
    {				/* scrolling region     */
      ttwindow (row, bot);
      ttmove (bot, 0);
      while (nchunk--)
	ttputc (LF);
      ttnowindow ();
    }
  else if (insdel)
    {
      ttmove (row, 0);		/* Else use insert/delete line  */
      if (pDL)
	putpad (tgoto (pDL, 0, nchunk));
      else
	for (i = 0; i < nchunk; i++)	/* For all lines in the chunk   */
	  putpad (DL);
      ttmove (1 + bot - nchunk, 0);
      if (pAL)
	putpad (tgoto (pAL, 0, nchunk));
      else
	for (i = 0; i < nchunk; i++)	/* For all lines in the chunk   */
	  putpad (AL);
      ttrow = HUGE;
      ttcol = HUGE;
    }
  else
    panic ("ttdell: Can't insert/delete line");
}
Ejemplo n.º 9
0
/*ARGSUSED*/
spawncli(f, n)
{
	extern char	*strrchr();
	register int	pid;
	register int	wpid;
	register VOID	(*oqsig)();
	register VOID	(*oisig)();
#ifdef	ADDFUNC		/* 93.07.08  by S.Yoshida */
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
	register VOID	(*owsig)();
#endif
#ifdef	SIGTSTP	/* 93.07.08  by S.Yoshida */
	register int	omask;
#endif
#endif	/* ADDFUNC */
	int		status = FALSE;
	int		errp = FALSE;

#ifdef XKEYS  /* 92.03.16 by Gen KUROKI */
	ttykeymaptidy();
#endif /* XKEYS */
	if (shellp == NULL) {
		shellp = getenv("SHELL");
		if (shellp == NULL)
			shellp = getenv("shell");
		if (shellp == NULL)
			shellp = "/bin/sh";	/* Safer.		*/
		shname = strrchr( shellp, '/' ); 
		shname = shname ? shname+1 : shellp;
	}
	ttcolor(CTEXT);
	ttnowindow();
#ifdef	ADDFUNC	/* 93.07.08  by S.Yoshida */
#ifdef	SIGTSTP	/* 93.07.08  by S.Yoshida */
	if (strcmp(shellp, "/bin/csh") == 0) {
		if (epresf != FALSE) {
			ttmove(nrow-1, 0);
			tteeol();
			epresf = FALSE;
		}				/* Csh types a "\n"	*/
		ttmove(nrow-2, 0);		/* before "Stopped".	*/
	} else {
#endif
#endif
	ttmove(nrow-1, 0);
	if (epresf != FALSE) {
		tteeol();
		epresf = FALSE;
	}
#ifdef	ADDFUNC	/* 93.07.08  by S.Yoshida */
#ifdef	SIGTSTP	/* 93.07.08  by S.Yoshida */
	}
#endif
#endif
	ttclose();
	sgarbf = TRUE;				/* Force repaint.	*/
#ifdef	ADDFUNC	/* 93.07.08  by S.Yoshida */
#ifdef	SIGTSTP	/* 93.07.08  by S.Yoshida */
# ifdef HAVE_GETSID
	if (job_control) {
# else
	if (strcmp(shellp, "/bin/sh")!=0 ||
	    getenv("BASH_VERSION") || getenv("BASH"))	{
		/* C shell, ksh	or bash	*/
# endif
	    /*	omask = sigsetmask(0);  */
		oqsig = signal(SIGQUIT, SIG_IGN);
		oisig = signal(SIGINT,  SIG_IGN);
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
		owsig = signal(SIGWINCH, SIG_IGN);
#endif
		(void) kill(0, SIGTSTP);
	    /*	(void) sigsetmask(omask); */
		signal(SIGINT,  oisig);
		signal(SIGQUIT, oqsig);
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
		signal(SIGWINCH, owsig);
#endif
	} else {				/* Bourne shell.	*/
#endif	/* SIGTSTP */	
#endif	/* ADDFUNC */
	oqsig = signal(SIGQUIT, SIG_IGN);
	oisig = signal(SIGINT,  SIG_IGN);
#ifdef	ADDFUNC		/* 93.07.08  by S.Yoshida */
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
	owsig = signal(SIGWINCH, SIG_IGN);
#endif
#endif
	if ((pid=fork()) == 0) {
		(void) signal(SIGINT, oisig);
		(void) signal(SIGQUIT, oqsig);
#ifdef	ADDFUNC		/* 93.07.08  by S.Yoshida */
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
		(void) signal(SIGWINCH, owsig);
#endif
#endif
#ifdef	EXTD_DIR
		dirend();
#endif
		execlp(shellp, shname, "-i", (char *)NULL);
		_exit(1);			/* Should do better!	*/
	}
	else if (pid > 0) {
		while ((wpid=wait(&status))>=0 && wpid!=pid)
			;
	}
	else errp = TRUE;

	signal(SIGINT,  oisig);
	signal(SIGQUIT, oqsig);
#ifdef	ADDFUNC		/* 93.07.08  by S.Yoshida */
#ifdef	SIGWINCH	/* 93.07.08  by S.Yoshida */
	signal(SIGWINCH, owsig);
#endif
#ifdef	SIGTSTP	/* 93.07.08  by S.Yoshida */
	}
#endif
#endif
	ttopen();
#ifdef SIGWINCH		/* by A.ITO  21 Jan. 1991 / by S.Yoshida */
	refresh(FFRAND, 0);		/* May be resized.	*/
#endif
	if(errp)
		ewprintf("Failed to create process");
#ifdef XKEYS  /* 92.03.16 by Gen KUROKI */
	ttykeypadstart();
#endif /* XKEYS */

	return !( errp | status );
}

#ifndef NO_SHELL	/* 91.01.10  by K.Maeda */
#include <sys/types.h>
#include <sys/stat.h>
/*
 *	Call process in subshell.
 * Execute COMMAND binding standard input to file INPUT.
 * NULL as INPUT means standard input should be bound to
 * /dev/null or whatever equivalent in your OS.
 * All output during the execution (including standard error output)
 * should go into a scratch file, whose name call_process() returns.
 * Return value NULL means error in some stage of the execution.
 * In that case, scratch file should be deleted.
 */
char *
call_process(command, input)
char *command;
char *input;
{
	char buf[256];
	char *tmp;
	static char tmpbuf[20];
	int ostdin, ostdout, ostderr, in, out, s;
	extern char *mktemp();

	strcpy(tmpbuf, "/tmp/ngXXXXXX");
	if ((tmp = mktemp(tmpbuf)) == NULL)
		return NULL;
	if ((in = open(input ? input : "/dev/null", 0)) < 0)
		return NULL;
	if ((out = creat(tmp, S_IREAD | S_IWRITE)) < 0) {
		close(in);
		return NULL;
	}
	ostdin = dup(0); ostdout = dup(1); ostderr = dup(2);
	if (ostdin < 0 || ostdout < 0 || ostderr < 0) {
		s = -1;
		goto skip;
	}
#ifndef	SVR2	/* 91.02.04  SVR3 or later. by Junn Ohta */
	dup2(in, 0);
	dup2(out, 1);
	dup2(out, 2);
#else	/* SVR2 */
	close(0); dup(in);
	close(1); dup(out);
	close(2); dup(out);
#endif	/* SVR2 */
	strcpy(buf, command);
#ifdef	EXTD_DIR
	ensurecwd();
#endif
	s = system(buf);
	close(in);
	close(out);
#ifndef	SVR2	/* 91.02.04  SVR3 or later. by Junn Ohta */
	dup2(ostdin, 0); dup2(ostdout, 1); dup2(ostderr, 2);
#else	/* SVR2 */
	close(0); dup(ostdin);
	close(1); dup(ostdout);
	close(2); dup(ostderr);
#endif	/* SVR2 */
skip:	close(ostdin); close(ostdout); close(ostderr);
	if (s == -1) {
		unlink(tmp);
		return NULL;
	}
	return tmp;
}