Remove format_create_flags and just pass flags to format_create.

This commit is contained in:
nicm 2015-12-08 08:34:18 +00:00
parent 8f671d3eef
commit e0f26dcda3
22 changed files with 28 additions and 36 deletions

View File

@ -93,7 +93,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
}
if (cflag != NULL) {
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
NULL, NULL);
cwd = format_expand(ft, cflag);

View File

@ -101,7 +101,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((template = args_get(args, 'F')) == NULL)
template = BREAK_PANE_TEMPLATE;
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), dst_s, wl,
wp);

View File

@ -88,7 +88,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
if (template == NULL)
template = DISPLAY_MESSAGE_TEMPLATE;
ft = format_create();
ft = format_create(0);
format_defaults(ft, c, s, wl, wp);
msg = format_expand_time(ft, template, time(NULL));

View File

@ -86,7 +86,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
cwd = NULL;
}
ft = format_create();
ft = format_create(0);
format_defaults(ft, NULL, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);

View File

@ -54,7 +54,7 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_q *cmdq)
pb = NULL;
while ((pb = paste_walk(pb)) != NULL) {
ft = format_create();
ft = format_create(0);
format_defaults_paste_buffer(ft, pb);
line = format_expand(ft, template);

View File

@ -69,7 +69,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
if (c->session == NULL || (s != NULL && s != c->session))
continue;
ft = format_create();
ft = format_create(0);
format_add(ft, "line", "%u", idx);
format_defaults(ft, c, NULL, NULL, NULL);

View File

@ -125,7 +125,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();
ft = format_create(0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, wp);

View File

@ -61,7 +61,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
n = 0;
RB_FOREACH(s, sessions, &sessions) {
ft = format_create();
ft = format_create(0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, NULL, NULL);

View File

@ -105,7 +105,7 @@ cmd_list_windows_session(
n = 0;
RB_FOREACH(wl, winlinks, &s->windows) {
ft = format_create();
ft = format_create(0);
format_add(ft, "line", "%u", n);
format_defaults(ft, NULL, s, wl, NULL);

View File

@ -119,7 +119,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Get the new session working directory. */
to_free = NULL;
if (args_has(args, 'c')) {
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), NULL, NULL,
NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
@ -283,7 +283,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
if ((template = args_get(args, 'F')) == NULL)
template = NEW_SESSION_TEMPLATE;
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
NULL);

View File

@ -94,7 +94,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
to_free = NULL;
if (args_has(args, 'c')) {
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
NULL);
cwd = to_free = format_expand(ft, args_get(args, 'c'));
@ -143,7 +143,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
if ((template = args_get(args, 'F')) == NULL)
template = NEW_WINDOW_TEMPLATE;
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
NULL);

View File

@ -89,7 +89,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
/* Expand the command. */
ft = format_create();
ft = format_create(0);
format_defaults(ft, c, s, wl, wp);
cmd = format_expand_time(ft, args->argv[0], time(NULL));
format_free(ft);

View File

@ -100,7 +100,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
cwd = NULL;
}
ft = format_create();
ft = format_create(0);
format_defaults(ft, NULL, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);

View File

@ -88,7 +88,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
to_free = NULL;
if (args_has(args, 'c')) {
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
NULL);
to_free = cwd = format_expand(ft, args_get(args, 'c'));
@ -165,7 +165,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
if ((template = args_get(args, 'F')) == NULL)
template = SPLIT_WINDOW_TEMPLATE;
ft = format_create();
ft = format_create(0);
format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
new_wp);

View File

@ -88,7 +88,7 @@ control_notify_window_layout_changed(struct window *w)
if (w->layout_root == NULL)
continue;
ft = format_create();
ft = format_create(0);
wl = winlink_find_by_window(&s->windows, w);
if (wl != NULL) {
format_defaults(ft, c, NULL, wl, NULL);

View File

@ -465,14 +465,7 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe)
/* Create a new tree. */
struct format_tree *
format_create(void)
{
return (format_create_flags(0));
}
/* Create a new tree for the status line. */
struct format_tree *
format_create_flags(int flags)
format_create(int flags)
{
struct format_tree *ft;

View File

@ -118,7 +118,7 @@ format_window_name(struct window *w)
struct format_tree *ft;
char *fmt, *name;
ft = format_create();
ft = format_create(0);
format_defaults_window(ft, w);
format_defaults_pane(ft, w->active);

View File

@ -933,7 +933,7 @@ server_client_set_title(struct client *c)
template = options_get_string(s->options, "set-titles-string");
ft = format_create();
ft = format_create(0);
format_defaults(ft, c, NULL, NULL, NULL);
title = format_expand_time(ft, template, time(NULL));

View File

@ -500,9 +500,9 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
return (xstrdup(""));
if (c->flags & CLIENT_STATUSFORCE)
ft = format_create_flags(FORMAT_STATUS|FORMAT_FORCE);
ft = format_create(FORMAT_STATUS|FORMAT_FORCE);
else
ft = format_create_flags(FORMAT_STATUS);
ft = format_create(FORMAT_STATUS);
format_defaults(ft, c, NULL, wl, NULL);
expanded = format_expand_time(ft, fmt, t);
@ -661,7 +661,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
int keys;
time_t t;
ft = format_create();
ft = format_create(0);
format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL);
@ -722,7 +722,7 @@ status_prompt_update(struct client *c, const char *msg, const char *input)
struct format_tree *ft;
time_t t;
ft = format_create();
ft = format_create(0);
format_defaults(ft, c, NULL, NULL, NULL);
t = time(NULL);

3
tmux.h
View File

@ -1492,8 +1492,7 @@ char *paste_make_sample(struct paste_buffer *);
#define FORMAT_STATUS 0x1
#define FORMAT_FORCE 0x2
struct format_tree;
struct format_tree *format_create(void);
struct format_tree *format_create_flags(int);
struct format_tree *format_create(int);
void format_free(struct format_tree *);
void printflike(3, 4) format_add(struct format_tree *, const char *,
const char *, ...);

View File

@ -186,7 +186,7 @@ window_choose_data_create(int type, struct client *c, struct session *s)
wcd = xmalloc(sizeof *wcd);
wcd->type = type;
wcd->ft = format_create();
wcd->ft = format_create(0);
wcd->ft_template = NULL;
wcd->command = NULL;

View File

@ -1480,7 +1480,7 @@ window_copy_copy_pipe(struct window_pane *wp, struct session *sess,
if (buf == NULL)
return;
ft = format_create();
ft = format_create(0);
format_defaults(ft, NULL, sess, NULL, wp);
expanded = format_expand(ft, arg);