version 1.38, 2020/06/11 09:55:47 |
version 1.39, 2020/07/06 09:14:20 |
|
|
.name = "refresh-client", |
.name = "refresh-client", |
.alias = "refresh", |
.alias = "refresh", |
|
|
.args = { "A:cC:Df:F:lLRSt:U", 0, 1 }, |
.args = { "A:B:cC:Df:F:lLRSt:U", 0, 1 }, |
.usage = "[-cDlLRSU] [-A pane:state] [-C XxY] [-f flags] " |
.usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] " |
CMD_TARGET_CLIENT_USAGE " [adjustment]", |
"[-C XxY] [-f flags] " CMD_TARGET_CLIENT_USAGE " [adjustment]", |
|
|
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, |
.flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG, |
.exec = cmd_refresh_client_exec |
.exec = cmd_refresh_client_exec |
}; |
}; |
|
|
static void |
static void |
|
cmd_refresh_client_update_subscription(struct client *tc, const char *value) |
|
{ |
|
char *copy, *split, *name, *what; |
|
enum control_sub_type subtype; |
|
int subid = -1; |
|
|
|
copy = name = xstrdup(value); |
|
if ((split = strchr(copy, ':')) == NULL) { |
|
control_remove_sub(tc, copy); |
|
goto out; |
|
} |
|
*split++ = '\0'; |
|
|
|
what = split; |
|
if ((split = strchr(what, ':')) == NULL) |
|
goto out; |
|
*split++ = '\0'; |
|
|
|
if (strcmp(what, "%*") == 0) |
|
subtype = CONTROL_SUB_ALL_PANES; |
|
else if (sscanf(what, "%%%d", &subid) == 1 && subid >= 0) |
|
subtype = CONTROL_SUB_PANE; |
|
else if (strcmp(what, "@*") == 0) |
|
subtype = CONTROL_SUB_ALL_WINDOWS; |
|
else if (sscanf(what, "@%d", &subid) == 1 && subid >= 0) |
|
subtype = CONTROL_SUB_WINDOW; |
|
else |
|
subtype = CONTROL_SUB_SESSION; |
|
control_add_sub(tc, name, subtype, subid, split); |
|
|
|
out: |
|
free(copy); |
|
} |
|
|
|
static void |
cmd_refresh_client_update_offset(struct client *tc, const char *value) |
cmd_refresh_client_update_offset(struct client *tc, const char *value) |
{ |
{ |
struct window_pane *wp; |
struct window_pane *wp; |
char *copy, *colon; |
char *copy, *split; |
u_int pane; |
u_int pane; |
|
|
if (*value != '%') |
if (*value != '%') |
return; |
return; |
copy = xstrdup(value); |
copy = xstrdup(value); |
if ((colon = strchr(copy, ':')) == NULL) |
if ((split = strchr(copy, ':')) == NULL) |
goto out; |
goto out; |
*colon++ = '\0'; |
*split++ = '\0'; |
|
|
if (sscanf(copy, "%%%u", &pane) != 1) |
if (sscanf(copy, "%%%u", &pane) != 1) |
goto out; |
goto out; |
|
|
if (wp == NULL) |
if (wp == NULL) |
goto out; |
goto out; |
|
|
if (strcmp(colon, "on") == 0) |
if (strcmp(split, "on") == 0) |
control_set_pane_on(tc, wp); |
control_set_pane_on(tc, wp); |
else if (strcmp(colon, "off") == 0) |
else if (strcmp(split, "off") == 0) |
control_set_pane_off(tc, wp); |
control_set_pane_off(tc, wp); |
else if (strcmp(colon, "continue") == 0) |
else if (strcmp(split, "continue") == 0) |
control_continue_pane(tc, wp); |
control_continue_pane(tc, wp); |
else if (strcmp(colon, "pause") == 0) |
else if (strcmp(split, "pause") == 0) |
control_pause_pane(tc, wp); |
control_pause_pane(tc, wp); |
|
|
out: |
out: |
|
|
value = args_first_value(args, 'A', &av); |
value = args_first_value(args, 'A', &av); |
while (value != NULL) { |
while (value != NULL) { |
cmd_refresh_client_update_offset(tc, value); |
cmd_refresh_client_update_offset(tc, value); |
|
value = args_next_value(&av); |
|
} |
|
return (CMD_RETURN_NORMAL); |
|
} |
|
if (args_has(args, 'B')) { |
|
if (~tc->flags & CLIENT_CONTROL) |
|
goto not_control_client; |
|
value = args_first_value(args, 'B', &av); |
|
while (value != NULL) { |
|
cmd_refresh_client_update_subscription(tc, value); |
value = args_next_value(&av); |
value = args_next_value(&av); |
} |
} |
return (CMD_RETURN_NORMAL); |
return (CMD_RETURN_NORMAL); |