aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-09-19 18:53:01 +0000
committerTiago Cunha <tcunha@gmx.com>2009-09-19 18:53:01 +0000
commit23d7ed3187512ad53984051069a70eca4fb99edb (patch)
treea3b667ce8643345061b3437911379365dac43ef7 /server.c
parenta2e03ce3cbc91bc0a56bfd5828da08327f489681 (diff)
downloadrtmux-23d7ed3187512ad53984051069a70eca4fb99edb.tar.gz
rtmux-23d7ed3187512ad53984051069a70eca4fb99edb.tar.bz2
rtmux-23d7ed3187512ad53984051069a70eca4fb99edb.zip
Sync OpenBSD patchset 331:
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 'server.c')
-rw-r--r--server.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/server.c b/server.c
index cba9601c..9101ac31 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.188 2009-09-15 23:52:30 tcunha Exp $ */
+/* $Id: server.c,v 1.189 2009-09-19 18:53:01 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -65,6 +65,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);
@@ -519,7 +520,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)
@@ -529,19 +529,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)
@@ -573,6 +564,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)