Esempio n. 1
0
int
nonl(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "nonl()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->rawt.c_iflag &= ~ICRNL;
	_cursesi_screen->rawt.c_oflag &= ~ONLCR;
	_cursesi_screen->cbreakt.c_iflag &= ~ICRNL;
	_cursesi_screen->cbreakt.c_oflag &= ~ONLCR;
	_cursesi_screen->baset.c_iflag &= ~ICRNL;
	_cursesi_screen->baset.c_oflag &= ~ONLCR;

	_cursesi_screen->nl = 0;
	__pfast = 1;
	return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ?
			  TCSASOFT | TCSADRAIN : TCSADRAIN,
			  _cursesi_screen->curt) ? ERR : OK);
}
Esempio n. 2
0
int
__nodelay(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "__nodelay()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->rawt.c_cc[VMIN] = 0;
	_cursesi_screen->rawt.c_cc[VTIME] = 0;
	_cursesi_screen->cbreakt.c_cc[VMIN] = 0;
	_cursesi_screen->cbreakt.c_cc[VTIME] = 0;
	_cursesi_screen->baset.c_cc[VMIN] = 0;
	_cursesi_screen->baset.c_cc[VTIME] = 0;

	if (tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSANOW,
	    _cursesi_screen->curt)) {
		__restore_termios();
		return ERR;
	}

	return OK;
}
Esempio n. 3
0
int
__timeout(int delay)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "__timeout()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->ovmin = _cursesi_screen->cbreakt.c_cc[VMIN];
	_cursesi_screen->ovtime = _cursesi_screen->cbreakt.c_cc[VTIME];
	_cursesi_screen->rawt.c_cc[VMIN] = 0;
	_cursesi_screen->rawt.c_cc[VTIME] = delay;
	_cursesi_screen->cbreakt.c_cc[VMIN] = 0;
	_cursesi_screen->cbreakt.c_cc[VTIME] = delay;
	_cursesi_screen->baset.c_cc[VMIN] = 0;
	_cursesi_screen->baset.c_cc[VTIME] = delay;

	if (tcsetattr(fileno(_cursesi_screen->infd),
			  __tcaction ? TCSASOFT | TCSANOW : TCSANOW,
			  _cursesi_screen->curt)) {
		__restore_termios();
		return ERR;
	}

	return OK;
}
Esempio n. 4
0
/*
 * nocbreak --
 *	Disable cbreak mode
 */
int
nocbreak(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "nocbreak()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	__rawmode = 0;
	if (_cursesi_screen->notty == TRUE)
		return OK;
	  /* if we were in halfdelay mode then nuke the timeout */
	if ((_cursesi_screen->half_delay == TRUE) &&
	    (__notimeout() == ERR))
		return ERR;

	_cursesi_screen->half_delay = FALSE;
	_cursesi_screen->curt = _cursesi_screen->useraw ?
		&_cursesi_screen->rawt : &_cursesi_screen->baset;
	return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ?
			  TCSASOFT | TCSADRAIN : TCSADRAIN,
			  _cursesi_screen->curt) ? ERR : OK);
}
Esempio n. 5
0
void
__save_termios(void)
{
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return;
	_cursesi_screen->ovmin = _cursesi_screen->cbreakt.c_cc[VMIN];
	_cursesi_screen->ovtime = _cursesi_screen->cbreakt.c_cc[VTIME];
}
Esempio n. 6
0
int
noecho(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "noecho()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	__echoit = 0;
	return (OK);
}
Esempio n. 7
0
/*
 * noraw --
 *	Put the terminal into cooked mode
 */
int
noraw(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "noraw()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	_cursesi_screen->useraw = __pfast = __rawmode = 0;
	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->curt = &_cursesi_screen->baset;
	return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN,
	    _cursesi_screen->curt) ? ERR : OK;
}
Esempio n. 8
0
/*
 * raw --
 *	Put the terminal into raw mode
 */
