Beispiel #1
0
void
tty_putcode2(struct tty *tty, enum tty_code_code code, int a, int b)
{
	if (a < 0 || b < 0)
		return;
	tty_puts(tty, tty_term_string2(tty->term, code, a, b));
}
Beispiel #2
0
void
tty_stop_tty(struct tty *tty)
{
	struct winsize	ws;

	/*
	 * Be flexible about error handling and try not kill the server just
	 * because the fd is invalid. Things like ssh -t can easily leave us
	 * with a dead tty.
	 */
	if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
		return;
	if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)
		return;

	tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
	tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
	tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
	tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX));
	tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
	tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR));

	tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
	if (tty_term_has(tty->term, TTYC_KMOUS))
		tty_raw(tty, "\033[?1000l");
}
Beispiel #3
0
void
tty_stop_tty(struct tty *tty)
{
	struct winsize	ws;

	if (!(tty->flags & TTY_STARTED))
		return;
	tty->flags &= ~TTY_STARTED;

	bufferevent_disable(tty->event, EV_READ|EV_WRITE);

	/*
	 * Be flexible about error handling and try not kill the server just
	 * because the fd is invalid. Things like ssh -t can easily leave us
	 * with a dead tty.
	 */
	if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
		return;
	if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)
		return;

	setblocking(tty->fd, 1);

	tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
	if (tty_use_acs(tty))
		tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
	tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
	tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX));
	tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR));
	if (tty_term_has(tty->term, TTYC_CS1) && tty->cstyle != 0) {
		if (tty_term_has(tty->term, TTYC_CSR1))
			tty_raw(tty, tty_term_string(tty->term, TTYC_CSR1));
		else
			tty_raw(tty, tty_term_string1(tty->term, TTYC_CS1, 0));
	}
	tty_raw(tty, tty_term_string(tty->term, TTYC_CR));

	tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
	if (tty_term_has(tty->term, TTYC_KMOUS))
		tty_raw(tty, "\033[?1000l");

	tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));

	if (tty->xterm_version > 270)
		tty_raw(tty, "\033[61;1\"p");
}
Beispiel #4
0
Datei: tty.c Projekt: jnbek/tmux
void
tty_stop_tty(struct tty *tty)
{
    struct winsize	ws;
    int		mode;

    if (!(tty->flags & TTY_STARTED))
        return;
    tty->flags &= ~TTY_STARTED;

    bufferevent_disable(tty->event, EV_READ|EV_WRITE);

    /*
     * Be flexible about error handling and try not kill the server just
     * because the fd is invalid. Things like ssh -t can easily leave us
     * with a dead tty.
     */
    if (ioctl(tty->fd, TIOCGWINSZ, &ws) == -1)
        return;
    if (tcsetattr(tty->fd, TCSANOW, &tty->tio) == -1)
        return;

    tty_raw(tty, tty_term_string2(tty->term, TTYC_CSR, 0, ws.ws_row - 1));
    tty_raw(tty, tty_term_string(tty->term, TTYC_RMACS));
    tty_raw(tty, tty_term_string(tty->term, TTYC_SGR0));
    tty_raw(tty, tty_term_string(tty->term, TTYC_RMKX));
    tty_raw(tty, tty_term_string(tty->term, TTYC_CLEAR));

    tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
    if (tty_term_has(tty->term, TTYC_KMOUS))
        tty_raw(tty, "\033[?1000l");

    tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));

    if ((mode = fcntl(tty->fd, F_GETFL)) != -1)
        fcntl(tty->fd, F_SETFL, mode & ~O_NONBLOCK);
}