コード例 #1
0
ファイル: cmds.c プロジェクト: AlfredArouna/illumos-gate
/*
 * Suspend tip
 */
void
suspend(int c)
{

	unraw();
	(void) kill(c == _CTRL('y') ? getpid() : 0, SIGTSTP);
	raw();
}
コード例 #2
0
ファイル: wbkgd.c プロジェクト: andreiw/polaris
int
wbkgd(WINDOW *win, chtype nbkgd)
{
	short	maxx;
	int	x, y;
	chtype	*wcp, obkgda, obkgdc, nbkgda,
		nbkgdc, acolor, c;
	short	*begch, *endch;

	/* if 'nbkgd' contains color information, but this is not a color   */
	/* terminal, erase that information.				*/

	if ((nbkgd & A_COLOR) && (cur_term->_pairs_tbl == NULL))
		nbkgd &= ~A_COLOR;

	if (nbkgd == win->_bkgd)
		return (OK);

	obkgdc = _CHAR(win->_bkgd);
	obkgda = _ATTR(win->_bkgd);

	nbkgdc = _CHAR(nbkgd);
	nbkgda = _ATTR(nbkgd);

	/* switch byte order if necessary */
	if (ISCBIT(nbkgdc))
		nbkgdc = _CHAR((RBYTE(nbkgdc) << 8) | (LBYTE(nbkgdc)|MBIT)) |
		    CBIT;
	c = RBYTE(nbkgdc);
	if ((nbkgdc < ' ' || nbkgdc == _CTRL('?')) ||
	    _curs_scrwidth[TYPE(c)] > 1)
		nbkgdc = obkgdc;
	nbkgd = (nbkgdc & ~CBIT) | nbkgda;

	win->_bkgd = nbkgd;

	/* delete the old background from the attribute field and replace    */
	/* it with the new background.  Note: if the same attribute was	*/
	/* first set by wbkgd() and then by wattron(), or vice versa, it */
	/* will be deleted, so the effect of wattron() will be lost.	 */
	/* This applies to both video and color attributes.		 */

	if ((acolor = (win->_attrs & A_COLOR)) != 0) {
		if (acolor == (obkgda & A_COLOR)) {
			win->_attrs = _ATTR((win->_attrs & ~obkgda) | nbkgda);
		} else {
			win->_attrs = _ATTR((win->_attrs &
			    (~obkgda | A_COLOR)) | (nbkgda & ~A_COLOR));
		}
	} else
		win->_attrs = _ATTR((win->_attrs & ~obkgda) | nbkgda);

	maxx = win->_maxx - 1;
	begch = win->_firstch;
	endch = win->_lastch;
	for (y = win->_maxy-1; y >= 0; --y, ++begch, ++endch) {
		for (x = maxx, wcp = win->_y[y]; x-- >= 0; ++wcp) {
			if ((c = _CHAR(*wcp)) == obkgdc)
				c = nbkgdc;
			if ((acolor = (*wcp & A_COLOR)) != 0) {
				if (acolor == (obkgda & A_COLOR))
					*wcp = c | _ATTR((*wcp & ~obkgda) |
					    nbkgda);
				else
					*wcp = c | _ATTR((*wcp & (~obkgda |
					    A_COLOR)) | (nbkgda & ~A_COLOR));
			} else
				*wcp = c | _ATTR((*wcp & ~obkgda) | nbkgda);
		}
		*begch = 0;
		*endch = maxx;
	}

	win->_flags |= _WINCHANGED;
	if (win->_sync)
		wsyncup(win);

	return (win->_immed ? wrefresh(win) : OK);
}
コード例 #3
0
ファイル: waddch.c プロジェクト: apprisi/illumos-gate
int
waddch(WINDOW *win, chtype c)
{
	short	x = win->_curx;
	short	y = win->_cury;
	chtype	rawc = _CHAR(c);
	chtype	rawattrs = _ATTR(c);
	int	rv = OK;
	bool	savimmed = win->_immed;
	bool	savsync = win->_sync;

	win->_immed = win->_sync = FALSE;

#ifdef	DEBUG
	if (outf)
		if (c == rawc)
			fprintf(outf, "'%c'", rawc);
		else
			fprintf(outf, "'%c' %o, raw %o", c, c, rawc);
#endif	/* DEBUG */

	win->_insmode = FALSE;
	if (_scrmax > 1 && _mbvalid(win) == ERR)
		goto next;
	if (_mbtrue && ISMBIT(rawc)) {
		rv = _mbaddch(win, rawattrs, RBYTE(rawc));
		win->_immed = savimmed;
		win->_sync = savsync;
		goto nextw;
	}

	switch (rawc) {
		case '\n':
			(void) wclrtoeol(win);
			goto new_line;
		case '\r':
			goto move_to_begin_line;
		case '\b':
			if (--x < 0)
move_to_begin_line:
				x = 0;
			win->_curx = x;
			win->_flags |= _WINMOVED;
			goto out_move_only;
		default:
			if (rawc < ' ' || rawc == _CTRL('?')) {
				if (rawc == '\t') {
					int	newx;
					chtype	space = ' ' | rawattrs;

					if ((newx = x + (TABSIZE -
					    (x % TABSIZE))) > win->_maxx)
						newx = win->_maxx;
						for (; x < newx; x++)
							if (waddch(win,
							    space) == ERR)
								goto next;
				} else {
					if ((waddch(win, (chtype)
					    '^'|rawattrs) == ERR) ||
					    (waddch(win, (chtype)
					    _UNCTRL(rawc)|rawattrs) == ERR)) {
next :
						rv = ERR;
				}
			}
			x = win->_curx;
			y = win->_cury;
			win->_immed = savimmed;
			win->_sync = savsync;
			break;
		}
#ifdef	DEBUG
		if ((win->_attrs) && outf)
			fprintf(outf, "(attrs %o, %o=>%o)", win->_attrs,
			    c, c | win->_attrs);
#endif	/* DEBUG */

		/* clear any partial multi-column character */
		if (_scrmax > 1 && ISMBIT(win->_y[y][x]) &&
		    (rv = _mbclrch(win, y, x)) == ERR) {
			x = win->_curx;
			y = win->_cury;
			win->_immed = savimmed;
			win->_sync = savsync;
			break;
		}

		if ((c = _WCHAR(win, c)|rawattrs) != win->_y[y][x]) {
			if (x < win->_firstch[y])
				win->_firstch[y] = x;
			if (x > win->_lastch[y])
				win->_lastch[y] = x;
			win->_y[y][x] = c;
#ifdef	_VR3_COMPAT_CODE
			if (_y16update)
				/* LINTED */
				win->_y16[y][x] = _TO_OCHTYPE(c);
#endif	/* _VR3_COMPAT_CODE */
		}
		if (++x == win->_maxx) {
new_line:
			if (y == win->_bmarg) {
				if (wscrl(win, 1) == ERR) {
					rv = ERR;
					if (x == win->_maxx)
						--x;
#ifdef	DEBUG
					if (outf) {
						int	i;

						fprintf(outf, "ERR because "
						    "(%d, %d) > (%d, %d)\n",
						    x, y, win->_maxx,
						    win->_maxy);
						fprintf(outf, "line: '");
						for (i = 0; i < win->_maxy;
						    i++)
							fprintf(outf, "%c",
							    win->_y[y-1][i]);
						fprintf(outf, "'\n");
					}
#endif	/* DEBUG */
					break;
				} else
					savimmed = 1;
			} else
				y++;
				x = 0;
		} else
			savimmed += 2;
#ifdef	FULLDEBUG
		if (outf)
			fprintf(outf, "ADDCH: 2: y = %d, x = %d, "
			    "firstch = %d, lastch = %d\n", y, x,
			    win->_firstch[y], win->_lastch[y]);
#endif	/* FULLDEBUG */
		break;
	}
	win->_cury = y;
	win->_curx = x;

nextw:
	/* sync with ancestor structures */
	if (win->_sync)
		wsyncup(win);

	if (savimmed == 3)
		return ((*_quick_ptr)(win, c));

	win->_flags |= _WINCHANGED;

out_move_only:

	return ((savimmed == 1) ? wrefresh(win) : rv);
}
コード例 #4
0
ファイル: tty.c プロジェクト: stqism/DEMOS
#define stty(f, s)      ioctl(f, TCSETA, s)
#define gtty(f, s)      ioctl(f, TCGETA, s)
#define sg_erase        c_cc[VERASE]
#define sg_kill         c_cc[VKILL]
#define sgttyb termio

static struct termio svm;       /* Saved old modes */

#undef TIOCSTI
#undef TIOCSETA
#endif

#define _CTRL(c) ((c)&037)

static  int     crterase = 1;    /* TTY allows CRT BS-ing */
static  int     c_erase = _CTRL('H');            /* Current erase char */
static  int     c_kill =  _CTRL('U');            /* Current kill char */
static  int     c_intr = _CTRL('C');
static  int     c_quit = _CTRL('\\');
static  int     hadcont;                /* Saw continue signal */
#ifdef  VMUNIX
static  jmp_buf rewrite;                /* Place to go when continued */
#endif
static char *readtty();

#ifndef TIOCSTI
#ifndef MSDOS
#if defined(TIOCSETA)
#define sgttyb  sgttya
#define stty(f, s)      ioctl(f, TIOCSETA, s)
#define gtty(f, s)      ioctl(f, TIOCGETA, s)