diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-08-13 19:03:59 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-08-13 19:03:59 +0000 |
commit | 52793e7a3fc7f53b173ee887c221ff4ed38499e8 (patch) | |
tree | 356d4c56edbc1c2e4ed9d567c682dafc30290808 /cmd-new-session.c | |
parent | 2e3bb5a51193269305eca3d689b6c66d08b2530a (diff) | |
download | rtmux-52793e7a3fc7f53b173ee887c221ff4ed38499e8.tar.gz rtmux-52793e7a3fc7f53b173ee887c221ff4ed38499e8.tar.bz2 rtmux-52793e7a3fc7f53b173ee887c221ff4ed38499e8.zip |
When creating a new session from the command-line where there is an external
terminal, copy the termios(4) special characters and use them for new windows
created in the new session. Suggested by Theo.
Diffstat (limited to 'cmd-new-session.c')
-rw-r--r-- | cmd-new-session.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c index 61f18c8f..5dc27879 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -18,6 +18,12 @@ #include <sys/types.h> +#include <string.h> +#include <termios.h> + +#define TTYDEFCHARS +#include <sys/ttydefaults.h> + #include "tmux.h" /* @@ -109,6 +115,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) struct cmd_new_session_data *data = self->data; struct session *s; struct environ env; + struct termios tio; const char *update; char *overrides, *cmd, *cwd, *cause; int detached; @@ -192,8 +199,24 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx) if (ctx->cmdclient != NULL) environ_update(update, &ctx->cmdclient->environ, &env); + /* + * Fill in the termios settings used for new windows in this session; + * if there is a command client, use the control characters from it. + */ + if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) { + if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0) + fatal("tcgetattr failed"); + } else + memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc); + tio.c_iflag = TTYDEF_IFLAG; + tio.c_oflag = TTYDEF_OFLAG; + tio.c_lflag = TTYDEF_LFLAG; + tio.c_cflag = TTYDEF_CFLAG; + tio.c_ispeed = TTYDEF_SPEED; + tio.c_ospeed = TTYDEF_SPEED; + /* Create the new session. */ - s = session_create(data->newname, cmd, cwd, &env, sx, sy, &cause); + s = session_create(data->newname, cmd, cwd, &env, &tio, sx, sy, &cause); if (s == NULL) { ctx->error(ctx, "create session failed: %s", cause); xfree(cause); |