Revision: 2741
          http://tmux.svn.sourceforge.net/tmux/?rev=2741&view=rev
Author:   tcunha
Date:     2012-03-18 02:03:15 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
Sync OpenBSD patchset 1062:

Break out termios initialization into a separate function, from George
Nachman.

Modified Paths:
--------------
    trunk/tmux.h
    trunk/tty.c

Modified: trunk/tmux.h
===================================================================
--- trunk/tmux.h        2012-03-18 02:02:18 UTC (rev 2740)
+++ trunk/tmux.h        2012-03-18 02:03:15 UTC (rev 2741)
@@ -1440,6 +1440,7 @@
 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 *);

Modified: trunk/tty.c
===================================================================
--- trunk/tty.c 2012-03-18 02:02:18 UTC (rev 2740)
+++ trunk/tty.c 2012-03-18 02:03:15 UTC (rev 2741)
@@ -175,18 +175,19 @@
 }
 
 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,9 +195,15 @@
            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);
 
        tty_putcode(tty, TTYC_SGR0);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to