Move window name changes into wrapper function window_set_name, from

George Nachman.
This commit is contained in:
Nicholas Marriott 2012-02-02 00:10:11 +00:00
parent fdeaa73342
commit 8363d19307
6 changed files with 16 additions and 7 deletions

View File

@ -46,6 +46,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct window_pane *wp;
struct window *w;
char *name;
char *cause;
int base_idx;
@ -74,7 +75,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
w = wp->window = window_create1(s->sx, s->sy);
TAILQ_INSERT_HEAD(&w->panes, wp, entry);
w->active = wp;
w->name = default_window_name(w);
name = default_window_name(w);
window_set_name(w, name);
xfree(name);
layout_init(w);
base_idx = options_get_number(&s->options, "base-index");

View File

@ -217,8 +217,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (cmd != NULL && args_has(args, 'n')) {
w = s->curw->window;
xfree(w->name);
w->name = xstrdup(args_get(args, 'n'));
window_set_name(w, args_get(args, 'n'));
options_set_number(&w->options, "automatic-rename", 0);
}

View File

@ -48,8 +48,7 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
return (-1);
xfree(wl->window->name);
wl->window->name = xstrdup(args->argv[0]);
window_set_name(wl->window, args->argv[0]);
options_set_number(&wl->window->options, "automatic-rename", 0);
server_status_window(wl->window);

View File

@ -1552,8 +1552,7 @@ input_exit_rename(struct input_ctx *ictx)
return;
log_debug("%s: \"%s\"", __func__, ictx->input_buf);
xfree(ictx->wp->window->name);
ictx->wp->window->name = xstrdup(ictx->input_buf);
window_set_name(ictx->wp->window, ictx->input_buf);
options_set_number(&ictx->wp->window->options, "automatic-rename", 0);
server_status_window(ictx->wp->window);

1
tmux.h
View File

@ -1968,6 +1968,7 @@ struct window_pane *window_pane_find_up(struct window_pane *);
struct window_pane *window_pane_find_down(struct window_pane *);
struct window_pane *window_pane_find_left(struct window_pane *);
struct window_pane *window_pane_find_right(struct window_pane *);
void window_set_name(struct window *, const char *);
/* layout.c */
u_int layout_count_cells(struct layout_cell *);

View File

@ -361,6 +361,14 @@ window_destroy(struct window *w)
xfree(w);
}
void
window_set_name(struct window *w, const char *new_name)
{
if (w->name != NULL)
xfree(w->name);
w->name = xstrdup(new_name);
}
void
window_resize(struct window *w, u_int sx, u_int sy)
{