int
raw(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "raw()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	_cursesi_screen->useraw = __pfast = __rawmode = 1;
	_cursesi_screen->curt = &_cursesi_screen->rawt;
	if (_cursesi_screen->notty == TRUE)
		return OK;
	return (tcsetattr(fileno(_cursesi_screen->infd), __tcaction ?
			  TCSASOFT | TCSADRAIN : TCSADRAIN,
			  _cursesi_screen->curt) ? ERR : OK);
}
Esempio n. 9
0
/*
 * cbreak --
 * 	Enable cbreak mode
 */
int
cbreak(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "cbreak()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	__rawmode = 1;
	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->curt = _cursesi_screen->useraw ?
		&_cursesi_screen->rawt : &_cursesi_screen->cbreakt;
	return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN,
	    _cursesi_screen->curt) ? ERR : OK;
}
Esempio n. 10
0
int
__notimeout(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "__notimeout()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->rawt.c_cc[VMIN] = 1;
	_cursesi_screen->rawt.c_cc[VTIME] = 0;
	_cursesi_screen->cbreakt.c_cc[VMIN] = 1;
	_cursesi_screen->cbreakt.c_cc[VTIME] = 0;
	_cursesi_screen->baset.c_cc[VMIN] = 1;
	_cursesi_screen->baset.c_cc[VTIME] = 0;

	return (tcsetattr(fileno(_cursesi_screen->infd),
			  __tcaction ? TCSASOFT | TCSANOW : TCSANOW,
			  _cursesi_screen->curt) ? ERR : OK);
}
Esempio n. 11
0
int
intrflush(WINDOW *win, bool bf)	/*ARGSUSED*/
{
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	if (bf) {
		_cursesi_screen->rawt.c_lflag &= ~NOFLSH;
		_cursesi_screen->cbreakt.c_lflag &= ~NOFLSH;
		_cursesi_screen->baset.c_lflag &= ~NOFLSH;
	} else {
		_cursesi_screen->rawt.c_lflag |= NOFLSH;
		_cursesi_screen->cbreakt.c_lflag |= NOFLSH;
		_cursesi_screen->baset.c_lflag |= NOFLSH;
	}

	__pfast = 1;
	return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN,
	    _cursesi_screen->curt) ? ERR : OK;
}
Esempio n. 12
0
/*
 * stop_signal_handler --
 *	Handle stop signals.
 */
void
__stop_signal_handler(/*ARGSUSED*/int signo)
{
	sigset_t oset, set;

	/*
	 * Block window change and timer signals.  The latter is because
	 * applications use timers to decide when to repaint the screen.
	 */
	(void) sigemptyset(&set);
	(void) sigaddset(&set, SIGALRM);
	(void) sigaddset(&set, SIGWINCH);
	(void) sigprocmask(SIG_BLOCK, &set, &oset);

	/*
	 * End the window, which also resets the terminal state to the
	 * original modes.
	 */
	__stopwin();

	/* Unblock SIGTSTP. */
	(void) sigemptyset(&set);
	(void) sigaddset(&set, SIGTSTP);
	(void) sigprocmask(SIG_UNBLOCK, &set, NULL);

	/* Stop ourselves. */
	(void) kill(0, SIGTSTP);

	/* Time passes ... */

	/* restart things */
	__restartwin();

	/* Reset the signals. */
	(void) sigprocmask(SIG_SETMASK, &oset, NULL);
}
Esempio n. 13
0
int
nl(void)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_MISC, "nl()\n");
#endif
	/* Check if we need to restart ... */
	if (_cursesi_screen->endwin)
		__restartwin();

	if (_cursesi_screen->notty == TRUE)
		return OK;
	_cursesi_screen->rawt.c_iflag |= ICRNL;
	_cursesi_screen->rawt.c_oflag |= ONLCR;
	_cursesi_screen->cbreakt.c_iflag |= ICRNL;
	_cursesi_screen->cbreakt.c_oflag |= ONLCR;
	_cursesi_screen->baset.c_iflag |= ICRNL;
	_cursesi_screen->baset.c_oflag |= ONLCR;

	_cursesi_screen->nl = 1;
	_cursesi_screen->pfast = _cursesi_screen->rawmode;
	return tcsetattr(fileno(_cursesi_screen->infd), TCSASOFT | TCSADRAIN,
	    _cursesi_screen->curt) ? ERR : OK;
}