=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server.c,v retrieving revision 1.37 retrieving revision 1.38 diff -c -r1.37 -r1.38 *** src/usr.bin/tmux/server.c 2009/09/15 07:45:16 1.37 --- src/usr.bin/tmux/server.c 2009/09/18 15:19:27 1.38 *************** *** 1,4 **** ! /* $OpenBSD: server.c,v 1.37 2009/09/15 07:45:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server.c,v 1.38 2009/09/18 15:19:27 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 66,71 **** --- 66,72 ---- 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,522 **** { struct session *s; struct window_pane *wp; - char title[512]; int flags, redraw; if (c == NULL || c->session == NULL) --- 517,522 ---- *************** *** 526,544 **** 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 (c->message_string != NULL) redraw = status_message_redraw(c); else if (c->prompt_string != NULL) --- 526,535 ---- flags = c->tty.flags & TTY_FREEZE; c->tty.flags &= ~TTY_FREEZE; 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) *************** *** 568,573 **** --- 559,584 ---- c->tty.flags |= flags; 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. */