The branch, master has been updated
via 833fe5bdee449b04afe8844774be66374e1baf9c (commit)
via 313f2263f8bb3336893527f65789f820ba7eaf0f (commit)
via 8d94bb67abe0e83571bc5c0875755a40ea9c9039 (commit)
via 03758a50dc21b7c77b75f689d06f81292266c20a (commit)
via 83a8e1fd20e3cbd6da38d0b4d6973cad0484c27b (commit)
via 90bf7026f6bb83e0781ff2fc71c32ce973edce59 (commit)
via f1e68bfdd22dc1fa13630cb64855506643e01c5c (commit)
via 4946f74253de52f10beb023d4c5b88bafdb11ec4 (commit)
via e5d9ceff18e37320b9243d24204a0a79d77172e4 (commit)
via c9642ee21367f0bf2b17b423d7155c88138aa9fc (commit)
via 4e03239d1f2edc4f2d9f90c2bb28d609b64ea566 (commit)
via 144025e3e6ecd5503326a674de70075851e54a85 (commit)
via adcc71d4d5d338d0f7d13867e59a11741eb36afa (commit)
via c38f0d85da44d83ea69c6586a1aef428d9f489d0 (commit)
via f9c7f9a17aaf05f4303f66982f6cf33ad03f9714 (commit)
via 16bdd970dcc68e50f26c512b3ead628b9b899c88 (commit)
via d45150267656530b8503375555a1814fcfe6a15a (commit)
from 93c3fb78a3593afd23e85352213236131dd5958f (commit)
- Log -----------------------------------------------------------------
commit 833fe5bdee449b04afe8844774be66374e1baf9c
Merge: 93c3fb7 313f226
Author: Thomas Adam <[email protected]>
Commit: Thomas Adam <[email protected]>
Merge branch 'obsd-master'
Conflicts:
cmd-pipe-pane.c
cmd-attach-session.c | 14 ++-----
cmd-break-pane.c | 7 +---
cmd-choose-buffer.c | 2 +-
cmd-choose-client.c | 3 +-
cmd-detach-client.c | 47 ++++++++++++-----------
cmd-display-message.c | 6 +--
cmd-find-window.c | 4 +-
cmd-if-shell.c | 7 +---
cmd-list-buffers.c | 2 +-
cmd-list-clients.c | 3 +-
cmd-list-panes.c | 4 +-
cmd-list-sessions.c | 2 +-
cmd-list-windows.c | 4 +-
cmd-new-session.c | 9 ++--
cmd-new-window.c | 15 ++-----
cmd-pipe-pane.c | 23 +++++++++--
cmd-queue.c | 23 ++++-------
cmd-run-shell.c | 7 +---
cmd-split-window.c | 15 ++-----
control-notify.c | 2 +-
environ.c | 7 ++-
format.c | 78 +++++++++++++++++++++++++++++++++-----
input.c | 12 ++++++
names.c | 4 +-
options-table.c | 70 +++++++++++++++++-----------------
screen-redraw.c | 2 +-
server-client.c | 14 +++++--
status.c | 99 ++++++++++++++++++++++++-------------------------
tmux.1 | 34 +++++++++--------
tmux.c | 5 +-
tmux.h | 20 ++++-----
tty-term.c | 1 +
tty.c | 16 +++++--
window-choose.c | 6 +--
window-copy.c | 4 +-
35 files changed, 306 insertions(+), 265 deletions(-)
commit 313f2263f8bb3336893527f65789f820ba7eaf0f
Author: nicm <nicm>
Commit: nicm <nicm>
status_replace can now become local to status.c and it no longer needs
the jobsflag argument. While here there is no need to repeat work that
format_defaults already does.
---
status.c | 43 +++++++++++++++----------------------------
tmux.h | 2 --
2 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/status.c b/status.c
index 2755665..e7714a0 100644
--- a/status.c
+++ b/status.c
@@ -29,16 +29,17 @@
#include "tmux.h"
-char *status_redraw_get_left(
- struct client *, time_t, int, struct grid_cell *, size_t *);
-char *status_redraw_get_right(
- struct client *, time_t, int, struct grid_cell *, size_t *);
+char *status_redraw_get_left(struct client *, time_t, int, struct grid_cell
*,
+ size_t *);
+char *status_redraw_get_right(struct client *, time_t, int,
+ struct grid_cell *, size_t *);
char *status_find_job(struct client *, char **);
void status_job_free(void *);
void status_job_callback(struct job *);
-char *status_print(
- struct client *, struct winlink *, time_t, struct grid_cell *);
-void status_replace1(struct client *, char **, char **, char *, size_t, int);
+char *status_print(struct client *, struct winlink *, time_t,
+ struct grid_cell *);
+char *status_replace(struct client *, struct winlink *, const char *,
time_t);
+void status_replace1(struct client *, char **, char **, char *, size_t);
void status_message_callback(int, short, void *);
const char *status_prompt_up_history(u_int *);
@@ -86,7 +87,7 @@ status_redraw_get_left(struct client *c, time_t t, int
utf8flag,
style_apply_update(gc, &s->options, "status-left-style");
template = options_get_string(&s->options, "status-left");
- left = status_replace(c, NULL, template , t, 1);
+ left = status_replace(c, NULL, template, t);
*size = options_get_number(&s->options, "status-left-length");
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
@@ -108,7 +109,7 @@ status_redraw_get_right(struct client *c, time_t t, int
utf8flag,
style_apply_update(gc, &s->options, "status-right-style");
template = options_get_string(&s->options, "status-right");
- right = status_replace(c, NULL, template, t, 1);
+ right = status_replace(c, NULL, template, t);
*size = options_get_number(&s->options, "status-right-length");
rightlen = screen_write_cstrlen(utf8flag, "%s", right);
@@ -364,7 +365,7 @@ out:
/* Replace a single special sequence (prefixed by #). */
void
status_replace1(struct client *c, char **iptr, char **optr, char *out,
- size_t outsize, int jobsflag)
+ size_t outsize)
{
char ch, tmp[256], *ptr, *endptr;
size_t ptrlen;
@@ -382,10 +383,6 @@ status_replace1(struct client *c, char **iptr, char
**optr, char *out,
switch (*(*iptr)++) {
case '(':
- if (!jobsflag) {
- ch = ')';
- goto skip_to;
- }
if ((ptr = status_find_job(c, iptr)) == NULL)
return;
goto do_replace;
@@ -434,11 +431,8 @@ skip_to:
/* Replace special sequences in fmt. */
char *
-status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t,
- int jobsflag)
+status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
{
- struct session *s = NULL;
- struct window_pane *wp = NULL;
static char out[BUFSIZ];
char in[BUFSIZ], ch, *iptr, *optr, *expanded;
size_t len;
@@ -447,13 +441,6 @@ status_replace(struct client *c, struct winlink *wl, const
char *fmt, time_t t,
if (fmt == NULL)
return (xstrdup(""));
- if (c != NULL)
- s = c->session;
- if (wl == NULL && s != NULL)
- wl = s->curw;
- if (wl != NULL)
- wp = wl->window->active;
-
len = strftime(in, sizeof in, fmt, localtime(&t));
in[len] = '\0';
@@ -469,12 +456,12 @@ status_replace(struct client *c, struct winlink *wl,
const char *fmt, time_t t,
*optr++ = ch;
continue;
}
- status_replace1(c, &iptr, &optr, out, sizeof out, jobsflag);
+ status_replace1(c, &iptr, &optr, out, sizeof out);
}
*optr = '\0';
ft = format_create();
- format_defaults(ft, c, s, wl, wp);
+ format_defaults(ft, c, NULL, wl, NULL);
expanded = format_expand(ft, out);
format_free(ft);
return (expanded);
@@ -639,7 +626,7 @@ status_print(struct client *c, struct winlink *wl, time_t t,
else if (wl->flags & (WINLINK_ACTIVITY|WINLINK_SILENCE))
style_apply_update(gc, oo, "window-status-activity-style");
- text = status_replace(c, wl, fmt, t, 1);
+ text = status_replace(c, wl, fmt, t);
return (text);
}
diff --git a/tmux.h b/tmux.h
index 72e417f..4e1ee1b 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1925,8 +1925,6 @@ void status_free_jobs(struct status_out_tree *);
void status_update_jobs(struct client *);
void status_set_window_at(struct client *, u_int);
int status_redraw(struct client *);
-char *status_replace(struct client *, struct winlink *, const char *, time_t,
- int);
void printflike(2, 3) status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
commit 8d94bb67abe0e83571bc5c0875755a40ea9c9039
Author: nicm <nicm>
Commit: nicm <nicm>
Use formats not status_replace for set-titles-string.
---
server-client.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/server-client.c b/server-client.c
index 6c475f2..280815c 100644
--- a/server-client.c
+++ b/server-client.c
@@ -773,19 +773,25 @@ server_client_check_redraw(struct client *c)
void
server_client_set_title(struct client *c)
{
- struct session *s = c->session;
- const char *template;
- char *title;
+ struct session *s = c->session;
+ const char *template;
+ char *title;
+ struct format_tree *ft;
template = options_get_string(&s->options, "set-titles-string");
- title = status_replace(c, NULL, template, time(NULL), 1);
+ ft = format_create();
+ format_defaults(ft, c, NULL, NULL, NULL);
+
+ title = format_expand_time(ft, template, time(NULL));
if (c->title == NULL || strcmp(title, c->title) != 0) {
free(c->title);
c->title = xstrdup(title);
tty_set_title(&c->tty, c->title);
}
free(title);
+
+ format_free(ft);
}
/* Dispatch message from client. */
commit 03758a50dc21b7c77b75f689d06f81292266c20a
Author: nicm <nicm>
Commit: nicm <nicm>
Add format_expand_time and use it instead of status_replace where
command execution is not needed.
---
cmd-pipe-pane.c | 21 +++++++++++++++++----
format.c | 30 ++++++++++++++++++++++++++++++
status.c | 27 ++++++++++++++++++++++-----
tmux.h | 1 +
4 files changed, 70 insertions(+), 9 deletions(-)
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index fde6baa..df70643 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -22,6 +22,7 @@
#include <errno.h>
#include <fcntl.h>
#include <paths.h>
+#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -49,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);
@@ -84,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. */
@@ -109,8 +121,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
closefrom(STDERR_FILENO + 1);
- command = status_replace(c, 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/format.c b/format.c
index f7cd359..01fa3ad 100644
--- a/format.c
+++ b/format.c
@@ -326,6 +326,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)
@@ -335,6 +362,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;
diff --git a/status.c b/status.c
index 93dc021..2755665 100644
--- a/status.c
+++ b/status.c
@@ -760,14 +760,20 @@ status_prompt_set(struct client *c, const char *msg,
const char *input,
int (*callbackfn)(void *, const char *), void (*freefn)(void *),
void *data, int flags)
{
- int keys;
+ struct format_tree *ft;
+ int keys;
+ time_t t;
+
+ ft = format_create();
+ format_defaults(ft, c, NULL, NULL, NULL);
+ t = time(NULL);
status_message_clear(c);
status_prompt_clear(c);
- c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
+ c->prompt_string = format_expand_time(ft, msg, time(NULL));
- c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
+ c->prompt_buffer = format_expand_time(ft, input, time(NULL));
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_callbackfn = callbackfn;
@@ -786,6 +792,8 @@ status_prompt_set(struct client *c, const char *msg, const
char *input,
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS;
+
+ format_free(ft);
}
/* Remove status line prompt. */
@@ -814,16 +822,25 @@ status_prompt_clear(struct client *c)
void
status_prompt_update(struct client *c, const char *msg, const char *input)
{
+ struct format_tree *ft;
+ time_t t;
+
+ ft = format_create();
+ format_defaults(ft, c, NULL, NULL, NULL);
+ t = time(NULL);
+
free(c->prompt_string);
- c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
+ c->prompt_string = format_expand_time(ft, msg, time(NULL));
free(c->prompt_buffer);
- c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
+ c->prompt_buffer = format_expand_time(ft, input, time(NULL));
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_hindex = 0;
c->flags |= CLIENT_STATUS;
+
+ format_free(ft);
}
/* Draw client prompt on status line of present else on last line. */
diff --git a/tmux.h b/tmux.h
index c9be497..72e417f 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1512,6 +1512,7 @@ void format_free(struct format_tree *);
void printflike(3, 4) format_add(struct format_tree *, const char *,
const char *, ...);
const char *format_find(struct format_tree *, const char *);
+char *format_expand_time(struct format_tree *, const char *, time_t);
char *format_expand(struct format_tree *, const char *);
void format_defaults(struct format_tree *, struct client *,
struct session *, struct winlink *, struct window_pane *);
commit 83a8e1fd20e3cbd6da38d0b4d6973cad0484c27b
Author: nicm <nicm>
Commit: nicm <nicm>
Move pane border options to window options rather than session, from Marc
Finet.
---
options-table.c | 68 +++++++++++++++++++++++++++---------------------------
screen-redraw.c | 2 +-
tmux.1 | 34 ++++++++++++++-------------
3 files changed, 53 insertions(+), 51 deletions(-)
diff --git a/options-table.c b/options-table.c
index 7d8b256..fb231f7 100644
--- a/options-table.c
+++ b/options-table.c
@@ -275,40 +275,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"
- },
-
- { .name = "pane-active-border-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .default_num = 2,
- .style = "pane-active-border-style"
- },
-
- { .name = "pane-active-border-style",
- .type = OPTIONS_TABLE_STYLE,
- .default_str = "fg=green"
- },
-
- { .name = "pane-border-bg",
- .type = OPTIONS_TABLE_COLOUR,
- .default_num = 8,
- .style = "pane-border-style"
- },
-
- { .name = "pane-border-fg",
- .type = OPTIONS_TABLE_COLOUR,
- .default_num = 8,
- .style = "pane-border-style"
- },
-
- { .name = "pane-border-style",
- .type = OPTIONS_TABLE_STYLE,
- .default_str = "default"
- },
-
{ .name = "prefix",
.type = OPTIONS_TABLE_KEY,
.default_num = '\002',
@@ -646,6 +612,23 @@ const struct options_table_entry window_options_table[] = {
.default_num = 0
},
+ { .name = "pane-active-border-bg",
+ .type = OPTIONS_TABLE_COLOUR,
+ .default_num = 8,
+ .style = "pane-active-border-style"
+ },
+
+ { .name = "pane-active-border-fg",
+ .type = OPTIONS_TABLE_COLOUR,
+ .default_num = 2,
+ .style = "pane-active-border-style"
+ },
+
+ { .name = "pane-active-border-style",
+ .type = OPTIONS_TABLE_STYLE,
+ .default_str = "fg=green"
+ },
+
{ .name = "pane-base-index",
.type = OPTIONS_TABLE_NUMBER,
.minimum = 0,
@@ -653,6 +636,23 @@ const struct options_table_entry window_options_table[] = {
.default_num = 0
},
+ { .name = "pane-border-bg",
+ .type = OPTIONS_TABLE_COLOUR,
+ .default_num = 8,
+ .style = "pane-border-style"
+ },
+
+ { .name = "pane-border-fg",
+ .type = OPTIONS_TABLE_COLOUR,
+ .default_num = 8,
+ .style = "pane-border-style"
+ },
+
+ { .name = "pane-border-style",
+ .type = OPTIONS_TABLE_STYLE,
+ .default_str = "default"
+ },
+
{ .name = "remain-on-exit",
.type = OPTIONS_TABLE_FLAG,
.default_num = 0
diff --git a/screen-redraw.c b/screen-redraw.c
index ef9e539..c2b2ece 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -275,7 +275,7 @@ void
screen_redraw_draw_borders(struct client *c, int status, u_int top)
{
struct window *w = c->session->curw->window;
- struct options *oo = &c->session->options;
+ struct options *oo = &w->options;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct grid_cell active_gc, other_gc, msg_gc;
diff --git a/tmux.1 b/tmux.1
index 1d4f292..ca7d392 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2441,22 +2441,6 @@ window.
.Op Ic on | off
.Xc
If enabled, request mouse input as UTF-8 on UTF-8 terminals.
-.It Ic pane-active-border-style Ar style
-Set the pane border style for the currently active pane.
-For how to specify
-.Ar style ,
-see the
-.Ic message-command-style
-option.
-Attributes are ignored.
-.It Ic pane-border-style Ar style
-Set the pane border style for panes aside from the active pane.
-For how to specify
-.Ar style ,
-see the
-.Ic message-command-style
-option.
-Attributes are ignored.
.It Ic prefix Ar key
Set the key accepted as a prefix key.
.It Ic prefix2 Ar key
@@ -2895,11 +2879,29 @@ but set the width of other panes in the
.Ic main-vertical
layout.
.Pp
+.It Ic pane-active-border-style Ar style
+Set the pane border style for the currently active pane.
+For how to specify
+.Ar style ,
+see the
+.Ic message-command-style
+option.
+Attributes are ignored.
+.Pp
.It Ic pane-base-index Ar index
Like
.Ic base-index ,
but set the starting index for pane numbers.
.Pp
+.It Ic pane-border-style Ar style
+Set the pane border style for panes aside from the active pane.
+For how to specify
+.Ar style ,
+see the
+.Ic message-command-style
+option.
+Attributes are ignored.
+.Pp
.It Xo Ic remain-on-exit
.Op Ic on | off
.Xc
commit 90bf7026f6bb83e0781ff2fc71c32ce973edce59
Author: nicm <nicm>
Commit: nicm <nicm>
Reset bracket paste mode on detach.
---
tty.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tty.c b/tty.c
index 875e420..1bb8981 100644
--- a/tty.c
+++ b/tty.c
@@ -281,6 +281,8 @@ tty_stop_tty(struct tty *tty)
else
tty_raw(tty, tty_term_string1(tty->term, TTYC_SS, 0));
}
+ if (tty->mode & MODE_BRACKETPASTE)
+ tty_raw(tty, "\033[?2004l");
tty_raw(tty, tty_term_string(tty->term, TTYC_CR));
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM));
commit f1e68bfdd22dc1fa13630cb64855506643e01c5c
Author: nicm <nicm>
Commit: nicm <nicm>
Remove a couple of now-unused variables.
---
cmd-new-window.c | 1 -
cmd-split-window.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/cmd-new-window.c b/cmd-new-window.c
index be3f43a..c05a0ce 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;
diff --git a/cmd-split-window.c b/cmd-split-window.c
index d26ce82..680b156 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -59,7 +59,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;
commit 4946f74253de52f10beb023d4c5b88bafdb11ec4
Author: nicm <nicm>
Commit: nicm <nicm>
Wrap all the individual format_* calls in a single format_defaults
functions.
---
cmd-attach-session.c | 14 ++++----------
cmd-break-pane.c | 7 +------
cmd-choose-buffer.c | 2 +-
cmd-choose-client.c | 3 +--
cmd-display-message.c | 6 +-----
cmd-find-window.c | 4 +---
cmd-if-shell.c | 7 +------
cmd-list-buffers.c | 2 +-
cmd-list-clients.c | 3 +--
cmd-list-panes.c | 4 +---
cmd-list-sessions.c | 2 +-
cmd-list-windows.c | 4 +---
cmd-new-session.c | 9 ++++-----
cmd-new-window.c | 14 ++++----------
cmd-run-shell.c | 7 +------
cmd-split-window.c | 14 ++++----------
control-notify.c | 2 +-
format.c | 48 ++++++++++++++++++++++++++++++++++++++----------
names.c | 4 ++--
status.c | 9 +--------
tmux.h | 12 +++++-------
window-choose.c | 6 ++----
window-copy.c | 4 +---
23 files changed, 78 insertions(+), 109 deletions(-)
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 160f2a8..a67ec82 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 0025167..a1da0a3 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 19f5fba..33125a0 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 5a1892f..3002f7b 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-display-message.c b/cmd-display-message.c
index f3547b0..0a61fd1 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 88e4879..25155f7 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 1543291..8c6620d 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 8eb1610..37571b8 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 292be72..893a6d0 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 7f62177..bd34344 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 ea8f3e3..8ad55d0 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 5f73e8d..3f6b2a4 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 e244f88..ec292fa 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 7f14b21..be3f43a 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -109,11 +109,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 +170,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-run-shell.c b/cmd-run-shell.c
index b47c282..5d6d178 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 7e34e52..d26ce82 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -89,11 +89,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);
@@ -181,11 +178,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 4ea1570..747ef5b 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/format.c b/format.c
index ea0a91b..f7cd359 100644
--- a/format.c
+++ b/format.c
@@ -38,7 +38,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 {
@@ -418,9 +423,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;
@@ -451,7 +478,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;
@@ -501,7 +528,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;
@@ -523,7 +550,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;
@@ -533,7 +561,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);
@@ -553,7 +581,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;
@@ -575,7 +603,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;
@@ -665,12 +693,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/names.c b/names.c
index 8e01d34..1ceb83c 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/status.c b/status.c
index dc6d390..93dc021 100644
--- a/status.c
+++ b/status.c
@@ -474,14 +474,7 @@ status_replace(struct client *c, struct winlink *wl, const
char *fmt, time_t t,
*optr = '\0';
ft = format_create();
- if (c != NULL)
- format_client(ft, c);
- 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, c, s, wl, wp);
expanded = format_expand(ft, out);
format_free(ft);
return (expanded);
diff --git a/tmux.h b/tmux.h
index da8d3bf..c9be497 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1513,14 +1513,12 @@ void printflike(3, 4) format_add(struct format_tree *,
const char *,
const char *, ...);
const char *format_find(struct format_tree *, const char *);
char *format_expand(struct format_tree *, const char *);
-void format_session(struct format_tree *, struct session *);
-void format_client(struct format_tree *, struct client *);
-void format_window(struct format_tree *, struct window *);
-void format_winlink(struct format_tree *, struct session *,
- struct winlink *);
-void format_window_pane(struct format_tree *,
+void format_defaults(struct format_tree *, struct client *,
+ struct session *, struct winlink *, struct window_pane *);
+void format_defaults_window(struct format_tree *, struct window *);
+void format_defaults_pane(struct format_tree *,
struct window_pane *);
-void format_paste_buffer(struct format_tree *,
+void format_defaults_paste_buffer(struct format_tree *,
struct paste_buffer *, int);
/* mode-key.c */
diff --git a/window-choose.c b/window-choose.c
index 0d72474..6914167 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -919,7 +919,7 @@ window_choose_add_session(struct window_pane *wp, struct
client *c,
wcd->ft_template = xstrdup(template);
format_add(wcd->ft, "line", "%u", idx);
- format_session(wcd->ft, s);
+ format_defaults(wcd->ft, NULL, s, NULL, NULL);
wcd->command = cmd_template_replace(action, s->name, 1);
@@ -946,9 +946,7 @@ window_choose_add_window(struct window_pane *wp, struct
client *c,
wcd->ft_template = xstrdup(template);
format_add(wcd->ft, "line", "%u", idx);
- format_session(wcd->ft, s);
- format_winlink(wcd->ft, s, wl);
- format_window_pane(wcd->ft, wl->window->active);
+ format_defaults(wcd->ft, NULL, s, wl, NULL);
xasprintf(&expanded, "%s:%d", s->name, wl->idx);
wcd->command = cmd_template_replace(action, expanded, 1);
diff --git a/window-copy.c b/window-copy.c
index 6447a2d..223df88 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1512,9 +1512,7 @@ window_copy_copy_pipe(struct window_pane *wp, struct
session *sess,
return;
ft = format_create();
- format_window_pane(ft, wp);
- if (sess != NULL)
- format_session(ft, sess);
+ format_defaults(ft, NULL, sess, NULL, wp);
expanded = format_expand(ft, arg);
job = job_run(expanded, sess, NULL, NULL, NULL);
commit e5d9ceff18e37320b9243d24204a0a79d77172e4
Author: nicm <nicm>
Commit: nicm <nicm>
There is no need to save the guard state because the function checks it
again anyway.
---
cmd-queue.c | 23 +++++++++--------------
tmux.h | 2 +-
2 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/cmd-queue.c b/cmd-queue.c
index a98fa9b..58282c8 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/tmux.h b/tmux.h
index 6b97469..da8d3bf 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1832,7 +1832,7 @@ struct cmd_q *cmdq_new(struct client *);
int cmdq_free(struct cmd_q *);
void printflike(2, 3) cmdq_print(struct cmd_q *, const char *, ...);
void printflike(2, 3) cmdq_error(struct cmd_q *, const char *, ...);
-int cmdq_guard(struct cmd_q *, const char *, int);
+void cmdq_guard(struct cmd_q *, const char *, int);
void cmdq_run(struct cmd_q *, struct cmd_list *);
void cmdq_append(struct cmd_q *, struct cmd_list *);
int cmdq_continue(struct cmd_q *);
commit c9642ee21367f0bf2b17b423d7155c88138aa9fc
Author: nicm <nicm>
Commit: nicm <nicm>
Remove two unused arguments from status_replace.
---
cmd-pipe-pane.c | 3 +--
server-client.c | 2 +-
status.c | 46 +++++++++++++++++++++++-----------------------
tmux.h | 4 ++--
4 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c
index 3158765..fde6baa 100644
--- a/cmd-pipe-pane.c
+++ b/cmd-pipe-pane.c
@@ -109,8 +109,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);
+ command = status_replace(c, NULL, args->argv[0], time(NULL), 0);
execl(_PATH_BSHELL, "sh", "-c", command, (char *) NULL);
_exit(1);
default:
diff --git a/server-client.c b/server-client.c
index e0b0c66..6c475f2 100644
--- a/server-client.c
+++ b/server-client.c
@@ -779,7 +779,7 @@ server_client_set_title(struct client *c)
template = options_get_string(&s->options, "set-titles-string");
- title = status_replace(c, NULL, NULL, NULL, template, time(NULL), 1);
+ title = status_replace(c, NULL, template, time(NULL), 1);
if (c->title == NULL || strcmp(title, c->title) != 0) {
free(c->title);
c->title = xstrdup(title);
diff --git a/status.c b/status.c
index 6d6c7c9..dc6d390 100644
--- a/status.c
+++ b/status.c
@@ -75,17 +75,18 @@ status_at_line(struct client *c)
/* Retrieve options for left string. */
char *
-status_redraw_get_left(struct client *c,
- time_t t, int utf8flag, struct grid_cell *gc, size_t *size)
+status_redraw_get_left(struct client *c, time_t t, int utf8flag,
+ struct grid_cell *gc, size_t *size)
{
struct session *s = c->session;
+ const char *template;
char *left;
size_t leftlen;
style_apply_update(gc, &s->options, "status-left-style");
- left = status_replace(c, NULL,
- NULL, NULL, options_get_string(&s->options, "status-left"), t, 1);
+ template = options_get_string(&s->options, "status-left");
+ left = status_replace(c, NULL, template , t, 1);
*size = options_get_number(&s->options, "status-left-length");
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
@@ -96,17 +97,18 @@ status_redraw_get_left(struct client *c,
/* Retrieve options for right string. */
char *
-status_redraw_get_right(struct client *c,
- time_t t, int utf8flag, struct grid_cell *gc, size_t *size)
+status_redraw_get_right(struct client *c, time_t t, int utf8flag,
+ struct grid_cell *gc, size_t *size)
{
struct session *s = c->session;
+ const char *template;
char *right;
size_t rightlen;
style_apply_update(gc, &s->options, "status-right-style");
- right = status_replace(c, NULL,
- NULL, NULL, options_get_string(&s->options, "status-right"), t, 1);
+ template = options_get_string(&s->options, "status-right");
+ right = status_replace(c, NULL, template, t, 1);
*size = options_get_number(&s->options, "status-right-length");
rightlen = screen_write_cstrlen(utf8flag, "%s", right);
@@ -432,9 +434,11 @@ skip_to:
/* Replace special sequences in fmt. */
char *
-status_replace(struct client *c, struct session *s, struct winlink *wl,
- struct window_pane *wp, const char *fmt, time_t t, int jobsflag)
+status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t,
+ int jobsflag)
{
+ struct session *s = NULL;
+ struct window_pane *wp = NULL;
static char out[BUFSIZ];
char in[BUFSIZ], ch, *iptr, *optr, *expanded;
size_t len;
@@ -443,11 +447,11 @@ status_replace(struct client *c, struct session *s,
struct winlink *wl,
if (fmt == NULL)
return (xstrdup(""));
- if (s == NULL && c != NULL)
+ if (c != NULL)
s = c->session;
if (wl == NULL && s != NULL)
wl = s->curw;
- if (wp == NULL && wl != NULL)
+ if (wl != NULL)
wp = wl->window->active;
len = strftime(in, sizeof in, fmt, localtime(&t));
@@ -620,8 +624,8 @@ status_job_callback(struct job *job)
/* Return winlink status line entry and adjust gc as necessary. */
char *
-status_print(
- struct client *c, struct winlink *wl, time_t t, struct grid_cell *gc)
+status_print(struct client *c, struct winlink *wl, time_t t,
+ struct grid_cell *gc)
{
struct options *oo = &wl->window->options;
struct session *s = c->session;
@@ -642,7 +646,7 @@ status_print(
else if (wl->flags & (WINLINK_ACTIVITY|WINLINK_SILENCE))
style_apply_update(gc, oo, "window-status-activity-style");
- text = status_replace(c, NULL, wl, NULL, fmt, t, 1);
+ text = status_replace(c, wl, fmt, t, 1);
return (text);
}
@@ -768,11 +772,9 @@ status_prompt_set(struct client *c, const char *msg, const
char *input,
status_message_clear(c);
status_prompt_clear(c);
- c->prompt_string = status_replace(c, NULL, NULL, NULL, msg,
- time(NULL), 0);
+ c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
- c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input,
- time(NULL), 0);
+ c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_callbackfn = callbackfn;
@@ -820,12 +822,10 @@ void
status_prompt_update(struct client *c, const char *msg, const char *input)
{
free(c->prompt_string);
- c->prompt_string = status_replace(c, NULL, NULL, NULL, msg,
- time(NULL), 0);
+ c->prompt_string = status_replace(c, NULL, msg, time(NULL), 0);
free(c->prompt_buffer);
- c->prompt_buffer = status_replace(c, NULL, NULL, NULL, input,
- time(NULL), 0);
+ c->prompt_buffer = status_replace(c, NULL, input, time(NULL), 0);
c->prompt_index = strlen(c->prompt_buffer);
c->prompt_hindex = 0;
diff --git a/tmux.h b/tmux.h
index c73b59c..6b97469 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1926,8 +1926,8 @@ void status_free_jobs(struct status_out_tree *);
void status_update_jobs(struct client *);
void status_set_window_at(struct client *, u_int);
int status_redraw(struct client *);
-char *status_replace(struct client *, struct session *, struct winlink *,
- struct window_pane *, const char *, time_t, int);
+char *status_replace(struct client *, struct winlink *, const char *, time_t,
+ int);
void printflike(2, 3) status_message_set(struct client *, const char *, ...);
void status_message_clear(struct client *);
int status_message_redraw(struct client *);
commit 4e03239d1f2edc4f2d9f90c2bb28d609b64ea566
Author: nicm <nicm>
Commit: nicm <nicm>
Tidy up detach-client a bit.
---
cmd-detach-client.c | 47 +++++++++++++++++++++++++----------------------
1 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
index 600554a..7f87d2c 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);
}
commit 144025e3e6ecd5503326a674de70075851e54a85
Author: nicm <nicm>
Commit: nicm <nicm>
Focus off needs to be sent with tty_raw, reported by Geoff Nixon.
---
tty.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tty.c b/tty.c
index 2ff2fcc..875e420 100644
--- a/tty.c
+++ b/tty.c
@@ -290,7 +290,7 @@ tty_stop_tty(struct tty *tty)
if (tty_term_has(tty->term, TTYC_XT)) {
if (tty->flags & TTY_FOCUS) {
tty->flags &= ~TTY_FOCUS;
- tty_puts(tty, "\033[?1004l");
+ tty_raw(tty, "\033[?1004l");
}
}
commit adcc71d4d5d338d0f7d13867e59a11741eb36afa
Author: nicm <nicm>
Commit: nicm <nicm>
Don't leak the individual strings when copying environment.
---
environ.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/environ.c b/environ.c
index 284f8b5..0dd9178 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) {
commit c38f0d85da44d83ea69c6586a1aef428d9f489d0
Author: sthen <sthen>
Commit: sthen <sthen>
In options-table.c r1.51 an extra space was added to the default
status-right,
overrunning status-right-length with long window titles. Allow for the extra
space so the last digit of the year isn't lost. ok nicm@
---
options-table.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/options-table.c b/options-table.c
index 65b9122..7d8b256 100644
--- a/options-table.c
+++ b/options-table.c
@@ -431,7 +431,7 @@ const struct options_table_entry session_options_table[] = {
{ .name = "status-right",
.type = OPTIONS_TABLE_STRING,
- .default_str = " \"#{=22:pane_title}\" %H:%M %d-%b-%y"
+ .default_str = " \"#{=21:pane_title}\" %H:%M %d-%b-%y"
},
{ .name = "status-right-attr",
commit f9c7f9a17aaf05f4303f66982f6cf33ad03f9714
Author: sthen <sthen>
Commit: sthen <sthen>
typo in comment ;) ok nicm
---
status.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/status.c b/status.c
index ac248ba..6d6c7c9 100644
--- a/status.c
+++ b/status.c
@@ -328,7 +328,7 @@ draw:
wloffset = 0;
if (wlwidth < wlavailable) {
switch (options_get_number(&s->options, "status-justify")) {
- case 1: /* centered */
+ case 1: /* centred */
wloffset += (wlavailable - wlwidth) / 2;
break;
case 2: /* right */
commit 16bdd970dcc68e50f26c512b3ead628b9b899c88
Author: nicm <nicm>
Commit: nicm <nicm>
Support blinking cursor mode, both the xterm CSI ?12 h/l and (the
backwards) screen CSI 34 h/l. From Guanpeng Xu.
---
input.c | 12 ++++++++++++
tmux.h | 3 ++-
tty-term.c | 1 +
tty.c | 12 ++++++++----
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/input.c b/input.c
index fcc9118..de11f62 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/tmux.h b/tmux.h
index aff664c..c73b59c 100644
--- a/tmux.h
+++ b/tmux.h
@@ -175,6 +175,7 @@ enum tty_code_code {
TTYC_CUP, /* cursor_address, cm */
TTYC_CUU, /* parm_up_cursor, UP */
TTYC_CUU1, /* cursor_up, up */
+ TTYC_CVVIS, /* cursor_visible, vs */
TTYC_DCH, /* parm_dch, DC */
TTYC_DCH1, /* delete_character, dc */
TTYC_DIM, /* enter_dim_mode, mh */
@@ -600,7 +601,7 @@ struct mode_key_table {
#define MODE_WRAP 0x10 /* whether lines wrap */
#define MODE_MOUSE_STANDARD 0x20
#define MODE_MOUSE_BUTTON 0x40
-/* 0x80 unused */
+#define MODE_BLINKING 0x80
#define MODE_MOUSE_UTF8 0x100
#define MODE_MOUSE_SGR 0x200
#define MODE_BRACKETPASTE 0x400
diff --git a/tty-term.c b/tty-term.c
index f866a2d..c8a6ba8 100644
--- a/tty-term.c
+++ b/tty-term.c
@@ -54,6 +54,7 @@ const struct tty_term_code_entry tty_term_codes[NTTYCODE] = {
{ TTYC_CUP, TTYCODE_STRING, "cup" },
{ TTYC_CUU, TTYCODE_STRING, "cuu" },
{ TTYC_CUU1, TTYCODE_STRING, "cuu1" },
+ { TTYC_CVVIS, TTYCODE_STRING, "cvvis" },
{ TTYC_DCH, TTYCODE_STRING, "dch" },
{ TTYC_DCH1, TTYCODE_STRING, "dch1" },
{ TTYC_DIM, TTYCODE_STRING, "dim" },
diff --git a/tty.c b/tty.c
index 9f57c36..2ff2fcc 100644
--- a/tty.c
+++ b/tty.c
@@ -482,10 +482,14 @@ tty_update_mode(struct tty *tty, int mode, struct screen
*s)
mode &= ~MODE_CURSOR;
changed = mode ^ tty->mode;
- if (changed & MODE_CURSOR) {
- if (mode & MODE_CURSOR)
- tty_putcode(tty, TTYC_CNORM);
- else
+ if (changed & (MODE_CURSOR|MODE_BLINKING)) {
+ if (mode & MODE_CURSOR) {
+ if (mode & MODE_BLINKING &&
+ tty_term_has(tty->term, TTYC_CVVIS))
+ tty_putcode(tty, TTYC_CVVIS);
+ else
+ tty_putcode(tty, TTYC_CNORM);
+ } else
tty_putcode(tty, TTYC_CIVIS);
}
if (tty->cstyle != s->cstyle) {
commit d45150267656530b8503375555a1814fcfe6a15a
Author: nicm <nicm>
Commit: nicm <nicm>
Make a tmux-%u directory under TMUX_TMPDIR, like TMPDIR.
---
tmux.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tmux.c b/tmux.c
index fabcee5..77a3924 100644
--- a/tmux.c
+++ b/tmux.c
@@ -131,7 +131,7 @@ makesocketpath(const char *label)
uid = getuid();
if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0')
- xsnprintf(base, sizeof base, "%s/", s);
+ xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
else if ((s = getenv("TMPDIR")) != NULL && *s != '\0')
xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
else
@@ -146,8 +146,7 @@ makesocketpath(const char *label)
errno = ENOTDIR;
return (NULL);
}
- if (sb.st_uid != uid || (!S_ISDIR(sb.st_mode) &&
- sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) {
+ if (sb.st_uid != uid || (sb.st_mode & S_IRWXO) != 0) {
errno = EACCES;
return (NULL);
}
-----------------------------------------------------------------------
Summary of changes:
cmd-attach-session.c | 14 ++-----
cmd-break-pane.c | 7 +---
cmd-choose-buffer.c | 2 +-
cmd-choose-client.c | 3 +-
cmd-detach-client.c | 47 ++++++++++++-----------
cmd-display-message.c | 6 +--
cmd-find-window.c | 4 +-
cmd-if-shell.c | 7 +---
cmd-list-buffers.c | 2 +-
cmd-list-clients.c | 3 +-
cmd-list-panes.c | 4 +-
cmd-list-sessions.c | 2 +-
cmd-list-windows.c | 4 +-
cmd-new-session.c | 9 ++--
cmd-new-window.c | 15 ++-----
cmd-pipe-pane.c | 23 +++++++++--
cmd-queue.c | 23 ++++-------
cmd-run-shell.c | 7 +---
cmd-split-window.c | 15 ++-----
control-notify.c | 2 +-
environ.c | 7 ++-
format.c | 78 +++++++++++++++++++++++++++++++++-----
input.c | 12 ++++++
names.c | 4 +-
options-table.c | 70 +++++++++++++++++-----------------
screen-redraw.c | 2 +-
server-client.c | 14 +++++--
status.c | 99 ++++++++++++++++++++++++-------------------------
tmux.1 | 34 +++++++++--------
tmux.c | 5 +-
tmux.h | 20 ++++-----
tty-term.c | 1 +
tty.c | 16 +++++--
window-choose.c | 6 +--
window-copy.c | 4 +-
35 files changed, 306 insertions(+), 265 deletions(-)
hooks/post-receive
--
tmux
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs