Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2019-04-18 14:08:13 +01:00
commit 3c1f0cfc34
4 changed files with 24 additions and 10 deletions

View File

@ -160,6 +160,7 @@ dist_tmux_SOURCES = \
server-fn.c \ server-fn.c \
server.c \ server.c \
session.c \ session.c \
spawn.c \
status.c \ status.c \
style.c \ style.c \
spawn.c \ spawn.c \

30
cfg.c
View File

@ -115,7 +115,8 @@ start_cfg(void)
} }
static int static int
cfg_check_condition(const char *path, size_t line, const char *p, int *skip) cfg_check_cond(const char *path, size_t line, const char *p, int *skip,
struct client *c, struct cmd_find_state *fs)
{ {
struct format_tree *ft; struct format_tree *ft;
char *s; char *s;
@ -130,6 +131,10 @@ cfg_check_condition(const char *path, size_t line, const char *p, int *skip)
} }
ft = format_create(NULL, NULL, FORMAT_NONE, FORMAT_NOJOBS); ft = format_create(NULL, NULL, FORMAT_NONE, FORMAT_NOJOBS);
if (fs != NULL)
format_defaults(ft, c, fs->s, fs->wl, fs->wp);
else
format_defaults(ft, c, NULL, NULL, NULL);
s = format_expand(ft, p); s = format_expand(ft, p);
result = format_true(s); result = format_true(s);
free(s); free(s);
@ -141,7 +146,7 @@ cfg_check_condition(const char *path, size_t line, const char *p, int *skip)
static void static void
cfg_handle_if(const char *path, size_t line, struct cfg_conds *conds, cfg_handle_if(const char *path, size_t line, struct cfg_conds *conds,
const char *p) const char *p, struct client *c, struct cmd_find_state *fs)
{ {
struct cfg_cond *cond; struct cfg_cond *cond;
struct cfg_cond *parent = TAILQ_FIRST(conds); struct cfg_cond *parent = TAILQ_FIRST(conds);
@ -153,7 +158,7 @@ cfg_handle_if(const char *path, size_t line, struct cfg_conds *conds,
cond = xcalloc(1, sizeof *cond); cond = xcalloc(1, sizeof *cond);
cond->line = line; cond->line = line;
if (parent == NULL || parent->met) if (parent == NULL || parent->met)
cond->met = cfg_check_condition(path, line, p, &cond->skip); cond->met = cfg_check_cond(path, line, p, &cond->skip, c, fs);
else else
cond->skip = 1; cond->skip = 1;
cond->saw_else = 0; cond->saw_else = 0;
@ -162,7 +167,7 @@ cfg_handle_if(const char *path, size_t line, struct cfg_conds *conds,
static void static void
cfg_handle_elif(const char *path, size_t line, struct cfg_conds *conds, cfg_handle_elif(const char *path, size_t line, struct cfg_conds *conds,
const char *p) const char *p, struct client *c, struct cmd_find_state *fs)
{ {
struct cfg_cond *cond = TAILQ_FIRST(conds); struct cfg_cond *cond = TAILQ_FIRST(conds);
@ -173,7 +178,7 @@ cfg_handle_elif(const char *path, size_t line, struct cfg_conds *conds,
if (cond == NULL || cond->saw_else) if (cond == NULL || cond->saw_else)
cfg_add_cause("%s:%zu: unexpected %%elif", path, line); cfg_add_cause("%s:%zu: unexpected %%elif", path, line);
else if (!cond->skip) else if (!cond->skip)
cond->met = cfg_check_condition(path, line, p, &cond->skip); cond->met = cfg_check_cond(path, line, p, &cond->skip, c, fs);
else else
cond->met = 0; cond->met = 0;
} }
@ -214,16 +219,16 @@ cfg_handle_endif(const char *path, size_t line, struct cfg_conds *conds)
static void static void
cfg_handle_directive(const char *p, const char *path, size_t line, cfg_handle_directive(const char *p, const char *path, size_t line,
struct cfg_conds *conds) struct cfg_conds *conds, struct client *c, struct cmd_find_state *fs)
{ {
int n = 0; int n = 0;
while (p[n] != '\0' && !isspace((u_char)p[n])) while (p[n] != '\0' && !isspace((u_char)p[n]))
n++; n++;
if (strncmp(p, "%if", n) == 0) if (strncmp(p, "%if", n) == 0)
cfg_handle_if(path, line, conds, p + n); cfg_handle_if(path, line, conds, p + n, c, fs);
else if (strncmp(p, "%elif", n) == 0) else if (strncmp(p, "%elif", n) == 0)
cfg_handle_elif(path, line, conds, p + n); cfg_handle_elif(path, line, conds, p + n, c, fs);
else if (strcmp(p, "%else") == 0) else if (strcmp(p, "%else") == 0)
cfg_handle_else(path, line, conds); cfg_handle_else(path, line, conds);
else if (strcmp(p, "%endif") == 0) else if (strcmp(p, "%endif") == 0)
@ -244,6 +249,13 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
struct cmdq_item *new_item; struct cmdq_item *new_item;
struct cfg_cond *cond, *cond1; struct cfg_cond *cond, *cond1;
struct cfg_conds conds; struct cfg_conds conds;
struct cmd_find_state *fs = NULL;
struct client *fc = NULL;
if (item != NULL) {
fs = &item->target;
fc = cmd_find_client(item, NULL, 1);
}
TAILQ_INIT(&conds); TAILQ_INIT(&conds);
@ -270,7 +282,7 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
*q-- = '\0'; *q-- = '\0';
if (*p == '%') { if (*p == '%') {
cfg_handle_directive(p, path, line, &conds); cfg_handle_directive(p, path, line, &conds, fc, fs);
continue; continue;
} }
cond = TAILQ_FIRST(&conds); cond = TAILQ_FIRST(&conds);

View File

@ -1139,7 +1139,7 @@ screen_write_collect_clear(struct screen_write_ctx *ctx, u_int y, u_int n)
u_int i; u_int i;
size_t size; size_t size;
for (i = y ; i < y + n; i++) { for (i = y; i < y + n; i++) {
if (TAILQ_EMPTY(&ctx->list[i].items)) if (TAILQ_EMPTY(&ctx->list[i].items))
continue; continue;
size = 0; size = 0;

View File

@ -1379,6 +1379,7 @@ focused:
if (wp->base.mode & MODE_FOCUSON) if (wp->base.mode & MODE_FOCUSON)
bufferevent_write(wp->event, "\033[I", 3); bufferevent_write(wp->event, "\033[I", 3);
notify_pane("pane-focus-in", wp); notify_pane("pane-focus-in", wp);
session_update_activity(c->session, NULL);
} }
wp->flags |= PANE_FOCUSED; wp->flags |= PANE_FOCUSED;
} }