version 1.18, 2009/09/15 07:45:16 |
version 1.19, 2009/09/16 12:35:04 |
|
|
#include <string.h> |
#include <string.h> |
#include <termios.h> |
#include <termios.h> |
|
|
#define TTYDEFCHARS |
|
#include <sys/ttydefaults.h> |
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
/* |
/* |
|
|
struct session *s; |
struct session *s; |
struct window *w; |
struct window *w; |
struct environ env; |
struct environ env; |
struct termios tio; |
struct termios tio, *tiop; |
const char *update; |
const char *update; |
char *overrides, *cmd, *cwd, *cause; |
char *overrides, *cmd, *cwd, *cause; |
int detached, idx; |
int detached, idx; |
|
|
detached = 1; |
detached = 1; |
|
|
/* |
/* |
* Fill in the termios settings used for new windows in this session; |
* Save the termios settings, part of which is used for new windows in |
* if there is a command client, use the control characters from it. |
* this session. |
* |
* |
* This is read again with tcgetattr() rather than using tty.tio as if |
* This is read again with tcgetattr() rather than using tty.tio as if |
* detached, tty_open won't be called. Because of this, it must be done |
* detached, tty_open won't be called. Because of this, it must be done |
|
|
if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) { |
if (ctx->cmdclient != NULL && ctx->cmdclient->tty.fd != -1) { |
if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0) |
if (tcgetattr(ctx->cmdclient->tty.fd, &tio) != 0) |
fatal("tcgetattr failed"); |
fatal("tcgetattr failed"); |
|
tiop = &tio; |
} else |
} else |
memcpy(tio.c_cc, ttydefchars, sizeof tio.c_cc); |
tiop = NULL; |
tio.c_cc[VERASE] = '\177'; |
|
tio.c_iflag = TTYDEF_IFLAG; |
|
tio.c_oflag = TTYDEF_OFLAG; |
|
tio.c_lflag = TTYDEF_LFLAG; |
|
tio.c_cflag = TTYDEF_CFLAG; |
|
cfsetispeed(&tio, TTYDEF_SPEED); |
|
cfsetospeed(&tio, TTYDEF_SPEED); |
|
|
|
/* Open the terminal if necessary. */ |
/* Open the terminal if necessary. */ |
if (!detached && ctx->cmdclient != NULL) { |
if (!detached && ctx->cmdclient != NULL) { |
|
|
/* Create the new session. */ |
/* Create the new session. */ |
idx = -1 - options_get_number(&global_s_options, "base-index"); |
idx = -1 - options_get_number(&global_s_options, "base-index"); |
s = session_create( |
s = session_create( |
data->newname, cmd, cwd, &env, &tio, idx, sx, sy, &cause); |
data->newname, cmd, cwd, &env, tiop, idx, sx, sy, &cause); |
if (s == NULL) { |
if (s == NULL) { |
ctx->error(ctx, "create session failed: %s", cause); |
ctx->error(ctx, "create session failed: %s", cause); |
xfree(cause); |
xfree(cause); |