mirror of
https://github.com/tmux/tmux.git
synced 2025-03-29 10:18:49 +00:00
Make display-panes block the client until a pane is chosen or it times out.
This commit is contained in:
parent
fe7486d43b
commit
21f8ac2766
@ -55,6 +55,7 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
|
||||||
return (CMD_RETURN_ERROR);
|
return (CMD_RETURN_ERROR);
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
if (c->identify_callback != NULL)
|
if (c->identify_callback != NULL)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
@ -64,7 +65,7 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
c->identify_callback_data = xstrdup(args->argv[0]);
|
c->identify_callback_data = xstrdup(args->argv[0]);
|
||||||
else
|
else
|
||||||
c->identify_callback_data = xstrdup("select-pane -t '%%'");
|
c->identify_callback_data = xstrdup("select-pane -t '%%'");
|
||||||
s = c->session;
|
c->identify_callback_item = item;
|
||||||
|
|
||||||
if (args_has(args, 'd')) {
|
if (args_has(args, 'd')) {
|
||||||
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
|
delay = args_strtonum(args, 'd', 0, UINT_MAX, &cause);
|
||||||
@ -77,7 +78,7 @@ cmd_display_panes_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
delay = options_get_number(s->options, "display-panes-time");
|
delay = options_get_number(s->options, "display-panes-time");
|
||||||
server_client_set_identify(c, delay);
|
server_client_set_identify(c, delay);
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static enum cmd_retval
|
static enum cmd_retval
|
||||||
@ -96,34 +97,36 @@ cmd_display_panes_callback(struct client *c, struct window_pane *wp)
|
|||||||
{
|
{
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmdq_item *new_item;
|
struct cmdq_item *new_item;
|
||||||
char *template, *cmd, *expanded, *cause;
|
char *cmd, *expanded, *cause;
|
||||||
|
|
||||||
template = c->identify_callback_data;
|
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
xasprintf(&expanded, "%%%u", wp->id);
|
xasprintf(&expanded, "%%%u", wp->id);
|
||||||
cmd = cmd_template_replace(template, expanded, 1);
|
cmd = cmd_template_replace(c->identify_callback_data, expanded, 1);
|
||||||
|
|
||||||
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
cmdlist = cmd_string_parse(cmd, NULL, 0, &cause);
|
||||||
if (cmdlist == NULL) {
|
if (cmdlist == NULL && cause != NULL)
|
||||||
if (cause != NULL) {
|
new_item = cmdq_get_callback(cmd_display_panes_error, cause);
|
||||||
new_item = cmdq_get_callback(cmd_display_panes_error,
|
else if (cmdlist == NULL)
|
||||||
cause);
|
new_item = NULL;
|
||||||
} else
|
else {
|
||||||
new_item = NULL;
|
|
||||||
} else {
|
|
||||||
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_item != NULL)
|
if (new_item != NULL)
|
||||||
cmdq_append(c, new_item);
|
cmdq_insert_after(c->identify_callback_item, new_item);
|
||||||
|
|
||||||
free(cmd);
|
free(cmd);
|
||||||
free(expanded);
|
free(expanded);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
c->identify_callback_item->flags &= ~CMDQ_WAITING;
|
||||||
|
c->identify_callback_item = NULL;
|
||||||
|
|
||||||
free(c->identify_callback_data);
|
free(c->identify_callback_data);
|
||||||
c->identify_callback_data = NULL;
|
c->identify_callback_data = NULL;
|
||||||
|
|
||||||
c->identify_callback = NULL;
|
c->identify_callback = NULL;
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -1357,6 +1357,7 @@ struct client {
|
|||||||
void (*identify_callback)(struct client *,
|
void (*identify_callback)(struct client *,
|
||||||
struct window_pane *);
|
struct window_pane *);
|
||||||
void *identify_callback_data;
|
void *identify_callback_data;
|
||||||
|
struct cmdq_item *identify_callback_item;
|
||||||
|
|
||||||
char *message_string;
|
char *message_string;
|
||||||
struct event message_timer;
|
struct event message_timer;
|
||||||
|
Loading…
Reference in New Issue
Block a user