summaryrefslogtreecommitdiffstats
path: root/cmd-refresh-client.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-13 20:51:57 +0000
committernicm <nicm>2020-04-13 20:51:57 +0000
commit3f7f9a0e20522c73e33480673496240f1bac724b (patch)
treec0ec19a026014bfd6981622ecd9ee2783344ef25 /cmd-refresh-client.c
parent187277eaadc4a675659bf7ede88f50bfe6cc7be9 (diff)
Make client -c and -t handling common in cmd-queue.c and try to be
clearer about whether the client is the target client (must have a session) or not.
Diffstat (limited to 'cmd-refresh-client.c')
-rw-r--r--cmd-refresh-client.c71
1 files changed, 33 insertions, 38 deletions
diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c
index 1becaaae..5514ff73 100644
--- a/cmd-refresh-client.c
+++ b/cmd-refresh-client.c
@@ -38,7 +38,7 @@ const struct cmd_entry cmd_refresh_client_entry = {
.usage = "[-cDlLRSU] [-C XxY] [-F flags] " CMD_TARGET_CLIENT_USAGE
" [adjustment]",
- .flags = CMD_AFTERHOOK,
+ .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG,
.exec = cmd_refresh_client_exec
};
@@ -46,17 +46,13 @@ static enum cmd_retval
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
- struct client *c;
- struct tty *tty;
+ struct client *tc = cmdq_get_target_client(item);
+ struct tty *tty = &tc->tty;
struct window *w;
const char *size, *errstr;
char *copy, *next, *s;
u_int x, y, adjust;
- if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
- return (CMD_RETURN_ERROR);
- tty = &c->tty;
-
if (args_has(args, 'c') ||
args_has(args, 'L') ||
args_has(args, 'R') ||
@@ -74,48 +70,47 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(args, 'c'))
- c->pan_window = NULL;
+ tc->pan_window = NULL;
else {
- w = c->session->curw->window;
- if (c->pan_window != w) {
- c->pan_window = w;
- c->pan_ox = tty->oox;
- c->pan_oy = tty->ooy;
+ w = tc->session->curw->window;
+ if (tc->pan_window != w) {
+ tc->pan_window = w;
+ tc->pan_ox = tty->oox;
+ tc->pan_oy = tty->ooy;
}
if (args_has(args, 'L')) {
- if (c->pan_ox > adjust)
- c->pan_ox -= adjust;
+ if (tc->pan_ox > adjust)
+ tc->pan_ox -= adjust;
else
- c->pan_ox = 0;
+ tc->pan_ox = 0;
} else if (args_has(args, 'R')) {
- c->pan_ox += adjust;
- if (c->pan_ox > w->sx - tty->osx)
- c->pan_ox = w->sx - tty->osx;
+ tc->pan_ox += adjust;
+ if (tc->pan_ox > w->sx - tty->osx)
+ tc->pan_ox = w->sx - tty->osx;
} else if (args_has(args, 'U')) {
- if (c->pan_oy > adjust)
- c->pan_oy -= adjust;
+ if (tc->pan_oy > adjust)
+ tc->pan_oy -= adjust;
else
- c->pan_oy = 0;
+ tc->pan_oy = 0;
} else if (args_has(args, 'D')) {
- c->pan_oy += adjust;
- if (c->pan_oy > w->sy - tty->osy)
- c->pan_oy = w->sy - tty->osy;
+ tc->pan_oy += adjust;
+ if (tc->pan_oy > w->sy - tty->osy)
+ tc->pan_oy = w->sy - tty->osy;
}
}
- tty_update_client_offset(c);
- server_redraw_client(c);
+ tty_update_client_offset(tc);
+ server_redraw_client(tc);
return (CMD_RETURN_NORMAL);
}
if (args_has(args, 'l')) {
- if (c->session != NULL)
- tty_putcode_ptr2(&c->tty, TTYC_MS, "", "?");
+ tty_putcode_ptr2(&tc->tty, TTYC_MS, "", "?");
return (CMD_RETURN_NORMAL);
}
if (args_has(args, 'C') || args_has(args, 'F')) {
if (args_has(args, 'C')) {
- if (!(c->flags & CLIENT_CONTROL)) {
+ if (!(tc->flags & CLIENT_CONTROL)) {
cmdq_error(item, "not a control client");
return (CMD_RETURN_ERROR);
}
@@ -130,12 +125,12 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "size too small or too big");
return (CMD_RETURN_ERROR);
}
- tty_set_size(&c->tty, x, y, 0, 0);
- c->flags |= CLIENT_SIZECHANGED;
+ tty_set_size(&tc->tty, x, y, 0, 0);
+ tc->flags |= CLIENT_SIZECHANGED;
recalculate_sizes();
}
if (args_has(args, 'F')) {
- if (!(c->flags & CLIENT_CONTROL)) {
+ if (!(tc->flags & CLIENT_CONTROL)) {
cmdq_error(item, "not a control client");
return (CMD_RETURN_ERROR);
}
@@ -143,7 +138,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
while ((next = strsep(&s, ",")) != NULL) {
/* Unknown flags are ignored. */
if (strcmp(next, "no-output") == 0)
- c->flags |= CLIENT_CONTROL_NOOUTPUT;
+ tc->flags |= CLIENT_CONTROL_NOOUTPUT;
}
free(copy);
}
@@ -151,11 +146,11 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(args, 'S')) {
- c->flags |= CLIENT_STATUSFORCE;
- server_status_client(c);
+ tc->flags |= CLIENT_STATUSFORCE;
+ server_status_client(tc);
} else {
- c->flags |= CLIENT_STATUSFORCE;
- server_redraw_client(c);
+ tc->flags |= CLIENT_STATUSFORCE;
+ server_redraw_client(tc);
}
return (CMD_RETURN_NORMAL);
}