summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2017-02-03 14:01:13 +0000
committerThomas Adam <thomas@xteddy.org>2017-02-03 14:01:13 +0000
commit6c333cc4864c11283704b069fa6477876fd48f70 (patch)
tree97f9033c539139408a55c59c0580d1321af0fb64
parent9b1f620aa017bb3634b3806e959580cde75ec655 (diff)
parent7d23d019c0df197d724ced7fec21dc2047634c9b (diff)
Merge branch 'obsd-master'
-rw-r--r--cfg.c2
-rw-r--r--cmd-attach-session.c2
-rw-r--r--cmd-break-pane.c2
-rw-r--r--cmd-display-message.c2
-rw-r--r--cmd-if-shell.c2
-rw-r--r--cmd-list-buffers.c2
-rw-r--r--cmd-list-clients.c2
-rw-r--r--cmd-list-keys.c2
-rw-r--r--cmd-list-panes.c2
-rw-r--r--cmd-list-sessions.c2
-rw-r--r--cmd-list-windows.c2
-rw-r--r--cmd-new-session.c4
-rw-r--r--cmd-new-window.c4
-rw-r--r--cmd-pipe-pane.c2
-rw-r--r--cmd-queue.c2
-rw-r--r--cmd-run-shell.c2
-rw-r--r--cmd-split-window.c4
-rw-r--r--control-notify.c2
-rw-r--r--format.c12
-rw-r--r--names.c2
-rw-r--r--screen-redraw.c2
-rw-r--r--server-client.c2
-rw-r--r--status.c13
-rw-r--r--tmux.h5
-rw-r--r--window-choose.c2
-rw-r--r--window-copy.c2
26 files changed, 50 insertions, 32 deletions
diff --git a/cfg.c b/cfg.c
index f59a0842..b1fe22bf 100644
--- a/cfg.c
+++ b/cfg.c
@@ -122,7 +122,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
line);
continue;
}
- ft = format_create(NULL, FORMAT_NOJOBS);
+ ft = format_create(NULL, FORMAT_NONE, FORMAT_NOJOBS);
s = p + 3;
while (isspace((u_char)*s))
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index f39c0e31..d29c4dd1 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -77,7 +77,7 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
}
if (cflag != NULL) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp);
cwd = format_expand(ft, cflag);
format_free(ft);
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index c949fe8a..fdefeb17 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -107,7 +107,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
if ((template = args_get(args, 'F')) == NULL)
template = BREAK_PANE_TEMPLATE;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, item->state.c, dst_s, wl, wp);
cp = format_expand(ft, template);
diff --git a/cmd-display-message.c b/cmd-display-message.c
index c57db579..3bb5f9ac 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -73,7 +73,7 @@ cmd_display_message_exec(struct cmd *self, struct cmdq_item *item)
if (template == NULL)
template = DISPLAY_MESSAGE_TEMPLATE;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp);
msg = format_expand_time(ft, template, time(NULL));
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index 93910f34..ec4bf68e 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -82,7 +82,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
else
cwd = NULL;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, item->state.c, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);
diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c
index c67c3524..cc3ffbfb 100644
--- a/cmd-list-buffers.c
+++ b/cmd-list-buffers.c
@@ -57,7 +57,7 @@ cmd_list_buffers_exec(struct cmd *self, struct cmdq_item *item)
pb = NULL;
while ((pb = paste_walk(pb)) != NULL) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults_paste_buffer(ft, pb);
line = format_expand(ft, template);
diff --git a/cmd-list-clients.c b/cmd-list-clients.c
index f07cd45e..faf39931 100644
--- a/cmd-list-clients.c
+++ b/cmd-list-clients.c
@@ -72,7 +72,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmdq_item *item)
if (c->session == NULL || (s != NULL && s != c->session))
continue;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", idx);
format_defaults(ft, c, NULL, NULL, NULL);
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 7c6142ec..ebc221e5 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -144,7 +144,7 @@ cmd_list_keys_commands(struct cmd *self, struct cmdq_item *item)
"#{command_list_usage}";
}
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, NULL, NULL, NULL, NULL);
for (entryp = cmd_table; *entryp != NULL; entryp++) {
diff --git a/cmd-list-panes.c b/cmd-list-panes.c
index 341bdd68..d8ca2a93 100644
--- a/cmd-list-panes.c
+++ b/cmd-list-panes.c
@@ -123,7 +123,7 @@ cmd_list_panes_window(struct cmd *self, struct session *s, struct winlink *wl,
n = 0;
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, wp);
diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c
index d90c8970..7d3e8c10 100644
--- a/cmd-list-sessions.c
+++ b/cmd-list-sessions.c
@@ -65,7 +65,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmdq_item *item)
n = 0;
RB_FOREACH(s, sessions, &sessions) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, NULL, NULL);
diff --git a/cmd-list-windows.c b/cmd-list-windows.c
index cd7498f0..52a8d562 100644
--- a/cmd-list-windows.c
+++ b/cmd-list-windows.c
@@ -105,7 +105,7 @@ cmd_list_windows_session(struct cmd *self, struct session *s,
n = 0;
RB_FOREACH(wl, winlinks, &s->windows) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, NULL);
diff --git a/cmd-new-session.c b/cmd-new-session.c
index a39522ac..4e7b413b 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -139,7 +139,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
/* Get the new session working directory. */
if (args_has(args, 'c')) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, NULL, NULL, NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -298,7 +298,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
if ((template = args_get(args, 'F')) == NULL)
template = NEW_SESSION_TEMPLATE;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, NULL, NULL);
cp = format_expand(ft, template);
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 2e032c40..082b7443 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -95,7 +95,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
to_free = NULL;
if (args_has(args, 'c')) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, NULL, NULL);
cwd = to_free = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -143,7 +143,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
if ((template = args_get(args, 'F')) == NULL)
template = NEW_WINDOW_TEMPLATE;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, NULL);
cp = format_expand(ft, template);
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index ff37b0d8..af5ee811 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -89,7 +89,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item)
}
/* Expand the command. */
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, c, s, wl, wp);
cmd = format_expand_time(ft, args->argv[0], time(NULL));
format_free(ft);
diff --git a/cmd-queue.c b/cmd-queue.c
index d1875717..8e3b0bf3 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -268,7 +268,7 @@ cmdq_format(struct cmdq_item *item, const char *key, const char *fmt, ...)
for (loop = item; loop != NULL; loop = item->next) {
if (loop->formats == NULL)
- loop->formats = format_create(NULL, 0);
+ loop->formats = format_create(NULL, FORMAT_NONE, 0);
format_add(loop->formats, key, "%s", value);
}
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index e5726b26..29375428 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -100,7 +100,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
else
cwd = NULL;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, item->state.c, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 213770c4..ee6c583b 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -91,7 +91,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
to_free = NULL;
if (args_has(args, 'c')) {
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, item->state.c, s, NULL, NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -168,7 +168,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
if ((template = args_get(args, 'F')) == NULL)
template = SPLIT_WINDOW_TEMPLATE;
- ft = format_create(item, 0);
+ ft = format_create(item, FORMAT_NONE, 0);
format_defaults(ft, item->state.c, s, wl, new_wp);
cp = format_expand(ft, template);
diff --git a/control-notify.c b/control-notify.c
index 9158ce2c..3b2d32eb 100644
--- a/control-notify.c
+++ b/control-notify.c
@@ -88,7 +88,7 @@ control_notify_window_layout_changed(struct window *w)
if (w->layout_root == NULL)
continue;
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_NONE, 0);
wl = winlink_find_by_window(&s->windows, w);
if (wl != NULL) {
format_defaults(ft, c, NULL, wl, NULL);
diff --git a/format.c b/format.c
index aace9103..57e9e6a4 100644
--- a/format.c
+++ b/format.c
@@ -81,6 +81,7 @@ static void format_defaults_winlink(struct format_tree *, struct session *,
/* Entry in format job tree. */
struct format_job {
+ u_int tag;
const char *cmd;
const char *expanded;
@@ -103,6 +104,10 @@ RB_GENERATE_STATIC(format_job_tree, format_job, entry, format_job_cmp);
static int
format_job_cmp(struct format_job *fj1, struct format_job *fj2)
{
+ if (fj1->tag < fj2->tag)
+ return (-1);
+ if (fj1->tag > fj2->tag)
+ return (1);
return (strcmp(fj1->cmd, fj2->cmd));
}
@@ -127,6 +132,7 @@ struct format_tree {
struct session *s;
struct window_pane *wp;
+ u_int tag;
int flags;
RB_HEAD(format_entry_tree, format_entry) tree;
@@ -242,9 +248,11 @@ format_job_get(struct format_tree *ft, const char *cmd)
char *expanded;
int force;
+ fj0.tag = ft->tag;
fj0.cmd = cmd;
if ((fj = RB_FIND(format_job_tree, &format_jobs, &fj0)) == NULL) {
fj = xcalloc(1, sizeof *fj);
+ fj->tag = ft->tag;
fj->cmd = xstrdup(cmd);
fj->expanded = NULL;
@@ -516,7 +524,7 @@ format_merge(struct format_tree *ft, struct format_tree *from)
/* Create a new tree. */
struct format_tree *
-format_create(struct cmdq_item *item, int flags)
+format_create(struct cmdq_item *item, int tag, int flags)
{
struct format_tree *ft;
@@ -527,6 +535,8 @@ format_create(struct cmdq_item *item, int flags)
ft = xcalloc(1, sizeof *ft);
RB_INIT(&ft->tree);
+
+ ft->tag = tag;
ft->flags = flags;
format_add(ft, "version", "%s", VERSION);
diff --git a/names.c b/names.c
index 877b2504..e5fd2611 100644
--- a/names.c
+++ b/names.c
@@ -124,7 +124,7 @@ format_window_name(struct window *w)
const char *fmt;
char *name;
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_WINDOW|w->id, 0);
format_defaults_window(ft, w);
format_defaults_pane(ft, w->active);
diff --git a/screen-redraw.c b/screen-redraw.c
index b7833716..ae2948aa 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -280,7 +280,7 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
fmt = options_get_string(w->options, "pane-border-format");
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_PANE|wp->id, 0);
format_defaults(ft, c, NULL, NULL, wp);
memcpy(&old, &wp->status_screen, sizeof old);
diff --git a/server-client.c b/server-client.c
index 0461b97e..856bc04d 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1230,7 +1230,7 @@ server_client_set_title(struct client *c)
template = options_get_string(s->options, "set-titles-string");
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_NONE, 0);
format_defaults(ft, c, NULL, NULL, NULL);
title = format_expand_time(ft, template, time(NULL));
diff --git a/status.c b/status.c
index 9fc9a502..c4f79050 100644
--- a/status.c
+++ b/status.c
@@ -500,14 +500,19 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
{
struct format_tree *ft;
char *expanded;
+ u_int tag;
if (fmt == NULL)
return (xstrdup(""));
+ if (wl != NULL)
+ tag = FORMAT_WINDOW|wl->window->id;
+ else
+ tag = FORMAT_NONE;
if (c->flags & CLIENT_STATUSFORCE)
- ft = format_create(NULL, FORMAT_STATUS|FORMAT_FORCE);
+ ft = format_create(NULL, tag, FORMAT_STATUS|FORMAT_FORCE);
else
- ft = format_create(NULL, FORMAT_STATUS);
+ ft = format_create(NULL, tag, FORMAT_STATUS);
format_defaults(ft, c, NULL, wl, NULL);
expanded = format_expand_time(ft, fmt, t);
@@ -665,7 +670,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
time_t t;
char *tmp;
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_NONE, 0);
format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL);
@@ -726,7 +731,7 @@ status_prompt_update(struct client *c, const char *msg, const char *input)
time_t t;
char *tmp;
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_NONE, 0);
format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL);
diff --git a/tmux.h b/tmux.h
index 2f40579c..69f99d63 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1505,8 +1505,11 @@ char *paste_make_sample(struct paste_buffer *);
#define FORMAT_STATUS 0x1
#define FORMAT_FORCE 0x2
#define FORMAT_NOJOBS 0x4
+#define FORMAT_NONE 0
+#define FORMAT_PANE 0x80000000U
+#define FORMAT_WINDOW 0x40000000U
struct format_tree;
-struct format_tree *format_create(struct cmdq_item *, int);
+struct format_tree *format_create(struct cmdq_item *, int, int);
void format_free(struct format_tree *);
void printflike(3, 4) format_add(struct format_tree *, const char *,
const char *, ...);
diff --git a/window-choose.c b/window-choose.c
index bf3cd10c..b7647d2a 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -202,7 +202,7 @@ window_choose_data_create(int type, struct client *c, struct session *s)
wcd = xmalloc(sizeof *wcd);
wcd->type = type;
- wcd->ft = format_create(NULL, 0);
+ wcd->ft = format_create(NULL, FORMAT_NONE, 0);
wcd->ft_template = NULL;
wcd->command = NULL;
diff --git a/window-copy.c b/window-copy.c
index 398683e2..f808e7af 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1611,7 +1611,7 @@ window_copy_copy_pipe(struct window_pane *wp, struct session *sess,
if (buf == NULL)
return;
- ft = format_create(NULL, 0);
+ ft = format_create(NULL, FORMAT_NONE, 0);
format_defaults(ft, NULL, sess, NULL, wp);
expanded = format_expand(ft, arg);