From 16efa8483888e326aed2c05a01b63b45a2b118ef Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 14 Sep 2015 10:25:52 +0000 Subject: [PATCH] Make refresh-client force update of jobs, from Sina Siadat. --- cmd-refresh-client.c | 7 +++++-- format.c | 18 +++++++++++------- server-client.c | 3 ++- status.c | 5 ++++- tmux.h | 5 ++++- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index b6d5d624..5a45ec25 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -65,10 +65,13 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq) } if (tty_set_size(&c->tty, w, h)) recalculate_sizes(); - } else if (args_has(args, 'S')) + } else if (args_has(args, 'S')) { + c->flags |= CLIENT_STATUSFORCE; server_status_client(c); - else + } else { + c->flags |= CLIENT_STATUSFORCE; server_redraw_client(c); + } return (CMD_RETURN_NORMAL); } diff --git a/format.c b/format.c index c401fa35..2fae8da0 100644 --- a/format.c +++ b/format.c @@ -104,7 +104,7 @@ struct format_tree { struct session *s; struct window_pane *wp; - int status; + int flags; RB_HEAD(format_entry_tree, format_entry) tree; }; @@ -216,27 +216,31 @@ const char * format_job_get(struct format_tree *ft, const char *cmd) { struct format_job fj0, *fj; + time_t t; fj0.cmd = cmd; if ((fj = RB_FIND(format_job_tree, &format_jobs, &fj0)) == NULL) { fj = xcalloc(1, sizeof *fj); fj->cmd = xstrdup(cmd); - fj->status = ft->status; xasprintf(&fj->out, "<'%s' not ready>", fj->cmd); RB_INSERT(format_job_tree, &format_jobs, fj); } - if (fj->job == NULL && fj->last != time(NULL)) { + t = time(NULL); + if (fj->job == NULL && ((ft->flags & FORMAT_FORCE) || fj->last != t)) { fj->job = job_run(fj->cmd, NULL, -1, format_job_callback, NULL, fj); if (fj->job == NULL) { free(fj->out); xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd); } + fj->last = t; } - fj->last = time(NULL); + + if (ft->flags & FORMAT_STATUS) + fj->status = 1; return (fj->out); } @@ -438,12 +442,12 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe) struct format_tree * format_create(void) { - return (format_create_status(0)); + return (format_create_flags(0)); } /* Create a new tree for the status line. */ struct format_tree * -format_create_status(int status) +format_create_flags(int flags) { struct format_tree *ft; @@ -454,7 +458,7 @@ format_create_status(int status) ft = xcalloc(1, sizeof *ft); RB_INIT(&ft->tree); - ft->status = status; + ft->flags = flags; format_add_cb(ft, "host", format_cb_host); format_add_cb(ft, "host_short", format_cb_host_short); diff --git a/server-client.c b/server-client.c index 70f5adcb..6669bf05 100644 --- a/server-client.c +++ b/server-client.c @@ -937,7 +937,8 @@ server_client_check_redraw(struct client *c) tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags; tty_update_mode(tty, tty->mode, NULL); - c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS); + c->flags &= ~(CLIENT_REDRAW|CLIENT_BORDERS|CLIENT_STATUS| + CLIENT_STATUSFORCE); } /* Set client title. */ diff --git a/status.c b/status.c index 29cb686c..7a1d2818 100644 --- a/status.c +++ b/status.c @@ -503,7 +503,10 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t) if (fmt == NULL) return (xstrdup("")); - ft = format_create_status(1); + if (c->flags & CLIENT_STATUSFORCE) + ft = format_create_flags(FORMAT_STATUS|FORMAT_FORCE); + else + ft = format_create_flags(FORMAT_STATUS); format_defaults(ft, c, NULL, wl, NULL); expanded = format_expand_time(ft, fmt, t); diff --git a/tmux.h b/tmux.h index 080d670d..e5523418 100644 --- a/tmux.h +++ b/tmux.h @@ -1220,6 +1220,7 @@ struct client { #define CLIENT_UTF8 0x10000 #define CLIENT_256COLOURS 0x20000 #define CLIENT_IDENTIFIED 0x40000 +#define CLIENT_STATUSFORCE 0x80000 int flags; struct key_table *keytable; @@ -1442,9 +1443,11 @@ int paste_set(char *, size_t, const char *, char **); char *paste_make_sample(struct paste_buffer *, int); /* format.c */ +#define FORMAT_STATUS 0x1 +#define FORMAT_FORCE 0x2 struct format_tree; struct format_tree *format_create(void); -struct format_tree *format_create_status(int); +struct format_tree *format_create_flags(int); void format_free(struct format_tree *); void printflike(3, 4) format_add(struct format_tree *, const char *, const char *, ...);