mirror of
https://github.com/tmate-io/tmate.git
synced 2024-11-25 17:43:57 +01:00
Merge branch 'obsd-master'
Conflicts: cmd-pipe-pane.c
This commit is contained in:
commit
833fe5bdee
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
} else {
|
||||
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++) {
|
||||
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);
|
||||
server_write_client(cloop, msgtype,
|
||||
cloop->session->name,
|
||||
strlen(cloop->session->name) + 1);
|
||||
}
|
||||
return (CMD_RETURN_STOP);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
23
cmd-queue.c
23
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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
78
format.c
78
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;
|
||||
|
12
input.c
12
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;
|
||||
|
4
names.c
4
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);
|
||||
|
@ -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"
|
||||
},
|
||||
|
||||
{ .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',
|
||||
@ -430,7 +396,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",
|
||||
@ -645,6 +611,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,
|
||||
@ -652,6 +635,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
|
||||
|
@ -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;
|
||||
|
@ -782,19 +782,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, NULL, 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. */
|
||||
|
99
status.c
99
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 *);
|
||||
@ -75,17 +76,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);
|
||||
|
||||
*size = options_get_number(&s->options, "status-left-length");
|
||||
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
|
||||
@ -96,17 +98,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);
|
||||
|
||||
*size = options_get_number(&s->options, "status-right-length");
|
||||
rightlen = screen_write_cstrlen(utf8flag, "%s", right);
|
||||
@ -328,7 +331,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 */
|
||||
@ -362,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;
|
||||
@ -380,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;
|
||||
@ -432,8 +431,7 @@ 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)
|
||||
{
|
||||
static char out[BUFSIZ];
|
||||
char in[BUFSIZ], ch, *iptr, *optr, *expanded;
|
||||
@ -443,13 +441,6 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
|
||||
if (fmt == NULL)
|
||||
return (xstrdup(""));
|
||||
|
||||
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;
|
||||
|
||||
len = strftime(in, sizeof in, fmt, localtime(&t));
|
||||
in[len] = '\0';
|
||||
|
||||
@ -465,19 +456,12 @@ status_replace(struct client *c, struct session *s, struct winlink *wl,
|
||||
*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();
|
||||
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, NULL, wl, NULL);
|
||||
expanded = format_expand(ft, out);
|
||||
format_free(ft);
|
||||
return (expanded);
|
||||
@ -620,8 +604,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 +626,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);
|
||||
return (text);
|
||||
}
|
||||
|
||||
@ -763,16 +747,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, NULL, NULL, msg,
|
||||
time(NULL), 0);
|
||||
c->prompt_string = format_expand_time(ft, msg, time(NULL));
|
||||
|
||||
c->prompt_buffer = status_replace(c, NULL, NULL, 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;
|
||||
@ -791,6 +779,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. */
|
||||
@ -819,18 +809,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, NULL, 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, NULL, 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. */
|
||||
|
34
tmux.1
34
tmux.1
@ -2445,22 +2445,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
|
||||
@ -2899,11 +2883,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
|
||||
|
5
tmux.c
5
tmux.c
@ -134,7 +134,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
|
||||
@ -149,8 +149,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);
|
||||
}
|
||||
|
20
tmux.h
20
tmux.h
@ -173,6 +173,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 */
|
||||
@ -598,7 +599,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
|
||||
@ -1509,15 +1510,14 @@ 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_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 */
|
||||
@ -1829,7 +1829,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 *);
|
||||
@ -1923,8 +1923,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 session *, struct winlink *,
|
||||
struct window_pane *, 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 *);
|
||||
|
@ -57,6 +57,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" },
|
||||
|
16
tty.c
16
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));
|
||||
@ -290,7 +292,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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,10 +484,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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user