summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-05-16 16:16:07 +0000
committernicm <nicm@openbsd.org>2020-05-16 16:16:07 +0000
commit94adf770415cb803237af9a844544f2da66f1f98 (patch)
tree44ced233d9768929dc89d5ec0752a7bd6a908ad2
parentMove editor stuff to common code in popup.c. (diff)
downloadwireguard-openbsd-94adf770415cb803237af9a844544f2da66f1f98.tar.xz
wireguard-openbsd-94adf770415cb803237af9a844544f2da66f1f98.zip
Expand target from client and use it to expand the prompt.
-rw-r--r--usr.bin/tmux/cmd-command-prompt.c8
-rw-r--r--usr.bin/tmux/cmd-confirm-before.c8
-rw-r--r--usr.bin/tmux/cmd-queue.c5
-rw-r--r--usr.bin/tmux/mode-tree.c6
-rw-r--r--usr.bin/tmux/server-client.c9
-rw-r--r--usr.bin/tmux/status.c13
-rw-r--r--usr.bin/tmux/tmux.h9
-rw-r--r--usr.bin/tmux/window-customize.c13
-rw-r--r--usr.bin/tmux/window-tree.c11
9 files changed, 45 insertions, 37 deletions
diff --git a/usr.bin/tmux/cmd-command-prompt.c b/usr.bin/tmux/cmd-command-prompt.c
index 0a78ae8854c..aa69fbc8b57 100644
--- a/usr.bin/tmux/cmd-command-prompt.c
+++ b/usr.bin/tmux/cmd-command-prompt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-command-prompt.c,v 1.52 2020/05/16 15:16:36 nicm Exp $ */
+/* $OpenBSD: cmd-command-prompt.c,v 1.53 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -66,6 +66,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
struct client *tc = cmdq_get_target_client(item);
+ struct cmd_find_state *target = cmdq_get_target(item);
const char *inputs, *prompts;
struct cmd_command_prompt_cdata *cdata;
char *prompt, *ptr, *input = NULL;
@@ -125,8 +126,9 @@ cmd_command_prompt_exec(struct cmd *self, struct cmdq_item *item)
cdata->flags |= PROMPT_WINDOW;
else if (args_has(args, 'T'))
cdata->flags |= PROMPT_TARGET;
- status_prompt_set(tc, prompt, input, cmd_command_prompt_callback,
- cmd_command_prompt_free, cdata, cdata->flags);
+ status_prompt_set(tc, target, prompt, input,
+ cmd_command_prompt_callback, cmd_command_prompt_free, cdata,
+ cdata->flags);
free(prompt);
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/cmd-confirm-before.c b/usr.bin/tmux/cmd-confirm-before.c
index d60360a6d33..5d2126c17e3 100644
--- a/usr.bin/tmux/cmd-confirm-before.c
+++ b/usr.bin/tmux/cmd-confirm-before.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-confirm-before.c,v 1.41 2020/04/13 20:51:57 nicm Exp $ */
+/* $OpenBSD: cmd-confirm-before.c,v 1.42 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -56,6 +56,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
struct args *args = cmd_get_args(self);
struct cmd_confirm_before_data *cdata;
struct client *tc = cmdq_get_target_client(item);
+ struct cmd_find_state *target = cmdq_get_target(item);
char *cmd, *copy, *new_prompt, *ptr;
const char *prompt;
@@ -71,8 +72,9 @@ cmd_confirm_before_exec(struct cmd *self, struct cmdq_item *item)
cdata = xmalloc(sizeof *cdata);
cdata->cmd = xstrdup(args->argv[0]);
- status_prompt_set(tc, new_prompt, NULL, cmd_confirm_before_callback,
- cmd_confirm_before_free, cdata, PROMPT_SINGLE);
+ status_prompt_set(tc, target, new_prompt, NULL,
+ cmd_confirm_before_callback, cmd_confirm_before_free, cdata,
+ PROMPT_SINGLE);
free(new_prompt);
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 3e3fb6216fc..d210b62a0c4 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.94 2020/05/16 15:54:20 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.95 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -522,7 +522,7 @@ cmdq_find_flag(struct cmdq_item *item, struct cmd_find_state *fs,
const char *value;
if (flag->flag == 0) {
- cmd_find_clear_state(fs, 0);
+ cmd_find_from_client(fs, item->target_client, 0);
return (CMD_RETURN_NORMAL);
}
@@ -610,7 +610,6 @@ cmdq_fire_command(struct cmdq_item *item)
if (retval == CMD_RETURN_ERROR)
goto out;
-
retval = entry->exec(cmd, item);
if (retval == CMD_RETURN_ERROR)
goto out;
diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c
index 740305bb5a9..b0d5e03b42c 100644
--- a/usr.bin/tmux/mode-tree.c
+++ b/usr.bin/tmux/mode-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-tree.c,v 1.46 2020/05/16 16:02:24 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.47 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1125,7 +1125,7 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
case '/':
case '\023': /* C-s */
mtd->references++;
- status_prompt_set(c, "(search) ", "",
+ status_prompt_set(c, NULL, "(search) ", "",
mode_tree_search_callback, mode_tree_search_free, mtd,
PROMPT_NOFORMAT);
break;
@@ -1134,7 +1134,7 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
break;
case 'f':
mtd->references++;
- status_prompt_set(c, "(filter) ", mtd->filter,
+ status_prompt_set(c, NULL, "(filter) ", mtd->filter,
mode_tree_filter_callback, mode_tree_filter_free, mtd,
PROMPT_NOFORMAT);
break;
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 6d807fa994b..a3efa3505f5 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.339 2020/05/16 16:07:55 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.340 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -213,7 +213,6 @@ server_client_create(int fd)
c->queue = cmdq_new();
c->tty.fd = -1;
-
c->tty.sx = 80;
c->tty.sy = 24;
@@ -272,7 +271,7 @@ server_client_open(struct client *c, char **cause)
void
server_client_lost(struct client *c)
{
- struct client_file *cf;
+ struct client_file *cf, *cf1;
c->flags |= CLIENT_DEAD;
@@ -280,7 +279,7 @@ server_client_lost(struct client *c)
status_prompt_clear(c);
status_message_clear(c);
- RB_FOREACH(cf, client_files, &c->files) {
+ RB_FOREACH_SAFE(cf, client_files, &c->files, cf1) {
cf->error = EINTR;
file_fire_done(cf);
}
@@ -2250,7 +2249,7 @@ server_client_set_flags(struct client *c, const char *flags)
}
-/*Get client flags. This is only flags useful to show to users. */
+/* Get client flags. This is only flags useful to show to users. */
const char *
server_client_get_flags(struct client *c)
{
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c
index 73d6845fcfe..89c4272b129 100644
--- a/usr.bin/tmux/status.c
+++ b/usr.bin/tmux/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.210 2020/05/16 15:54:20 nicm Exp $ */
+/* $OpenBSD: status.c,v 1.211 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -532,14 +532,17 @@ status_message_redraw(struct client *c)
/* Enable status line prompt. */
void
-status_prompt_set(struct client *c, const char *msg, const char *input,
- prompt_input_cb inputcb, prompt_free_cb freecb, void *data, int flags)
+status_prompt_set(struct client *c, struct cmd_find_state *fs,
+ const char *msg, const char *input, prompt_input_cb inputcb,
+ prompt_free_cb freecb, void *data, int flags)
{
struct format_tree *ft;
char *tmp, *cp;
- ft = format_create(c, NULL, FORMAT_NONE, 0);
- format_defaults(ft, c, NULL, NULL, NULL);
+ if (fs != NULL)
+ ft = format_create_from_state(NULL, c, fs);
+ else
+ ft = format_create_defaults(NULL, c, NULL, NULL, NULL);
if (input == NULL)
input = "";
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 8a47252833d..34ffd4d8955 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1039 2020/05/16 16:13:09 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1040 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1504,7 +1504,7 @@ struct client_file {
client_file_cb cb;
void *data;
- RB_ENTRY (client_file) entry;
+ RB_ENTRY(client_file) entry;
};
RB_HEAD(client_files, client_file);
@@ -2359,8 +2359,9 @@ void printflike(3, 4) status_message_set(struct client *, int, const char *,
...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
-void status_prompt_set(struct client *, const char *, const char *,
- prompt_input_cb, prompt_free_cb, void *, int);
+void status_prompt_set(struct client *, struct cmd_find_state *,
+ const char *, const char *, prompt_input_cb, prompt_free_cb,
+ void *, int);
void status_prompt_clear(struct client *);
int status_prompt_redraw(struct client *);
int status_prompt_key(struct client *, key_code);
diff --git a/usr.bin/tmux/window-customize.c b/usr.bin/tmux/window-customize.c
index d5ccb41d462..b78e7a0fa7c 100644
--- a/usr.bin/tmux/window-customize.c
+++ b/usr.bin/tmux/window-customize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-customize.c,v 1.1 2020/05/16 16:02:24 nicm Exp $ */
+/* $OpenBSD: window-customize.c,v 1.2 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1111,7 +1111,7 @@ window_customize_set_option(struct client *c,
new_item->idx = idx;
data->references++;
- status_prompt_set(c, prompt, value,
+ status_prompt_set(c, NULL, prompt, value,
window_customize_set_option_callback,
window_customize_free_item_callback, new_item,
PROMPT_NOFORMAT);
@@ -1243,7 +1243,7 @@ window_customize_set_key(struct client *c,
new_item->key = key;
data->references++;
- status_prompt_set(c, prompt, value,
+ status_prompt_set(c, NULL, prompt, value,
window_customize_set_command_callback,
window_customize_free_item_callback, new_item,
PROMPT_NOFORMAT);
@@ -1259,7 +1259,8 @@ window_customize_set_key(struct client *c,
new_item->key = key;
data->references++;
- status_prompt_set(c, prompt, (bd->note == NULL ? "" : bd->note),
+ status_prompt_set(c, NULL, prompt,
+ (bd->note == NULL ? "" : bd->note),
window_customize_set_note_callback,
window_customize_free_item_callback, new_item,
PROMPT_NOFORMAT);
@@ -1398,7 +1399,7 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
} else
xasprintf(&prompt, "Unset option %s? ", item->name);
data->references++;
- status_prompt_set(c, prompt, "",
+ status_prompt_set(c, NULL, prompt, "",
window_customize_unset_current_callback,
window_customize_free_callback, data,
PROMPT_SINGLE|PROMPT_NOFORMAT);
@@ -1410,7 +1411,7 @@ window_customize_key(struct window_mode_entry *wme, struct client *c,
break;
xasprintf(&prompt, "Unset or unbind %u tagged? ", tagged);
data->references++;
- status_prompt_set(c, prompt, "",
+ status_prompt_set(c, NULL, prompt, "",
window_customize_unset_tagged_callback,
window_customize_free_callback, data,
PROMPT_SINGLE|PROMPT_NOFORMAT);
diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c
index fdd72fe907a..af071e3caa0 100644
--- a/usr.bin/tmux/window-tree.c
+++ b/usr.bin/tmux/window-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-tree.c,v 1.49 2020/05/16 16:02:24 nicm Exp $ */
+/* $OpenBSD: window-tree.c,v 1.50 2020/05/16 16:16:07 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1234,7 +1234,7 @@ window_tree_key(struct window_mode_entry *wme, struct client *c,
if (prompt == NULL)
break;
data->references++;
- status_prompt_set(c, prompt, "",
+ status_prompt_set(c, NULL, prompt, "",
window_tree_kill_current_callback, window_tree_command_free,
data, PROMPT_SINGLE|PROMPT_NOFORMAT);
free(prompt);
@@ -1245,7 +1245,7 @@ window_tree_key(struct window_mode_entry *wme, struct client *c,
break;
xasprintf(&prompt, "Kill %u tagged? ", tagged);
data->references++;
- status_prompt_set(c, prompt, "",
+ status_prompt_set(c, NULL, prompt, "",
window_tree_kill_tagged_callback, window_tree_command_free,
data, PROMPT_SINGLE|PROMPT_NOFORMAT);
free(prompt);
@@ -1257,8 +1257,9 @@ window_tree_key(struct window_mode_entry *wme, struct client *c,
else
xasprintf(&prompt, "(current) ");
data->references++;
- status_prompt_set(c, prompt, "", window_tree_command_callback,
- window_tree_command_free, data, PROMPT_NOFORMAT);
+ status_prompt_set(c, NULL, prompt, "",
+ window_tree_command_callback, window_tree_command_free,
+ data, PROMPT_NOFORMAT);
free(prompt);
break;
case '\r':