From 7e3cc5fd121ff54fbe3e1b9d531cfba63bcf9768 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 13 Nov 2007 09:53:47 +0000 Subject: [PATCH] Use ctx->client/ctx->session inline instead of temporary variables which were being reused and causing confusion and problems. --- cmd-attach-session.c | 14 ++++++-------- cmd-bind-key.c | 5 ++--- cmd-detach-session.c | 15 +++++++-------- cmd-has-session.c | 6 ++---- cmd-kill-session.c | 7 +++---- cmd-kill-window.c | 16 ++++++++-------- cmd-last-window.c | 11 ++++------- cmd-link-window.c | 5 ++--- cmd-list-keys.c | 5 ++--- cmd-list-sessions.c | 11 +++++------ cmd-list-windows.c | 12 +++++------- cmd-new-session.c | 7 ++++--- cmd-new-window.c | 15 +++++++-------- cmd-next-window.c | 11 ++++------- cmd-previous-window.c | 11 ++++------- cmd-refresh-session.c | 15 +++++++-------- cmd-rename-session.c | 10 ++++------ cmd-rename-window.c | 13 ++++++------- cmd-select-window.c | 10 ++++------ cmd-send-prefix.c | 13 ++++++------- cmd-set-option.c | 6 +++--- cmd-swap-window.c | 5 ++--- cmd-unbind-key.c | 5 ++--- cmd-unlink-window.c | 16 ++++++++-------- 24 files changed, 107 insertions(+), 137 deletions(-) diff --git a/cmd-attach-session.c b/cmd-attach-session.c index b133df35..5f6aafc7 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.7 2007-10-19 09:21:25 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.8 2007-11-13 09:53:46 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -83,24 +83,22 @@ void cmd_attach_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_attach_session_data *data = ptr; - struct client *c = ctx->client; - struct session *s = ctx->session; if (ctx->flags & CMD_KEY) return; - if (!(c->flags & CLIENT_TERMINAL)) { + if (!(ctx->client->flags & CLIENT_TERMINAL)) { ctx->error(ctx, "not a terminal"); return; } if (data->flag_detach) - server_write_session(s, MSG_DETACH, NULL, 0); - c->session = s; + server_write_session(ctx->session, MSG_DETACH, NULL, 0); + ctx->client->session = ctx->session; - server_write_client(c, MSG_READY, NULL, 0); + server_write_client(ctx->client, MSG_READY, NULL, 0); recalculate_sizes(); - server_redraw_client(c); + server_redraw_client(ctx->client); } void diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 1fdbde4c..fff9a766 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.5 2007-10-19 09:21:25 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.6 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -92,7 +92,6 @@ void cmd_bind_key_exec(void *ptr, unused struct cmd_ctx *ctx) { struct cmd_bind_key_data *data = ptr; - struct client *c = ctx->client; if (data == NULL) return; @@ -101,7 +100,7 @@ cmd_bind_key_exec(void *ptr, unused struct cmd_ctx *ctx) data->cmd = NULL; /* avoid free */ if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-detach-session.c b/cmd-detach-session.c index bc5c198a..6c8be72c 100644 --- a/cmd-detach-session.c +++ b/cmd-detach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-detach-session.c,v 1.6 2007-10-19 09:21:25 nicm Exp $ */ +/* $Id: cmd-detach-session.c,v 1.7 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -84,8 +84,7 @@ void cmd_detach_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_detach_session_data *data = ptr, std = { 0 }; - struct client *c = ctx->client, *cp; - struct session *s = ctx->session; + struct client *c; u_int i; if (data == NULL) @@ -93,16 +92,16 @@ cmd_detach_session_exec(void *ptr, struct cmd_ctx *ctx) if (data->flag_all) { for (i = 0; i < ARRAY_LENGTH(&clients); i++) { - cp = ARRAY_ITEM(&clients, i); - if (cp == NULL || cp->session != s) + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session != ctx->session) continue; - server_write_client(cp, MSG_DETACH, NULL, 0); + server_write_client(c, MSG_DETACH, NULL, 0); } } else if (ctx->flags & CMD_KEY) - server_write_client(c, MSG_DETACH, NULL, 0); + server_write_client(ctx->client, MSG_DETACH, NULL, 0); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-has-session.c b/cmd-has-session.c index 3369ccc4..692e460a 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-has-session.c,v 1.1 2007-10-25 17:44:24 nicm Exp $ */ +/* $Id: cmd-has-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -44,8 +44,6 @@ const struct cmd_entry cmd_has_session_entry = { void cmd_has_session_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-kill-session.c b/cmd-kill-session.c index 45479624..40d2e902 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-session.c,v 1.1 2007-11-12 14:21:40 nicm Exp $ */ +/* $Id: cmd-kill-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -46,18 +46,17 @@ void cmd_kill_session_exec(unused void *ptr, struct cmd_ctx *ctx) { struct client *c; - struct session *s = ctx->session; u_int i; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c->session == s) { + if (c->session == ctx->session) { c->session = NULL; server_write_client(c, MSG_EXIT, NULL, 0); } } - session_destroy(s); + session_destroy(ctx->session); if (!(ctx->flags & CMD_KEY)) server_write_client(ctx->client, MSG_EXIT, NULL, 0); diff --git a/cmd-kill-window.c b/cmd-kill-window.c index 5c6b6d57..20272526 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-window.c,v 1.4 2007-10-30 10:59:43 nicm Exp $ */ +/* $Id: cmd-kill-window.c,v 1.5 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -90,8 +90,8 @@ void cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_kill_window_data *data = ptr, std = { -1 }; - struct client *c = ctx->client; - struct session *s = ctx->session; + struct client *c; + struct winlinks *wwl = &ctx->session->windows; struct winlink *wl; u_int i; int destroyed; @@ -100,16 +100,16 @@ cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx) data = &std; if (data->idx == -1) - wl = s->curw; - else if ((wl = winlink_find_by_index(&s->windows, data->idx)) == NULL) { + wl = ctx->session->curw; + else if ((wl = winlink_find_by_index(wwl, data->idx)) == NULL) { ctx->error(ctx, "no window %d", data->idx); return; } - destroyed = session_detach(s, wl); + destroyed = session_detach(ctx->session, wl); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->session != s) + if (c == NULL || c->session != ctx->session) continue; if (destroyed) { c->session = NULL; @@ -119,7 +119,7 @@ cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx) } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-last-window.c b/cmd-last-window.c index 4823b46b..dd3ff6d1 100644 --- a/cmd-last-window.c +++ b/cmd-last-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-last-window.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */ +/* $Id: cmd-last-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,14 +42,11 @@ const struct cmd_entry cmd_last_window_entry = { void cmd_last_window_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - struct session *s = ctx->session; - - if (session_last(s) == 0) - server_redraw_session(s); + if (session_last(ctx->session) == 0) + server_redraw_session(ctx->session); else ctx->error(ctx, "no last window"); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-link-window.c b/cmd-link-window.c index 4295232d..093c4568 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.4 2007-10-30 10:59:43 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.5 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -106,7 +106,6 @@ void cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_link_window_data *data = ptr; - struct client *c = ctx->client; struct session *dst = ctx->session, *src; struct winlink *wl; @@ -144,7 +143,7 @@ cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx) server_status_session(dst); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-list-keys.c b/cmd-list-keys.c index ff750438..c4cc6180 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-keys.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */ +/* $Id: cmd-list-keys.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,7 +42,6 @@ const struct cmd_entry cmd_list_keys_entry = { void cmd_list_keys_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; struct binding *bd; const char *key; u_int i; @@ -55,5 +54,5 @@ cmd_list_keys_exec(unused void *ptr, struct cmd_ctx *ctx) } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index 6bacdde2..4fc102cf 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-sessions.c,v 1.7 2007-10-26 12:29:07 nicm Exp $ */ +/* $Id: cmd-list-sessions.c,v 1.8 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -43,8 +43,7 @@ const struct cmd_entry cmd_list_sessions_entry = { void cmd_list_sessions_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - struct session *s = ctx->session; + struct session *s; struct winlink *wl; char *tim; u_int i, n; @@ -60,10 +59,10 @@ cmd_list_sessions_exec(unused void *ptr, struct cmd_ctx *ctx) tim = ctime(&s->tim); *strchr(tim, '\n') = '\0'; - ctx->print(ctx, "%s: %u windows (created %s) [%ux%u]", s->name, - n, tim, s->sx, s->sy); + ctx->print(ctx, "%s: %u windows" + " (created %s) [%ux%u]", s->name, n, tim, s->sx, s->sy); } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-list-windows.c b/cmd-list-windows.c index 7fd3ccec..ab80d3b3 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-windows.c,v 1.6 2007-10-31 14:26:26 nicm Exp $ */ +/* $Id: cmd-list-windows.c,v 1.7 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,18 +42,16 @@ const struct cmd_entry cmd_list_windows_entry = { void cmd_list_windows_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - struct session *s = ctx->session; struct winlink *wl; struct window *w; - RB_FOREACH(wl, winlinks, &s->windows) { + RB_FOREACH(wl, winlinks, &ctx->session->windows) { w = wl->window; - ctx->print(ctx, "%d: %s \"%s\" (%s) [%ux%u]", wl->idx, - w->name, w->screen.title, ttyname(w->fd), + ctx->print(ctx, "%d: %s \"%s\" (%s) [%ux%u]", + wl->idx, w->name, w->screen.title, ttyname(w->fd), w->screen.sx, w->screen.sy); } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-new-session.c b/cmd-new-session.c index 859ca35e..4122e539 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.15 2007-11-09 16:04:29 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.16 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -100,7 +100,7 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_new_session_data *data = ptr; struct cmd_new_session_data std = { NULL, NULL, NULL, 0 }; - struct client *c = ctx->client; + struct client *c; char *cmd; u_int sy; @@ -110,6 +110,7 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) if (ctx->flags & CMD_KEY) return; + c = ctx->client; if (!data->flag_detached && !(c->flags & CLIENT_TERMINAL)) { ctx->error(ctx, "not a terminal"); return; @@ -128,7 +129,7 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) cmd = data->cmd; if (cmd == NULL) cmd = default_command; - + c->session = session_create(data->name, cmd, c->sx, sy); if (c->session == NULL) fatalx("session_create failed"); diff --git a/cmd-new-window.c b/cmd-new-window.c index 094d877e..ebb434c9 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-window.c,v 1.11 2007-10-26 16:57:32 nicm Exp $ */ +/* $Id: cmd-new-window.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -106,8 +106,6 @@ cmd_new_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_new_window_data *data = ptr; struct cmd_new_window_data std = { NULL, NULL, -1, 0 }; - struct client *c = ctx->client; - struct session *s = ctx->session; struct winlink *wl; char *cmd; @@ -120,18 +118,19 @@ cmd_new_window_exec(void *ptr, struct cmd_ctx *ctx) if (data->idx < 0) data->idx = -1; - if ((wl = session_new(s, data->name, cmd, data->idx)) == NULL) { + wl = session_new(ctx->session, data->name, cmd, data->idx); + if (wl == NULL) { ctx->error(ctx, "command failed: %s", cmd); return; } if (!data->flag_detached) { - session_select(s, wl->idx); - server_redraw_session(s); + session_select(ctx->session, wl->idx); + server_redraw_session(ctx->session); } else - server_status_session(s); + server_status_session(ctx->session); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-next-window.c b/cmd-next-window.c index 3c398500..773f2b36 100644 --- a/cmd-next-window.c +++ b/cmd-next-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-next-window.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */ +/* $Id: cmd-next-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,14 +42,11 @@ const struct cmd_entry cmd_next_window_entry = { void cmd_next_window_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - struct session *s = ctx->session; - - if (session_next(s) == 0) - server_redraw_session(s); + if (session_next(ctx->session) == 0) + server_redraw_session(ctx->session); else ctx->error(ctx, "no next window"); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-previous-window.c b/cmd-previous-window.c index 1c2412b4..640cddf7 100644 --- a/cmd-previous-window.c +++ b/cmd-previous-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-previous-window.c,v 1.3 2007-10-04 22:04:01 nicm Exp $ */ +/* $Id: cmd-previous-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,14 +42,11 @@ const struct cmd_entry cmd_previous_window_entry = { void cmd_previous_window_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; - struct session *s = ctx->session; - - if (session_previous(s) == 0) - server_redraw_session(s); + if (session_previous(ctx->session) == 0) + server_redraw_session(ctx->session); else ctx->error(ctx, "no previous window"); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-refresh-session.c b/cmd-refresh-session.c index 37dea4e5..5853ee54 100644 --- a/cmd-refresh-session.c +++ b/cmd-refresh-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-refresh-session.c,v 1.1 2007-10-19 09:21:25 nicm Exp $ */ +/* $Id: cmd-refresh-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -84,8 +84,7 @@ void cmd_refresh_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_refresh_session_data *data = ptr, std = { 0 }; - struct client *c = ctx->client, *cp; - struct session *s = ctx->session; + struct client *c; u_int i; if (data == NULL) @@ -93,16 +92,16 @@ cmd_refresh_session_exec(void *ptr, struct cmd_ctx *ctx) if (data->flag_all) { for (i = 0; i < ARRAY_LENGTH(&clients); i++) { - cp = ARRAY_ITEM(&clients, i); - if (cp == NULL || cp->session != s) + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session != ctx->session) continue; - server_redraw_client(cp); + server_redraw_client(c); } } else if (ctx->flags & CMD_KEY) - server_redraw_client(c); + server_redraw_client(ctx->client); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-rename-session.c b/cmd-rename-session.c index 9c44398a..a5601d5b 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-session.c,v 1.1 2007-11-09 11:02:01 nicm Exp $ */ +/* $Id: cmd-rename-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -83,17 +83,15 @@ void cmd_rename_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_rename_session_data *data = ptr; - struct client *c = ctx->client; - struct session *s = ctx->session; if (data == NULL) return; - xfree(s->name); - s->name = xstrdup(data->newname); + xfree(ctx->session->name); + ctx->session->name = xstrdup(data->newname); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-rename-window.c b/cmd-rename-window.c index 3691f68f..8ee986ed 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-window.c,v 1.11 2007-11-09 11:02:01 nicm Exp $ */ +/* $Id: cmd-rename-window.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -94,26 +94,25 @@ void cmd_rename_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_rename_window_data *data = ptr; - struct client *c = ctx->client; - struct session *s = ctx->session; + struct winlinks *wwl = &ctx->session->windows; struct winlink *wl; if (data == NULL) return; if (data->idx == -1) - wl = s->curw; - else if ((wl = winlink_find_by_index(&s->windows, data->idx)) == NULL) { + wl = ctx->session->curw; + else if ((wl = winlink_find_by_index(wwl, data->idx)) == NULL) { ctx->error(ctx, "no window %d", data->idx); return; } xfree(wl->window->name); wl->window->name = xstrdup(data->newname); - server_status_session(s); + server_status_session(ctx->session); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-select-window.c b/cmd-select-window.c index d393f868..11af68e9 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-window.c,v 1.8 2007-11-09 16:04:29 nicm Exp $ */ +/* $Id: cmd-select-window.c,v 1.9 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -102,15 +102,13 @@ void cmd_select_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_select_window_data *data = ptr; - struct client *c = ctx->client; - struct session *s = ctx->session; if (data == NULL) return; - switch (session_select(s, data->idx)) { + switch (session_select(ctx->session, data->idx)) { case 0: - server_redraw_session(s); + server_redraw_session(ctx->session); break; case 1: break; @@ -120,7 +118,7 @@ cmd_select_window_exec(void *ptr, struct cmd_ctx *ctx) } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-send-prefix.c b/cmd-send-prefix.c index 62e3b4bc..af426c78 100644 --- a/cmd-send-prefix.c +++ b/cmd-send-prefix.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-prefix.c,v 1.3 2007-10-26 12:29:07 nicm Exp $ */ +/* $Id: cmd-send-prefix.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -42,12 +42,11 @@ const struct cmd_entry cmd_send_prefix_entry = { void cmd_send_prefix_exec(unused void *ptr, struct cmd_ctx *ctx) { - struct client *c = ctx->client; + struct window *w = ctx->client->session->curw->window; - if (!(ctx->flags & CMD_KEY)) { - server_write_client(c, MSG_EXIT, NULL, 0); - return; - } + if (ctx->flags & CMD_KEY) + input_translate_key(w->out, prefix_key); - input_translate_key(c->session->curw->window->out, prefix_key); + if (!(ctx->flags & CMD_KEY)) + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } diff --git a/cmd-set-option.c b/cmd-set-option.c index dff7361d..4e0c7c44 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.11 2007-10-30 10:59:43 nicm Exp $ */ +/* $Id: cmd-set-option.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -88,7 +88,7 @@ void cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx) { struct cmd_set_option_data *data = ptr; - struct client *c = ctx->client; + struct client *c; const char *errstr; u_int i; int number, bool, key; @@ -199,7 +199,7 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx) } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-swap-window.c b/cmd-swap-window.c index e515f2ea..4a02622d 100644 --- a/cmd-swap-window.c +++ b/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-window.c,v 1.1 2007-10-30 11:10:33 nicm Exp $ */ +/* $Id: cmd-swap-window.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -106,7 +106,6 @@ void cmd_swap_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_swap_window_data *data = ptr; - struct client *c = ctx->client; struct session *dst = ctx->session, *src; struct winlink *srcwl, *dstwl; struct window *w; @@ -157,7 +156,7 @@ cmd_swap_window_exec(void *ptr, struct cmd_ctx *ctx) server_redraw_session(dst); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 6307d5c9..b7b53c6d 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unbind-key.c,v 1.5 2007-10-19 09:21:26 nicm Exp $ */ +/* $Id: cmd-unbind-key.c,v 1.6 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -85,7 +85,6 @@ void cmd_unbind_key_exec(void *ptr, unused struct cmd_ctx *ctx) { struct cmd_unbind_key_data *data = ptr; - struct client *c = ctx->client; if (data == NULL) return; @@ -93,7 +92,7 @@ cmd_unbind_key_exec(void *ptr, unused struct cmd_ctx *ctx) key_bindings_remove(data->key); if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void diff --git a/cmd-unlink-window.c b/cmd-unlink-window.c index be3b6f58..948d07c9 100644 --- a/cmd-unlink-window.c +++ b/cmd-unlink-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unlink-window.c,v 1.2 2007-10-30 10:59:43 nicm Exp $ */ +/* $Id: cmd-unlink-window.c,v 1.3 2007-11-13 09:53:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -90,8 +90,8 @@ void cmd_unlink_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_unlink_window_data *data = ptr; - struct client *c = ctx->client; - struct session *s = ctx->session; + struct client *c; + struct winlinks *wwl = &ctx->session->windows; struct winlink *wl; u_int i; int destroyed; @@ -102,9 +102,9 @@ cmd_unlink_window_exec(void *ptr, struct cmd_ctx *ctx) if (data->idx < 0) data->idx = -1; if (data->idx == -1) - wl = s->curw; + wl = ctx->session->curw; else { - wl = winlink_find_by_index(&s->windows, data->idx); + wl = winlink_find_by_index(wwl, data->idx); if (wl == NULL) { ctx->error(ctx, "no window %d", data->idx); return; @@ -116,10 +116,10 @@ cmd_unlink_window_exec(void *ptr, struct cmd_ctx *ctx) return; } - destroyed = session_detach(s, wl); + destroyed = session_detach(ctx->session, wl); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->session != s) + if (c == NULL || c->session != ctx->session) continue; if (destroyed) { c->session = NULL; @@ -129,7 +129,7 @@ cmd_unlink_window_exec(void *ptr, struct cmd_ctx *ctx) } if (!(ctx->flags & CMD_KEY)) - server_write_client(c, MSG_EXIT, NULL, 0); + server_write_client(ctx->client, MSG_EXIT, NULL, 0); } void