repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: b993fc91b22fd29dd5329d12d44419f7cc0440b6: path_to: revision_to:
commit b993fc91b22fd29dd5329d12d44419f7cc0440b6 Author: Emanuele GiaquintaDate: Wed Jul 28 17:56:16 2010 +0000 Init termios structure once at startup and try to inherit user's terminal state. diff --git a/src/init.C b/src/init.C
--- a/src/init.C
+++ b/src/init.C
@@ -1506,160 +1506,6 @@ rxvt_term::create_windows (int argc, const char *const *argv)
scr_recolour ();
}
-/* ------------------------------------------------------------------------- *
- * GET TTY CURRENT STATE *
- * ------------------------------------------------------------------------- */
-static void
-rxvt_get_ttymode (struct termios *tio)
-{
- /*
- * standard System V termios interface
- */
- // does not work as stdin is not a tty
- // if (tcgetattr (STDIN_FILENO, tio) < 0)
- if (1)
- {
- // return error - use system defaults,
- // where possible, and zero elsewhere
- memset (tio, 0, sizeof (struct termios));
- if (VDISABLE)
- for (int i = 0; i < NCCS; i++)
- tio->c_cc[i] = VDISABLE;
-
- tio->c_cc[VINTR] = CINTR;
- tio->c_cc[VQUIT] = CQUIT;
- tio->c_cc[VERASE] = CERASE;
-#ifdef VERASE2
- tio->c_cc[VERASE2] = CERASE2;
-#endif
- tio->c_cc[VKILL] = CKILL;
- tio->c_cc[VSTART] = CSTART;
- tio->c_cc[VSTOP] = CSTOP;
- tio->c_cc[VSUSP] = CSUSP;
-# ifdef VDSUSP
- tio->c_cc[VDSUSP] = CDSUSP;
-# endif
-# ifdef VREPRINT
- tio->c_cc[VREPRINT] = CRPRNT;
-# endif
-# ifdef VDISCRD
- tio->c_cc[VDISCRD] = CFLUSH;
-# endif
-# ifdef VWERSE
- tio->c_cc[VWERSE] = CWERASE;
-# endif
-# ifdef VLNEXT
- tio->c_cc[VLNEXT] = CLNEXT;
-# endif
- }
-
- tio->c_cc[VEOF] = CEOF;
-# if VMIN != VEOF
- tio->c_cc[VMIN] = 1;
-# endif
-# if VTIME != VEOL
- tio->c_cc[VTIME] = 0;
-# endif
-
- /* input modes */
- tio->c_iflag = (BRKINT | IGNPAR | ICRNL
-# ifdef IMAXBEL
- | IMAXBEL
-# endif
- | IXON);
-
- /* output modes */
- tio->c_oflag = (OPOST | ONLCR);
-
- /* control modes */
- tio->c_cflag = (CS8 | CREAD);
-
- /* line discipline modes */
- tio->c_lflag = (ISIG | ICANON | IEXTEN | ECHO
-# if defined (ECHOCTL) && defined (ECHOKE)
- | ECHOCTL | ECHOKE
-# endif
- | ECHOE | ECHOK);
-
- /*
- * Debugging
- */
-#ifdef DEBUG_TTYMODE
- /* c_iflag bits */
- fprintf (stderr, "Input flags\n");
-
- /* cpp token stringize doesn't work on all machines */
-# define FOO(flag,name) \
- if ((tio->c_iflag) & flag) \
- fprintf (stderr, "%s ", name)
-
- /* c_iflag bits */
- FOO (IGNBRK, "IGNBRK");
- FOO (BRKINT, "BRKINT");
- FOO (IGNPAR, "IGNPAR");
- FOO (PARMRK, "PARMRK");
- FOO (INPCK, "INPCK");
- FOO (ISTRIP, "ISTRIP");
- FOO (INLCR, "INLCR");
- FOO (IGNCR, "IGNCR");
- FOO (ICRNL, "ICRNL");
- FOO (IXON, "IXON");
- FOO (IXOFF, "IXOFF");
-# ifdef IUCLC
- FOO (IUCLC, "IUCLC");
-# endif
-# ifdef IXANY
- FOO (IXANY, "IXANY");
-# endif
-# ifdef IMAXBEL
- FOO (IMAXBEL, "IMAXBEL");
-# endif
-
- fprintf (stderr, "\n");
-
-# undef FOO
-# define FOO(entry, name) \
- fprintf (stderr, "%-8s = %#04o\n", name, tio->c_cc [entry])
-
- FOO (VINTR, "VINTR");
- FOO (VQUIT, "VQUIT");
- FOO (VERASE, "VERASE");
- FOO (VKILL, "VKILL");
- FOO (VEOF, "VEOF");
- FOO (VEOL, "VEOL");
-# ifdef VEOL2
- FOO (VEOL2, "VEOL2");
-# endif
-# ifdef VSWTC
- FOO (VSWTC, "VSWTC");
-# endif
-# ifdef VSWTCH
- FOO (VSWTCH, "VSWTCH");
-# endif
- FOO (VSTART, "VSTART");
- FOO (VSTOP, "VSTOP");
- FOO (VSUSP, "VSUSP");
-# ifdef VDSUSP
- FOO (VDSUSP, "VDSUSP");
-# endif
-# ifdef VREPRINT
- FOO (VREPRINT, "VREPRINT");
-# endif
-# ifdef VDISCRD
- FOO (VDISCRD, "VDISCRD");
-# endif
-# ifdef VWERSE
- FOO (VWERSE, "VWERSE");
-# endif
-# ifdef VLNEXT
- FOO (VLNEXT, "VLNEXT");
-# endif
-
- fprintf (stderr, "\n");
-# undef FOO
-#endif /* DEBUG_TTYMODE */
-}
-
/*----------------------------------------------------------------------*/
/*
* Run the command in a subprocess and return a file descriptor for the
@@ -1688,7 +1534,7 @@ rxvt_term::run_command (const char *const *argv)
if (!pty->get ())
rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
- rxvt_get_ttymode (&tio);
+ struct termios tio = def_tio;
#ifndef NO_BACKSPACE_KEY
if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1])
diff --git a/src/main.C b/src/main.C
--- a/src/main.C +++ b/src/main.C @@ -32,6 +32,7 @@ #include "../config.h" /* NECESSARY */ #include "rxvt.h" /* NECESSARY */ +#include "init.h" #include "keyboard.h" #include "rxvtperl.h" @@ -52,6 +53,7 @@ # endif #endif +struct termios rxvt_term::def_tio; vectorrxvt_term::termlist; // used to tell global functions which terminal instance is "active" @@ -476,6 +478,70 @@ sig_handlers::sig_term (ev::sig &w, int revents) kill (getpid (), w.signum); } +static void +rxvt_get_ttymode (struct termios *tio) +{ + if (tcgetattr (STDIN_FILENO, tio) < 0) + memset (tio, 0, sizeof (struct termios)); + + for (int i = 0; i < NCCS; i++) + tio->c_cc[i] = VDISABLE; + + tio->c_cc[VINTR] = CINTR; + tio->c_cc[VQUIT] = CQUIT; + tio->c_cc[VERASE] = CERASE; +#ifdef VERASE2 + tio->c_cc[VERASE2] = CERASE2; +#endif + tio->c_cc[VKILL] = CKILL; + tio->c_cc[VEOF] = CEOF; + tio->c_cc[VSTART] = CSTART; + tio->c_cc[VSTOP] = CSTOP; + tio->c_cc[VSUSP] = CSUSP; +# ifdef VDSUSP + tio->c_cc[VDSUSP] = CDSUSP; +# endif +# ifdef VREPRINT + tio->c_cc[VREPRINT] = CRPRNT; +# endif +# ifdef VDISCRD + tio->c_cc[VDISCRD] = CFLUSH; +# endif +# ifdef VWERSE + tio->c_cc[VWERSE] = CWERASE; +# endif +# ifdef VLNEXT + tio->c_cc[VLNEXT] = CLNEXT; +# endif + +# if VMIN != VEOF + tio->c_cc[VMIN] = 1; +# endif +# if VTIME != VEOL + tio->c_cc[VTIME] = 0; +# endif + + /* input modes */ + tio->c_iflag = (BRKINT | IGNPAR | ICRNL +# ifdef IMAXBEL + | IMAXBEL +# endif + | IXON); + + /* output modes */ + tio->c_oflag = (OPOST | ONLCR); + + /* control modes */ + tio->c_cflag = (CS8 | CREAD); + + /* local modes */ + tio->c_lflag = (ISIG | ICANON | IEXTEN | ECHO +# if defined (ECHOCTL) && defined (ECHOKE) + | ECHOCTL | ECHOKE +# endif + | ECHOE | ECHOK); +} + char **rxvt_environ; // startup environment void @@ -484,6 +550,8 @@ rxvt_init () assert (("fontMask must not overlap other RS masks", 0 == (RS_fontMask & (RS_Sel | RS_baseattrMask | RS_customMask | RS_bgMask | RS_fgMask)))); + rxvt_get_ttymode (&rxvt_term::def_tio); + // get rid of stdin/stdout as we don't need them, to free resources dup2 (STDERR_FILENO, STDIN_FILENO); dup2 (STDERR_FILENO, STDOUT_FILENO); diff --git a/src/rxvt.h b/src/rxvt.h
--- a/src/rxvt.h +++ b/src/rxvt.h @@ -1076,7 +1076,7 @@ struct rxvt_term : zero_initialized, rxvt_vars, rxvt_screen /* ---------- */ struct mouse_event MEvent; XComposeStatus compose; - struct termios tio; + static struct termios def_tio; row_col_t oldcursor; #ifdef HAVE_BG_PIXMAP bgPixmap_t bgPixmap;
-----END OF PAGE-----