Make refresh-client force update of jobs, from Sina Siadat.

This commit is contained in:
nicm 2015-09-14 10:25:52 +00:00
parent 901c2eb20a
commit 16efa84838
5 changed files with 26 additions and 12 deletions

View File

@ -65,10 +65,13 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
} }
if (tty_set_size(&c->tty, w, h)) if (tty_set_size(&c->tty, w, h))
recalculate_sizes(); recalculate_sizes();
} else if (args_has(args, 'S')) } else if (args_has(args, 'S')) {
c->flags |= CLIENT_STATUSFORCE;
server_status_client(c); server_status_client(c);
else } else {
c->flags |= CLIENT_STATUSFORCE;
server_redraw_client(c); server_redraw_client(c);
}
return (CMD_RETURN_NORMAL); return (CMD_RETURN_NORMAL);
} }

View File

@ -104,7 +104,7 @@ struct format_tree {
struct session *s; struct session *s;
struct window_pane *wp; struct window_pane *wp;
int status; int flags;
RB_HEAD(format_entry_tree, format_entry) tree; RB_HEAD(format_entry_tree, format_entry) tree;
}; };
@ -216,27 +216,31 @@ const char *
format_job_get(struct format_tree *ft, const char *cmd) format_job_get(struct format_tree *ft, const char *cmd)
{ {
struct format_job fj0, *fj; struct format_job fj0, *fj;
time_t t;
fj0.cmd = cmd; fj0.cmd = cmd;
if ((fj = RB_FIND(format_job_tree, &format_jobs, &fj0)) == NULL) { if ((fj = RB_FIND(format_job_tree, &format_jobs, &fj0)) == NULL) {
fj = xcalloc(1, sizeof *fj); fj = xcalloc(1, sizeof *fj);
fj->cmd = xstrdup(cmd); fj->cmd = xstrdup(cmd);
fj->status = ft->status;
xasprintf(&fj->out, "<'%s' not ready>", fj->cmd); xasprintf(&fj->out, "<'%s' not ready>", fj->cmd);
RB_INSERT(format_job_tree, &format_jobs, fj); 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, fj->job = job_run(fj->cmd, NULL, -1, format_job_callback,
NULL, fj); NULL, fj);
if (fj->job == NULL) { if (fj->job == NULL) {
free(fj->out); free(fj->out);
xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd); 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); return (fj->out);
} }
@ -438,12 +442,12 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe)
struct format_tree * struct format_tree *
format_create(void) format_create(void)
{ {
return (format_create_status(0)); return (format_create_flags(0));
} }
/* Create a new tree for the status line. */ /* Create a new tree for the status line. */
struct format_tree * struct format_tree *
format_create_status(int status) format_create_flags(int flags)
{ {
struct format_tree *ft; struct format_tree *ft;
@ -454,7 +458,7 @@ format_create_status(int status)
ft = xcalloc(1, sizeof *ft); ft = xcalloc(1, sizeof *ft);
RB_INIT(&ft->tree); RB_INIT(&ft->tree);
ft->status = status; ft->flags = flags;
format_add_cb(ft, "host", format_cb_host); format_add_cb(ft, "host", format_cb_host);
format_add_cb(ft, "host_short", format_cb_host_short); format_add_cb(ft, "host_short", format_cb_host_short);

View File

@ -937,7 +937,8 @@ server_client_check_redraw(struct client *c)
tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags; tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
tty_update_mode(tty, tty->mode, NULL); 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. */ /* Set client title. */

View File

@ -503,7 +503,10 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
if (fmt == NULL) if (fmt == NULL)
return (xstrdup("")); 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); format_defaults(ft, c, NULL, wl, NULL);
expanded = format_expand_time(ft, fmt, t); expanded = format_expand_time(ft, fmt, t);

5
tmux.h
View File

@ -1220,6 +1220,7 @@ struct client {
#define CLIENT_UTF8 0x10000 #define CLIENT_UTF8 0x10000
#define CLIENT_256COLOURS 0x20000 #define CLIENT_256COLOURS 0x20000
#define CLIENT_IDENTIFIED 0x40000 #define CLIENT_IDENTIFIED 0x40000
#define CLIENT_STATUSFORCE 0x80000
int flags; int flags;
struct key_table *keytable; 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); char *paste_make_sample(struct paste_buffer *, int);
/* format.c */ /* format.c */
#define FORMAT_STATUS 0x1
#define FORMAT_FORCE 0x2
struct format_tree; struct format_tree;
struct format_tree *format_create(void); 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 format_free(struct format_tree *);
void printflike(3, 4) format_add(struct format_tree *, const char *, void printflike(3, 4) format_add(struct format_tree *, const char *,
const char *, ...); const char *, ...);