aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-02-06 19:05:56 +0000
committerThomas Adam <thomas@xteddy.org>2015-02-06 19:07:43 +0000
commit833fe5bdee449b04afe8844774be66374e1baf9c (patch)
tree11b21f479421b08f67776c832543becaa0b12fb8
parent93c3fb78a3593afd23e85352213236131dd5958f (diff)
parent313f2263f8bb3336893527f65789f820ba7eaf0f (diff)
downloadrtmux-833fe5bdee449b04afe8844774be66374e1baf9c.tar.gz
rtmux-833fe5bdee449b04afe8844774be66374e1baf9c.tar.bz2
rtmux-833fe5bdee449b04afe8844774be66374e1baf9c.zip
Merge branch 'obsd-master'
Conflicts: cmd-pipe-pane.c
-rw-r--r--cmd-attach-session.c14
-rw-r--r--cmd-break-pane.c7
-rw-r--r--cmd-choose-buffer.c2
-rw-r--r--cmd-choose-client.c3
-rw-r--r--cmd-detach-client.c47
-rw-r--r--cmd-display-message.c6
-rw-r--r--cmd-find-window.c4
-rw-r--r--cmd-if-shell.c7
-rw-r--r--cmd-list-buffers.c2
-rw-r--r--cmd-list-clients.c3
-rw-r--r--cmd-list-panes.c4
-rw-r--r--cmd-list-sessions.c2
-rw-r--r--cmd-list-windows.c4
-rw-r--r--cmd-new-session.c9
-rw-r--r--cmd-new-window.c15
-rw-r--r--cmd-pipe-pane.c23
-rw-r--r--cmd-queue.c23
-rw-r--r--cmd-run-shell.c7
-rw-r--r--cmd-split-window.c15
-rw-r--r--control-notify.c2
-rw-r--r--environ.c7
-rw-r--r--format.c78
-rw-r--r--input.c12
-rw-r--r--names.c4
-rw-r--r--options-table.c70
-rw-r--r--screen-redraw.c2
-rw-r--r--server-client.c14
-rw-r--r--status.c99
-rw-r--r--tmux.134
-rw-r--r--tmux.c5
-rw-r--r--tmux.h20
-rw-r--r--tty-term.c1
-rw-r--r--tty.c16
-rw-r--r--window-choose.c6
-rw-r--r--window-copy.c4
35 files changed, 306 insertions, 265 deletions
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 160f2a8f..a67ec82c 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -106,11 +106,8 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
if (cflag != NULL) {
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, s->curw);
- format_window_pane(ft, s->curw->window->active);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
+ NULL, NULL);
cp = format_expand(ft, cflag);
format_free(ft);
@@ -139,11 +136,8 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
if (cflag != NULL) {
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, s->curw);
- format_window_pane(ft, s->curw->window->active);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s,
+ NULL, NULL);
cp = format_expand(ft, cflag);
format_free(ft);
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index 0025167f..a1da0a3a 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -49,7 +49,6 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
char *name;
char *cause;
int base_idx;
- struct client *c;
struct format_tree *ft;
const char *template;
char *cp;
@@ -90,11 +89,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
template = BREAK_PANE_TEMPLATE;
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wp);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl, wp);
cp = format_expand(ft, template);
cmdq_print(cmdq, "%s", cp);
diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c
index 19f5fba2..33125a0e 100644
--- a/cmd-choose-buffer.c
+++ b/cmd-choose-buffer.c
@@ -83,7 +83,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
cdata->idx = idx;
cdata->ft_template = xstrdup(template);
- format_paste_buffer(cdata->ft, pb, utf8flag);
+ format_defaults_paste_buffer(cdata->ft, pb, utf8flag);
xasprintf(&action_data, "%s", pb->name);
cdata->command = cmd_template_replace(action, action_data, 1);
diff --git a/cmd-choose-client.c b/cmd-choose-client.c
index 5a1892f4..3002f7ba 100644
--- a/cmd-choose-client.c
+++ b/cmd-choose-client.c
@@ -94,8 +94,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_q *cmdq)
cdata->ft_template = xstrdup(template);
format_add(cdata->ft, "line", "%u", i);
- format_session(cdata->ft, c1->session);
- format_client(cdata->ft, c1);
+ format_defaults(cdata->ft, c1, NULL, NULL, NULL);
cdata->command = cmd_template_replace(action, c1->tty.path, 1);
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
index 600554a4..7f87d2c6 100644
--- a/cmd-detach-client.c
+++ b/cmd-detach-client.c
@@ -48,7 +48,7 @@ enum cmd_retval
cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
- struct client *c, *c2;
+ struct client *c, *cloop;
struct session *s;
enum msgtype msgtype;
u_int i;
@@ -73,32 +73,35 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session != s)
+ cloop = ARRAY_ITEM(&clients, i);
+ if (cloop == NULL || cloop->session != s)
continue;
- server_write_client(c, msgtype, c->session->name,
- strlen(c->session->name) + 1);
+ server_write_client(cloop, msgtype,
+ cloop->session->name,
+ strlen(cloop->session->name) + 1);
}
- } else {
- c = cmd_find_client(cmdq, args_get(args, 't'), 0);
- if (c == NULL)
- return (CMD_RETURN_ERROR);
+ return (CMD_RETURN_STOP);
+ }
- if (args_has(args, 'a')) {
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c2 = ARRAY_ITEM(&clients, i);
- if (c2 == NULL || c2->session == NULL ||
- c2 == c)
- continue;
- server_write_client(c2, msgtype,
- c2->session->name,
- strlen(c2->session->name) + 1);
- }
- } else {
- server_write_client(c, msgtype, c->session->name,
- strlen(c->session->name) + 1);
+ c = cmd_find_client(cmdq, args_get(args, 't'), 0);
+ if (c == NULL)
+ return (CMD_RETURN_ERROR);
+
+ if (args_has(args, 'a')) {
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ cloop = ARRAY_ITEM(&clients, i);
+ if (cloop == NULL || cloop->session == NULL)
+ continue;
+ if (cloop == c)
+ continue;
+ server_write_client(cloop, msgtype,
+ cloop->session->name,
+ strlen(cloop->session->name) + 1);
}
+ return (CMD_RETURN_NORMAL);
}
+ server_write_client(c, msgtype, c->session->name,
+ strlen(c->session->name) + 1);
return (CMD_RETURN_STOP);
}
diff --git a/cmd-display-message.c b/cmd-display-message.c
index f3547b00..0a61fd1e 100644
--- a/cmd-display-message.c
+++ b/cmd-display-message.c
@@ -92,11 +92,7 @@ cmd_display_message_exec(struct cmd *self, struct cmd_q *cmdq)
template = DISPLAY_MESSAGE_TEMPLATE;
ft = format_create();
- if (c != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wp);
+ format_defaults(ft, c, s, wl, wp);
t = time(NULL);
len = strftime(out, sizeof out, template, localtime(&t));
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 88e48798..25155f7b 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -194,9 +194,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_q *cmdq)
format_add(cdata->ft, "line", "%u", i);
format_add(cdata->ft, "window_find_matches", "%s",
ARRAY_ITEM(&find_list, i).list_ctx);
- format_session(cdata->ft, s);
- format_winlink(cdata->ft, s, wm);
- format_window_pane(cdata->ft, wm->window->active);
+ format_defaults(cdata->ft, NULL, s, wm, NULL);
window_choose_add(wl->window->active, cdata);
}
diff --git a/cmd-if-shell.c b/cmd-if-shell.c
index 15432919..8c6620da 100644
--- a/cmd-if-shell.c
+++ b/cmd-if-shell.c
@@ -76,12 +76,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_q *cmdq)
}
ft = format_create();
- if (s != NULL)
- format_session(ft, s);
- if (s != NULL && wl != NULL)
- format_winlink(ft, s, wl);
- if (wp != NULL)
- format_window_pane(ft, wp);
+ format_defaults(ft, NULL, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);
diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c
index 8eb1610f..37571b80 100644
--- a/cmd-list-buffers.c
+++ b/cmd-list-buffers.c
@@ -55,7 +55,7 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
pb = NULL;
while ((pb = paste_walk(pb)) != NULL) {
ft = format_create();
- format_paste_buffer(ft, pb, 0);
+ format_defaults_paste_buffer(ft, pb, 0);
line = format_expand(ft, template);
cmdq_print(cmdq, "%s", line);
diff --git a/cmd-list-clients.c b/cmd-list-clients.c
index 292be722..893a6d05 100644
--- a/cmd-list-clients.c
+++ b/cmd-list-clients.c
@@ -74,8 +74,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_q *cmdq)
ft = format_create();
format_add(ft, "line", "%u", i);
- format_session(ft, c->session);
- format_client(ft, c);
+ format_defaults(ft, c, NULL, NULL, NULL);
line = format_expand(ft, template);
cmdq_print(cmdq, "%s", line);
diff --git a/cmd-list-panes.c b/cmd-list-panes.c
index 7f62177b..bd34344f 100644
--- a/cmd-list-panes.c
+++ b/cmd-list-panes.c
@@ -128,9 +128,7 @@ cmd_list_panes_window(struct cmd *self,
TAILQ_FOREACH(wp, &wl->window->panes, entry) {
ft = format_create();
format_add(ft, "line", "%u", n);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wp);
+ format_defaults(ft, NULL, s, wl, wp);
line = format_expand(ft, template);
cmdq_print(cmdq, "%s", line);
diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c
index ea8f3e32..8ad55d03 100644
--- a/cmd-list-sessions.c
+++ b/cmd-list-sessions.c
@@ -63,7 +63,7 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_q *cmdq)
RB_FOREACH(s, sessions, &sessions) {
ft = format_create();
format_add(ft, "line", "%u", n);
- format_session(ft, s);
+ format_defaults(ft, NULL, s, NULL, NULL);
line = format_expand(ft, template);
cmdq_print(cmdq, "%s", line);
diff --git a/cmd-list-windows.c b/cmd-list-windows.c
index 5f73e8d2..3f6b2a4c 100644
--- a/cmd-list-windows.c
+++ b/cmd-list-windows.c
@@ -107,9 +107,7 @@ cmd_list_windows_session(
RB_FOREACH(wl, winlinks, &s->windows) {
ft = format_create();
format_add(ft, "line", "%u", n);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wl->window->active);
+ format_defaults(ft, NULL, s, wl, NULL);
line = format_expand(ft, template);
cmdq_print(cmdq, "%s", line);
diff --git a/cmd-new-session.c b/cmd-new-session.c
index e244f885..ec292fa8 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -119,8 +119,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
/* Get the new session working directory. */
if (args_has(args, 'c')) {
ft = format_create();
- if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c0);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), NULL, NULL,
+ NULL);
cp = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -287,9 +287,8 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
template = NEW_SESSION_TEMPLATE;
ft = format_create();
- if ((c0 = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c0);
- format_session(ft, s);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
+ NULL);
cp = format_expand(ft, template);
cmdq_print(cmdq, "%s", cp);
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 7f14b21a..c05a0ce8 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -49,7 +49,6 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
struct args *args = self->args;
struct session *s;
struct winlink *wl;
- struct client *c;
const char *cmd, *path, *template;
char **argv, *cause, *cp;
int argc, idx, last, detached, cwd, fd = -1;
@@ -109,11 +108,8 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(args, 'c')) {
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, s->curw);
- format_window_pane(ft, s->curw->window->active);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
+ NULL);
cp = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -173,11 +169,8 @@ cmd_new_window_exec(struct cmd *self, struct cmd_q *cmdq)
template = NEW_WINDOW_TEMPLATE;
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, wl->window->active);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
+ NULL);
cp = format_expand(ft, template);
cmdq_print(cmdq, "%s", cp);
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index 4ab1824e..df706432 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -21,6 +21,8 @@
#include <errno.h>
#include <fcntl.h>
+#include <paths.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -48,11 +50,14 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct client *c;
+ struct session *s;
+ struct winlink *wl;
struct window_pane *wp;
- char *command;
+ char *cmd;
int old_fd, pipe_fd[2], null_fd;
+ struct format_tree *ft;
- if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
+ if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
return (CMD_RETURN_ERROR);
c = cmd_find_client(cmdq, NULL, 1);
@@ -83,10 +88,18 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
+ /* Expand the command. */
+ ft = format_create();
+ format_defaults(ft, c, s, wl, wp);
+ cmd = format_expand_time(ft, args->argv[0], time(NULL));
+ format_free(ft);
+
/* Fork the child. */
switch (fork()) {
case -1:
cmdq_error(cmdq, "fork error: %s", strerror(errno));
+
+ free(cmd);
return (CMD_RETURN_ERROR);
case 0:
/* Child process. */
@@ -108,9 +121,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
closefrom(STDERR_FILENO + 1);
- command = status_replace(
- c, NULL, NULL, NULL, args->argv[0], time(NULL), 0);
- execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
+ execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
_exit(1);
default:
/* Parent process. */
@@ -124,6 +135,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
bufferevent_enable(wp->pipe_event, EV_WRITE);
setblocking(wp->pipe_fd, 0);
+
+ free(cmd);
return (CMD_RETURN_NORMAL);
}
}
diff --git a/cmd-queue.c b/cmd-queue.c
index a98fa9b6..58282c8f 100644
--- a/cmd-queue.c
+++ b/cmd-queue.c
@@ -117,20 +117,17 @@ cmdq_error(struct cmd_q *cmdq, const char *fmt, ...)
}
/* Print a guard line. */
-int
+void
cmdq_guard(struct cmd_q *cmdq, const char *guard, int flags)
{
struct client *c = cmdq->client;
- if (c == NULL)
- return (0);
- if (!(c->flags & CLIENT_CONTROL))
- return (0);
+ if (c == NULL || !(c->flags & CLIENT_CONTROL))
+ return;
evbuffer_add_printf(c->stdout_data, "%%%s %ld %u %d\n", guard,
(long) cmdq->time, cmdq->number, flags);
server_push_stdout(c);
- return (1);
}
/* Add command list to queue and begin processing if needed. */
@@ -163,7 +160,7 @@ cmdq_continue(struct cmd_q *cmdq)
{
struct cmd_q_item *next;
enum cmd_retval retval;
- int empty, guard, flags;
+ int empty, flags;
char s[1024];
notify_disable();
@@ -188,16 +185,14 @@ cmdq_continue(struct cmd_q *cmdq)
cmdq->number++;
flags = !!(cmdq->cmd->flags & CMD_CONTROL);
- guard = cmdq_guard(cmdq, "begin", flags);
+ cmdq_guard(cmdq, "begin", flags);
retval = cmdq->cmd->entry->exec(cmdq->cmd, cmdq);
- if (guard) {
- if (retval == CMD_RETURN_ERROR)
- cmdq_guard(cmdq, "error", flags);
- else
- cmdq_guard(cmdq, "end", flags);
- }
+ if (retval == CMD_RETURN_ERROR)
+ cmdq_guard(cmdq, "error", flags);
+ else
+ cmdq_guard(cmdq, "end", flags);
if (retval == CMD_RETURN_ERROR)
break;
diff --git a/cmd-run-shell.c b/cmd-run-shell.c
index b47c2827..5d6d178b 100644
--- a/cmd-run-shell.c
+++ b/cmd-run-shell.c
@@ -93,12 +93,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_q *cmdq)
}
ft = format_create();
- if (s != NULL)
- format_session(ft, s);
- if (s != NULL && wl != NULL)
- format_winlink(ft, s, wl);
- if (wp != NULL)
- format_window_pane(ft, wp);
+ format_defaults(ft, NULL, s, wl, wp);
shellcmd = format_expand(ft, args->argv[0]);
format_free(ft);
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 6b901254..1e7bc16a 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -58,7 +58,6 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
int argc, size, percentage, cwd, fd = -1;
enum layout_type type;
struct layout_cell *lc;
- struct client *c;
struct format_tree *ft;
struct environ_entry *envent;
@@ -88,11 +87,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(args, 'c')) {
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, s->curw);
- format_window_pane(ft, s->curw->window->active);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, NULL,
+ NULL);
cp = format_expand(ft, args_get(args, 'c'));
format_free(ft);
@@ -180,11 +176,8 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
template = SPLIT_WINDOW_TEMPLATE;
ft = format_create();
- if ((c = cmd_find_client(cmdq, NULL, 1)) != NULL)
- format_client(ft, c);
- format_session(ft, s);
- format_winlink(ft, s, wl);
- format_window_pane(ft, new_wp);
+ format_defaults(ft, cmd_find_client(cmdq, NULL, 1), s, wl,
+ new_wp);
cp = format_expand(ft, template);
cmdq_print(cmdq, "%s", cp);
diff --git a/control-notify.c b/control-notify.c
index 4ea1570b..747ef5b4 100644
--- a/control-notify.c
+++ b/control-notify.c
@@ -88,7 +88,7 @@ control_notify_window_layout_changed(struct window *w)
ft = format_create();
wl = winlink_find_by_window(&s->windows, w);
if (wl != NULL) {
- format_winlink(ft, c->session, wl);
+ format_defaults(ft, c, NULL, wl, NULL);
control_write(c, "%s", format_expand(ft, template));
}
format_free(ft);
diff --git a/environ.c b/environ.c
index 284f8b55..0dd91783 100644
--- a/environ.c
+++ b/environ.c
@@ -168,8 +168,11 @@ environ_push(struct environ *env)
var[strcspn(var, "=")] = '\0';
ARRAY_ADD(&varlist, var);
}
- for (i = 0; i < ARRAY_LENGTH(&varlist); i++)
- unsetenv(ARRAY_ITEM(&varlist, i));
+ for (i = 0; i < ARRAY_LENGTH(&varlist); i++) {
+ var = ARRAY_ITEM(&varlist, i);
+ unsetenv(var);
+ free(var);
+ }
ARRAY_FREE(&varlist);
RB_FOREACH(envent, environ, env) {
diff --git a/format.c b/format.c
index aecb9280..776de960 100644
--- a/format.c
+++ b/format.c
@@ -39,7 +39,12 @@
int format_replace(struct format_tree *, const char *, size_t, char **,
size_t *, size_t *);
char *format_get_command(struct window_pane *);
-void format_window_pane_tabs(struct format_tree *, struct window_pane *);
+
+void format_defaults_pane_tabs(struct format_tree *, struct window_pane *);
+void format_defaults_session(struct format_tree *, struct session *);
+void format_defaults_client(struct format_tree *, struct client *);
+void format_defaults_winlink(struct format_tree *, struct session *,
+ struct winlink *);
/* Entry in format tree. */
struct format_entry {
@@ -322,6 +327,33 @@ fail:
return (-1);
}
+/* Expand keys in a template, passing through strftime first. */
+char *
+format_expand_time(struct format_tree *ft, const char *fmt, time_t t)
+{
+ char *tmp, *expanded;
+ size_t tmplen;
+ struct tm *tm;
+
+ if (fmt == NULL)
+ return (xstrdup(""));
+
+ tm = localtime(&t);
+
+ tmp = NULL;
+ tmplen = strlen(fmt);
+
+ do {
+ tmp = xreallocarray(tmp, 2, tmplen);
+ tmplen *= 2;
+ } while (strftime(tmp, tmplen, fmt, tm) == 0);
+
+ expanded = format_expand(ft, tmp);
+ free(tmp);
+
+ return (expanded);
+}
+
/* Expand keys in a template. */
char *
format_expand(struct format_tree *ft, const char *fmt)
@@ -331,6 +363,9 @@ format_expand(struct format_tree *ft, const char *fmt)
size_t off, len, n;
int ch, brackets;
+ if (fmt == NULL)
+ return (xstrdup(""));
+
len = 64;
buf = xmalloc(len);
off = 0;
@@ -419,9 +454,31 @@ format_get_command(struct window_pane *wp)
return (out);
}
+/* Set defaults for any of arguments that are not NULL. */
+void
+format_defaults(struct format_tree *ft, struct client *c, struct session *s,
+ struct winlink *wl, struct window_pane *wp)
+{
+ if (s == NULL && c != NULL)
+ s = c->session;
+ if (wl == NULL && s != NULL)
+ wl = s->curw;
+ if (wp == NULL && wl != NULL)
+ wp = wl->window->active;
+
+ if (c != NULL)
+ format_defaults_client(ft, c);
+ if (s != NULL)
+ format_defaults_session(ft, s);
+ if (s != NULL && wl != NULL)
+ format_defaults_winlink(ft, s, wl);
+ if (wp != NULL)
+ format_defaults_pane(ft, wp);
+}
+
/* Set default format keys for a session. */
void
-format_session(struct format_tree *ft, struct session *s)
+format_defaults_session(struct format_tree *ft, struct session *s)
{
struct session_group *sg;
char *tim;
@@ -452,7 +509,7 @@ format_session(struct format_tree *ft, struct session *s)
/* Set default format keys for a client. */
void
-format_client(struct format_tree *ft, struct client *c)
+format_defaults_client(struct format_tree *ft, struct client *c)
{
char *tim;
time_t t;
@@ -502,7 +559,7 @@ format_client(struct format_tree *ft, struct client *c)
/* Set default format keys for a window. */
void
-format_window(struct format_tree *ft, struct window *w)
+format_defaults_window(struct format_tree *ft, struct window *w)
{
char *layout;
@@ -524,7 +581,8 @@ format_window(struct format_tree *ft, struct window *w)
/* Set default format keys for a winlink. */
void
-format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
+format_defaults_winlink(struct format_tree *ft, struct session *s,
+ struct winlink *wl)
{
struct window *w = wl->window;
char *flags;
@@ -534,7 +592,7 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
flags = window_printable_flags(s, wl);
- format_window(ft, w);
+ format_defaults_window(ft, w);
format_add(ft, "window_index", "%d", wl->idx);
format_add(ft, "window_flags", "%s", flags);
@@ -554,7 +612,7 @@ format_winlink(struct format_tree *ft, struct session *s, struct winlink *wl)
/* Add window pane tabs. */
void
-format_window_pane_tabs(struct format_tree *ft, struct window_pane *wp)
+format_defaults_pane_tabs(struct format_tree *ft, struct window_pane *wp)
{
struct evbuffer *buffer;
u_int i;
@@ -576,7 +634,7 @@ format_window_pane_tabs(struct format_tree *ft, struct window_pane *wp)
/* Set default format keys for a window pane. */
void
-format_window_pane(struct format_tree *ft, struct window_pane *wp)
+format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
{
struct grid *gd = wp->base.grid;
struct grid_line *gl;
@@ -668,12 +726,12 @@ format_window_pane(struct format_tree *ft, struct window_pane *wp)
format_add(ft, "mouse_utf8_flag", "%d",
!!(wp->base.mode & MODE_MOUSE_UTF8));
- format_window_pane_tabs(ft, wp);
+ format_defaults_pane_tabs(ft, wp);
}
/* Set default format keys for paste buffer. */
void
-format_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
+format_defaults_paste_buffer(struct format_tree *ft, struct paste_buffer *pb,
int utf8flag)
{
char *s;
diff --git a/input.c b/input.c
index fcc91180..de11f629 100644
--- a/input.c
+++ b/input.c
@@ -1342,6 +1342,9 @@ input_csi_dispatch_rm(struct input_ctx *ictx)
case 4: /* IRM */
screen_write_mode_clear(&ictx->ctx, MODE_INSERT);
break;
+ case 34:
+ screen_write_mode_set(&ictx->ctx, MODE_BLINKING);
+ break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
@@ -1368,6 +1371,9 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx)
case 7: /* DECAWM */
screen_write_mode_clear(&ictx->ctx, MODE_WRAP);
break;
+ case 12:
+ screen_write_mode_clear(&ictx->ctx, MODE_BLINKING);
+ break;
case 25: /* TCEM */
screen_write_mode_clear(&ictx->ctx, MODE_CURSOR);
break;
@@ -1413,6 +1419,9 @@ input_csi_dispatch_sm(struct input_ctx *ictx)
case 4: /* IRM */
screen_write_mode_set(&ictx->ctx, MODE_INSERT);
break;
+ case 34:
+ screen_write_mode_clear(&ictx->ctx, MODE_BLINKING);
+ break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
break;
@@ -1439,6 +1448,9 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
case 7: /* DECAWM */
screen_write_mode_set(&ictx->ctx, MODE_WRAP);
break;
+ case 12:
+ screen_write_mode_set(&ictx->ctx, MODE_BLINKING);
+ break;
case 25: /* TCEM */
screen_write_mode_set(&ictx->ctx, MODE_CURSOR);
break;
diff --git a/names.c b/names.c
index 8e01d347..1ceb83c0 100644
--- a/names.c
+++ b/names.c
@@ -86,8 +86,8 @@ format_window_name(struct window *w)
char *fmt, *name;
ft = format_create();
- format_window(ft, w);
- format_window_pane(ft, w->active);
+ format_defaults_window(ft, w);
+ format_defaults_pane(ft, w->active);
fmt = options_get_string(&w->options, "automatic-rename-format");
name = format_expand(ft, fmt);
diff --git a/options-table.c b/options-table.c
index 2b123248..2bcf29b4 100644
--- a/options-table.c
+++ b/options-table.c
@@ -274,40 +274,6 @@ const struct options_table_entry session_options_table[] = {
.default_num = 0
},
- { .name = "pane-active-border-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .default_num = 8,
- .style = "pane-active-border-style"
- },
-
- { .nam