mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Hide struct args behind a couple of accessor functions.
This commit is contained in:
@ -261,10 +261,10 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct menu *menu = NULL;
|
||||
struct menu_item menu_item;
|
||||
const char *key;
|
||||
char *title, *name;
|
||||
int flags = 0, i;
|
||||
u_int px, py;
|
||||
const char *key, *name;
|
||||
char *title;
|
||||
int flags = 0;
|
||||
u_int px, py, i, count = args_count(args);
|
||||
|
||||
if (tc->overlay_draw != NULL)
|
||||
return (CMD_RETURN_NORMAL);
|
||||
@ -275,24 +275,24 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item)
|
||||
title = xstrdup("");
|
||||
menu = menu_create(title);
|
||||
|
||||
for (i = 0; i != args->argc; /* nothing */) {
|
||||
name = args->argv[i++];
|
||||
for (i = 0; i != count; /* nothing */) {
|
||||
name = args_string(args, i++);
|
||||
if (*name == '\0') {
|
||||
menu_add_item(menu, NULL, item, tc, target);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args->argc - i < 2) {
|
||||
if (count - i < 2) {
|
||||
cmdq_error(item, "not enough arguments");
|
||||
free(title);
|
||||
menu_free(menu);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
key = args->argv[i++];
|
||||
key = args_string(args, i++);
|
||||
|
||||
menu_item.name = name;
|
||||
menu_item.key = key_string_lookup_string(key);
|
||||
menu_item.command = args->argv[i++];
|
||||
menu_item.command = args_string(args, i++);
|
||||
|
||||
menu_add_item(menu, &menu_item, item, tc, target);
|
||||
}
|
||||
@ -329,11 +329,10 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct session *s = target->s;
|
||||
struct client *tc = cmdq_get_target_client(item);
|
||||
struct tty *tty = &tc->tty;
|
||||
const char *value, *shell[] = { NULL, NULL };
|
||||
const char *shellcmd = NULL;
|
||||
char *cwd, *cause, **argv = args->argv;
|
||||
int flags = 0, argc = args->argc;
|
||||
u_int px, py, w, h;
|
||||
const char *value, *shell, *shellcmd = NULL;
|
||||
char *cwd, *cause, **argv = NULL;
|
||||
int flags = 0, argc = 0;
|
||||
u_int px, py, w, h, count = args_count(args);
|
||||
|
||||
if (args_has(args, 'C')) {
|
||||
server_client_clear_overlay(tc);
|
||||
@ -374,18 +373,18 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
cwd = format_single_from_target(item, value);
|
||||
else
|
||||
cwd = xstrdup(server_client_get_cwd(tc, s));
|
||||
if (argc == 0)
|
||||
if (count == 0)
|
||||
shellcmd = options_get_string(s->options, "default-command");
|
||||
else if (argc == 1)
|
||||
shellcmd = argv[0];
|
||||
if (argc <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
|
||||
else if (count == 1)
|
||||
shellcmd = args_string(args, 0);
|
||||
if (count <= 1 && (shellcmd == NULL || *shellcmd == '\0')) {
|
||||
shellcmd = NULL;
|
||||
shell[0] = options_get_string(s->options, "default-shell");
|
||||
if (!checkshell(shell[0]))
|
||||
shell[0] = _PATH_BSHELL;
|
||||
argc = 1;
|
||||
argv = (char**)shell;
|
||||
}
|
||||
shell = options_get_string(s->options, "default-shell");
|
||||
if (!checkshell(shell))
|
||||
shell = _PATH_BSHELL;
|
||||
cmd_append_argv(&argc, &argv, shell);
|
||||
} else
|
||||
args_vector(args, &argc, &argv);
|
||||
|
||||
if (args_has(args, 'E') > 1)
|
||||
flags |= POPUP_CLOSEEXITZERO;
|
||||
@ -394,7 +393,10 @@ cmd_display_popup_exec(struct cmd *self, struct cmdq_item *item)
|
||||
if (args_has(args, 'B'))
|
||||
flags |= POPUP_NOBORDER;
|
||||
if (popup_display(flags, item, px, py, w, h, shellcmd, argc, argv, cwd,
|
||||
tc, s, NULL, NULL) != 0)
|
||||
tc, s, NULL, NULL) != 0) {
|
||||
cmd_free_argv(argc, argv);
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
cmd_free_argv(argc, argv);
|
||||
return (CMD_RETURN_WAIT);
|
||||
}
|
||||
|
Reference in New Issue
Block a user