summaryrefslogtreecommitdiffstats
path: root/cmd-display-menu.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-08-25 12:01:11 +0100
committerThomas Adam <thomas@xteddy.org>2021-08-25 12:01:11 +0100
commitc6375a0d4003d1008bb64e96e9c0c4433e4a5d13 (patch)
treeac84b463df1f905b68cfce14c68a1bfe3d543b05 /cmd-display-menu.c
parent6616b42b2c28cd7a1b6d52dfc895f5a1d3dce8b3 (diff)
parent24636be42b4b0463afe5c72e1d982f28729a0579 (diff)
Merge branch 'obsd-master' into master
Diffstat (limited to 'cmd-display-menu.c')
-rw-r--r--cmd-display-menu.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/cmd-display-menu.c b/cmd-display-menu.c
index 06c62c5b..4c5fb510 100644
--- a/cmd-display-menu.c
+++ b/cmd-display-menu.c
@@ -27,16 +27,18 @@
* Display a menu on a client.
*/
-static enum cmd_retval cmd_display_menu_exec(struct cmd *,
- struct cmdq_item *);
-static enum cmd_retval cmd_display_popup_exec(struct cmd *,
- struct cmdq_item *);
+static enum args_parse_type cmd_display_menu_args_parse(struct args *,
+ u_int, char **);
+static enum cmd_retval cmd_display_menu_exec(struct cmd *,
+ struct cmdq_item *);
+static enum cmd_retval cmd_display_popup_exec(struct cmd *,
+ struct cmdq_item *);
const struct cmd_entry cmd_display_menu_entry = {
.name = "display-menu",
.alias = "menu",
- .args = { "c:t:OT:x:y:", 1, -1, NULL },
+ .args = { "c:t:OT:x:y:", 1, -1, cmd_display_menu_args_parse },
.usage = "[-O] [-c target-client] " CMD_TARGET_PANE_USAGE " [-T title] "
"[-x position] [-y position] name key command ...",
@@ -52,8 +54,8 @@ const struct cmd_entry cmd_display_popup_entry = {
.args = { "BCc:d:Eh:t:w:x:y:", 0, -1, NULL },
.usage = "[-BCE] [-c target-client] [-d start-directory] [-h height] "
- CMD_TARGET_PANE_USAGE " [-w width] "
- "[-x position] [-y position] [command]",
+ CMD_TARGET_PANE_USAGE " [-w width] "
+ "[-x position] [-y position] [shell-command]",
.target = { 't', CMD_FIND_PANE, 0 },
@@ -61,6 +63,30 @@ const struct cmd_entry cmd_display_popup_entry = {
.exec = cmd_display_popup_exec
};
+static enum args_parse_type
+cmd_display_menu_args_parse(struct args *args, u_int idx, __unused char **cause)
+{
+ u_int i = 0;
+ enum args_parse_type type = ARGS_PARSE_STRING;
+
+ for (;;) {
+ type = ARGS_PARSE_STRING;
+ if (i == idx)
+ break;
+ if (*args_string(args, i++) == '\0')
+ continue;
+
+ type = ARGS_PARSE_STRING;
+ if (i++ == idx)
+ break;
+
+ type = ARGS_PARSE_COMMANDS_OR_STRING;
+ if (i++ == idx)
+ break;
+ }
+ return (type);
+}
+
static int
cmd_display_menu_get_position(struct client *tc, struct cmdq_item *item,
struct args *args, u_int *px, u_int *py, u_int w, u_int h)