Merge branch 'obsd-master'

pull/757/head
Thomas Adam 2017-02-03 14:01:13 +00:00
commit 6c333cc486
26 changed files with 51 additions and 33 deletions

2
cfg.c
View File

@ -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))

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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++) {

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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 (c->flags & CLIENT_STATUSFORCE)
ft = format_create(NULL, FORMAT_STATUS|FORMAT_FORCE);
if (wl != NULL)
tag = FORMAT_WINDOW|wl->window->id;
else
ft = format_create(NULL, FORMAT_STATUS);
tag = FORMAT_NONE;
if (c->flags & CLIENT_STATUSFORCE)
ft = format_create(NULL, tag, FORMAT_STATUS|FORMAT_FORCE);
else
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);

5
tmux.h
View File

@ -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 *, ...);

View File

@ -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;

View File

@ -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);