summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-new-session.c27
-rw-r--r--usr.bin/tmux/cmd-respawn-window.c4
-rw-r--r--usr.bin/tmux/cmd-split-window.c4
-rw-r--r--usr.bin/tmux/session.c10
-rw-r--r--usr.bin/tmux/tmux.18
-rw-r--r--usr.bin/tmux/tmux.h15
-rw-r--r--usr.bin/tmux/window.c13
7 files changed, 57 insertions, 24 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c
index b2ecc6767e5..c18905f55af 100644
--- a/usr.bin/tmux/cmd-new-session.c
+++ b/usr.bin/tmux/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-new-session.c,v 1.10 2009/08/08 21:52:43 nicm Exp $ */
+/* $OpenBSD: cmd-new-session.c,v 1.11 2009/08/13 19:03:59 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
diff --git a/usr.bin/tmux/cmd-respawn-window.c b/usr.bin/tmux/cmd-respawn-window.c
index 71d82cc63d4..2ef024faf34 100644
--- a/usr.bin/tmux/cmd-respawn-window.c
+++ b/usr.bin/tmux/cmd-respawn-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-respawn-window.c,v 1.6 2009/08/08 21:52:43 nicm Exp $ */
+/* $OpenBSD: cmd-respawn-window.c,v 1.7 2009/08/13 19:04:00 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -75,7 +75,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
window_destroy_panes(w);
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
window_pane_resize(wp, w->sx, w->sy);
- if (window_pane_spawn(wp, data->arg, NULL, &env, &cause) != 0) {
+ if (window_pane_spawn(wp, data->arg, NULL, &env, &s->tio, &cause) != 0) {
ctx->error(ctx, "respawn window failed: %s", cause);
xfree(cause);
environ_free(&env);
diff --git a/usr.bin/tmux/cmd-split-window.c b/usr.bin/tmux/cmd-split-window.c
index 4907af86deb..1bc2d907bb5 100644
--- a/usr.bin/tmux/cmd-split-window.c
+++ b/usr.bin/tmux/cmd-split-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-split-window.c,v 1.8 2009/08/08 21:52:43 nicm Exp $ */
+/* $OpenBSD: cmd-split-window.c,v 1.9 2009/08/13 19:04:00 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -184,7 +184,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
type = LAYOUT_LEFTRIGHT;
wp = window_add_pane(w, hlimit);
- if (window_pane_spawn(wp, cmd, cwd, &env, &cause) != 0)
+ if (window_pane_spawn(wp, cmd, cwd, &env, &s->tio, &cause) != 0)
goto error;
if (layout_split_pane(w->active, type, size, wp) != 0) {
cause = xstrdup("pane too small");
diff --git a/usr.bin/tmux/session.c b/usr.bin/tmux/session.c
index 7691c29a2b1..af7ea96e047 100644
--- a/usr.bin/tmux/session.c
+++ b/usr.bin/tmux/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.3 2009/08/08 21:52:43 nicm Exp $ */
+/* $OpenBSD: session.c,v 1.4 2009/08/13 19:04:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -113,7 +113,7 @@ session_find(const char *name)
/* Create a new session. */
struct session *
session_create(const char *name, const char *cmd, const char *cwd,
- struct environ *env, u_int sx, u_int sy, char **cause)
+ struct environ *env, struct termios *tio, u_int sx, u_int sy, char **cause)
{
struct session *s;
u_int i;
@@ -131,6 +131,7 @@ session_create(const char *name, const char *cmd, const char *cwd,
environ_init(&s->environ);
if (env != NULL)
environ_copy(env, &s->environ);
+ memcpy(&s->tio, tio, sizeof s->tio);
s->sx = sx;
s->sy = sy;
@@ -200,7 +201,7 @@ session_index(struct session *s, u_int *i)
/* Create a new window on a session. */
struct winlink *
-session_new(struct session *s,
+session_new(struct session *s,
const char *name, const char *cmd, const char *cwd, int idx, char **cause)
{
struct window *w;
@@ -213,7 +214,8 @@ session_new(struct session *s,
server_fill_environ(s, &env);
hlimit = options_get_number(&s->options, "history-limit");
- w = window_create(name, cmd, cwd, &env, s->sx, s->sy, hlimit, cause);
+ w = window_create(
+ name, cmd, cwd, &env, &s->tio, s->sx, s->sy, hlimit, cause);
if (w == NULL) {
environ_free(&env);
return (NULL);
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 11afbd4ae03..d1fe7ebcb1d 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.67 2009/08/10 17:14:55 jmc Exp $
+.\" $OpenBSD: tmux.1,v 1.68 2009/08/13 19:04:00 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 10 2009 $
+.Dd $Mdocdate: August 13 2009 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -398,6 +398,10 @@ is given.
and
.Ar command
are the name of and command to execute in the initial window.
+.Pp
+If run from a terminal, any
+.Xr termios 4
+special characters are saved and used for new windows in the new session.
.It Ic refresh-client Op Fl t Ar target-client
.D1 (alias: Ic refresh )
Refresh the current client if bound to a key, or a single client if one is given
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index d2f2652f100..f99fa73e94c 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.79 2009/08/12 09:41:59 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.80 2009/08/13 19:04:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -803,6 +803,8 @@ struct session {
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags;
+ struct termios tio;
+
struct environ environ;
};
ARRAY_DECL(sessions, struct session *);
@@ -1574,7 +1576,8 @@ void winlink_stack_remove(struct winlink_stack *, struct winlink *);
int window_index(struct window *, u_int *);
struct window *window_create1(u_int, u_int);
struct window *window_create(const char *, const char *, const char *,
- struct environ *, u_int, u_int, u_int, char **);
+ struct environ *, struct termios *, u_int, u_int, u_int,
+ char **);
void window_destroy(struct window *);
void window_set_active_pane(struct window *, struct window_pane *);
struct window_pane *window_add_pane(struct window *, u_int);
@@ -1586,8 +1589,8 @@ u_int window_count_panes(struct window *);
void window_destroy_panes(struct window *);
struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
void window_pane_destroy(struct window_pane *);
-int window_pane_spawn(struct window_pane *,
- const char *, const char *, struct environ *, char **);
+int window_pane_spawn(struct window_pane *, const char *,
+ const char *, struct environ *, struct termios *, char **);
void window_pane_resize(struct window_pane *, u_int, u_int);
int window_pane_set_mode(
struct window_pane *, const struct window_mode *);
@@ -1666,8 +1669,8 @@ void session_alert_cancel(struct session *, struct winlink *);
int session_alert_has(struct session *, struct winlink *, int);
int session_alert_has_window(struct session *, struct window *, int);
struct session *session_find(const char *);
-struct session *session_create(const char *, const char *,
- const char *, struct environ *, u_int, u_int, char **);
+struct session *session_create(const char *, const char *, const char *,
+ struct environ *, struct termios *, u_int, u_int, char **);
void session_destroy(struct session *);
int session_index(struct session *, u_int *);
struct winlink *session_new(struct session *,
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 71e0622428e..d163dbb0c4b 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.20 2009/08/12 09:14:25 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.21 2009/08/13 19:04:00 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -269,7 +269,8 @@ window_create1(u_int sx, u_int sy)
struct window *
window_create(const char *name, const char *cmd, const char *cwd,
- struct environ *env, u_int sx, u_int sy, u_int hlimit, char **cause)
+ struct environ *env, struct termios *tio, u_int sx, u_int sy, u_int hlimit,
+ char **cause)
{
struct window *w;
struct window_pane *wp;
@@ -277,7 +278,7 @@ window_create(const char *name, const char *cmd, const char *cwd,
w = window_create1(sx, sy);
wp = window_add_pane(w, hlimit);
layout_init(w);
- if (window_pane_spawn(wp, cmd, cwd, env, cause) != 0) {
+ if (window_pane_spawn(wp, cmd, cwd, env, tio, cause) != 0) {
window_destroy(w);
return (NULL);
}
@@ -470,8 +471,8 @@ window_pane_destroy(struct window_pane *wp)
}
int
-window_pane_spawn(struct window_pane *wp,
- const char *cmd, const char *cwd, struct environ *env, char **cause)
+window_pane_spawn(struct window_pane *wp, const char *cmd,
+ const char *cwd, struct environ *env, struct termios *tio, char **cause)
{
struct winsize ws;
int mode;
@@ -505,7 +506,7 @@ window_pane_spawn(struct window_pane *wp,
tv.tv_usec = NAME_INTERVAL * 1000L;
timeradd(&wp->window->name_timer, &tv, &wp->window->name_timer);
- switch (wp->pid = forkpty(&wp->fd, wp->tty, NULL, &ws)) {
+ switch (wp->pid = forkpty(&wp->fd, wp->tty, tio, &ws)) {
case -1:
wp->fd = -1;
xasprintf(cause, "%s: %s", cmd, strerror(errno));