summaryrefslogtreecommitdiffstats
path: root/cmd-set-window-option.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-11-19 22:35:10 +0000
committerTiago Cunha <tcunha@gmx.com>2009-11-19 22:35:10 +0000
commitf9451028c0a7d3d53aa3aa2549bd9d632e9fc3b1 (patch)
tree3d17ba79b17cfa05ba90112f7209014249ce7af7 /cmd-set-window-option.c
parent1feea926ed83c15232df01756aed771afd7168f2 (diff)
Sync OpenBSD patchset 553:
Two new options, window-status-format and window-status-current-format, which allow the format of each window in the status line window list to be controlled using similar # sequences as status-left/right. This diff also moves part of the way towards UTF-8 support in window names but it isn't quite there yet.
Diffstat (limited to 'cmd-set-window-option.c')
-rw-r--r--cmd-set-window-option.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c
index baf8d656..a66ff5dd 100644
--- a/cmd-set-window-option.c
+++ b/cmd-set-window-option.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-set-window-option.c,v 1.41 2009-11-14 17:56:39 tcunha Exp $ */
+/* $Id: cmd-set-window-option.c,v 1.42 2009-11-19 22:35:10 tcunha Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -71,7 +71,9 @@ const struct set_option_entry set_window_option_table[] = {
{ "window-status-current-attr", SET_OPTION_ATTRIBUTES, 0, 0, NULL },
{ "window-status-current-bg", SET_OPTION_COLOUR, 0, 0, NULL },
{ "window-status-current-fg", SET_OPTION_COLOUR, 0, 0, NULL },
+ { "window-status-current-format", SET_OPTION_STRING, 0, 0, NULL },
{ "window-status-fg", SET_OPTION_COLOUR, 0, 0, NULL },
+ { "window-status-format", SET_OPTION_STRING, 0, 0, NULL },
{ "xterm-keys", SET_OPTION_FLAG, 0, 0, NULL },
{ NULL, 0, 0, 0, NULL }
};
@@ -84,7 +86,10 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
struct client *c;
struct options *oo;
const struct set_option_entry *entry, *opt;
+ struct jobs *jobs;
+ struct job *job, *nextjob;
u_int i;
+ int try_again;
if (cmd_check_flag(data->chflags, 'g'))
oo = &global_w_options;
@@ -166,5 +171,34 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
server_redraw_client(c);
}
+ /*
+ * Special-case: kill all persistent jobs if window-status-format has
+ * changed. Persistent jobs are only used by the status line at the
+ * moment so this works XXX.
+ */
+ if (strcmp(entry->name, "window-status-format") == 0) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session == NULL)
+ continue;
+
+ jobs = &c->status_jobs;
+ do {
+ try_again = 0;
+ job = RB_ROOT(jobs);
+ while (job != NULL) {
+ nextjob = RB_NEXT(jobs, jobs, job);
+ if (job->flags & JOB_PERSIST) {
+ job_remove(jobs, job);
+ try_again = 1;
+ break;
+ }
+ job = nextjob;
+ }
+ } while (try_again);
+ server_redraw_client(c);
+ }
+ }
+
return (0);
}