summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-09-18 15:19:28 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-09-18 15:19:28 +0000
commit14a84afcd7212af580892db4e645f291fca3764f (patch)
tree78a9ac54759939420d91d5a15ff661fc75db289c /usr.bin
parent0e3213ed97e73884bec54c41d4061078ce22ad4d (diff)
New option, set-titles-string, to allow the window title to be specified (as
for status-left/right) if set-titles is on. Also only update the title when the status line is being redrawn.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-set-option.c3
-rw-r--r--usr.bin/tmux/server.c39
-rw-r--r--usr.bin/tmux/tmux.111
-rw-r--r--usr.bin/tmux/tmux.c3
4 files changed, 38 insertions, 18 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index f7185a40ee0..6d57ba36d72 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-option.c,v 1.17 2009/09/01 13:09:49 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.18 2009/09/18 15:19:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -69,6 +69,7 @@ const struct set_option_entry set_option_table[] = {
{ "repeat-time", SET_OPTION_NUMBER, 0, SHRT_MAX, NULL },
{ "set-remain-on-exit", SET_OPTION_FLAG, 0, 0, NULL },
{ "set-titles", SET_OPTION_FLAG, 0, 0, NULL },
+ { "set-titles-string", SET_OPTION_STRING, 0, 0, NULL },
{ "status", SET_OPTION_FLAG, 0, 0, NULL },
{ "status-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
{ "status-bg", SET_OPTION_COLOUR, 0, 0, NULL },
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index b21fa1ed8cd..46bc2442ea6 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.37 2009/09/15 07:45:16 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.38 2009/09/18 15:19:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -66,6 +66,7 @@ void server_clean_dead(void);
void server_lost_client(struct client *);
void server_check_window(struct window *);
void server_check_redraw(struct client *);
+void server_set_title(struct client *);
void server_redraw_locked(struct client *);
void server_check_timers(struct client *);
void server_second_timers(void);
@@ -516,7 +517,6 @@ server_check_redraw(struct client *c)
{
struct session *s;
struct window_pane *wp;
- char title[512];
int flags, redraw;
if (c == NULL || c->session == NULL)
@@ -526,19 +526,10 @@ server_check_redraw(struct client *c)
flags = c->tty.flags & TTY_FREEZE;
c->tty.flags &= ~TTY_FREEZE;
- if (options_get_number(&s->options, "set-titles")) {
- xsnprintf(title, sizeof title, "%s:%u:%s - \"%s\"",
- s->name, s->curw->idx, s->curw->window->name,
- s->curw->window->active->screen->title);
- if (c->title == NULL || strcmp(title, c->title) != 0) {
- if (c->title != NULL)
- xfree(c->title);
- c->title = xstrdup(title);
- tty_set_title(&c->tty, c->title);
- }
- }
-
if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
+ if (options_get_number(&s->options, "set-titles"))
+ server_set_title(c);
+
if (c->message_string != NULL)
redraw = status_message_redraw(c);
else if (c->prompt_string != NULL)
@@ -570,6 +561,26 @@ server_check_redraw(struct client *c)
c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS);
}
+/* Set client title. */
+void
+server_set_title(struct client *c)
+{
+ struct session *s = c->session;
+ const char *template;
+ char *title;
+
+ template = options_get_string(&s->options, "set-titles-string");
+
+ title = status_replace(c->session, template, time(NULL));
+ if (c->title == NULL || strcmp(title, c->title) != 0) {
+ if (c->title != NULL)
+ xfree(c->title);
+ c->title = xstrdup(title);
+ tty_set_title(&c->tty, c->title);
+ }
+ xfree(title);
+}
+
/* Redraw client when locked. */
void
server_redraw_locked(struct client *c)
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 3ad8712a880..fc219a3765b 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.85 2009/09/10 17:16:24 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.86 2009/09/18 15:19:27 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: September 10 2009 $
+.Dd $Mdocdate: September 18 2009 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -1287,6 +1287,13 @@ This option is off by default.
Note that elinks
will only attempt to set the window title if the STY environment
variable is set.
+.It Ic set-titles-string Ar string
+String used to set the window title if
+.Ic set-titles
+is on.
+Character sequences are replaced as for the
+.Ic status-left
+option.
.It Xo Ic status
.Op Ic on | off
.Xc
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 05a06b826a9..c42d8c8cc8b 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.42 2009/09/04 15:15:24 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.43 2009/09/18 15:19:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -413,6 +413,7 @@ main(int argc, char **argv)
options_set_number(so, "repeat-time", 500);
options_set_number(so, "set-remain-on-exit", 0);
options_set_number(so, "set-titles", 0);
+ options_set_string(so, "set-titles-string", "#S:#I:#W - \"#T\"");
options_set_number(so, "status", 1);
options_set_number(so, "status-attr", 0);
options_set_number(so, "status-bg", 2);