diff options
author | Tiago Cunha <tcunha@gmx.com> | 2012-03-18 02:03:15 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2012-03-18 02:03:15 +0000 |
commit | be4d77e60fda649fea4efb34a4e0aad143cff0c1 (patch) | |
tree | 22674e40b127514ce284c5dffa3ee877c41066a4 | |
parent | bde45cdd9ca49f0e540ba1d43d0ab312a0a7f77f (diff) | |
download | rtmux-be4d77e60fda649fea4efb34a4e0aad143cff0c1.tar.gz rtmux-be4d77e60fda649fea4efb34a4e0aad143cff0c1.tar.bz2 rtmux-be4d77e60fda649fea4efb34a4e0aad143cff0c1.zip |
Sync OpenBSD patchset 1062:
Break out termios initialization into a separate function, from George
Nachman.
-rw-r--r-- | tmux.h | 1 | ||||
-rw-r--r-- | tty.c | 21 |
2 files changed, 15 insertions, 7 deletions
@@ -1440,6 +1440,7 @@ void environ_update(const char *, struct environ *, struct environ *); void environ_push(struct environ *); /* tty.c */ +void tty_init_termios(int, struct termios *, struct bufferevent *); void tty_raw(struct tty *, const char *); void tty_attributes(struct tty *, const struct grid_cell *); void tty_reset(struct tty *); @@ -175,18 +175,19 @@ tty_error_callback( } void -tty_start_tty(struct tty *tty) +tty_init_termios(int fd, struct termios *orig_tio, struct bufferevent *bufev) { struct termios tio; - if (tty->fd == -1 || tcgetattr(tty->fd, &tty->tio) != 0) + if (fd == -1 || tcgetattr(fd, orig_tio) != 0) return; - setblocking(tty->fd, 0); + setblocking(fd, 0); - bufferevent_enable(tty->event, EV_READ|EV_WRITE); + if (bufev != NULL) + bufferevent_enable(bufev, EV_READ|EV_WRITE); - memcpy(&tio, &tty->tio, sizeof tio); + memcpy(&tio, orig_tio, sizeof tio); tio.c_iflag &= ~(IXON|IXOFF|ICRNL|INLCR|IGNCR|IMAXBEL|ISTRIP); tio.c_iflag |= IGNBRK; tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET); @@ -194,8 +195,14 @@ tty_start_tty(struct tty *tty) ECHOPRT|ECHOKE|ECHOCTL|ISIG); tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; - if (tcsetattr(tty->fd, TCSANOW, &tio) == 0) - tcflush(tty->fd, TCIOFLUSH); + if (tcsetattr(fd, TCSANOW, &tio) == 0) + tcflush(fd, TCIOFLUSH); +} + +void +tty_start_tty(struct tty *tty) +{ + tty_init_termios(tty->fd, &tty->tio, tty->event); tty_putcode(tty, TTYC_SMCUP); |