mirror of https://github.com/tmux/tmux.git
Merge branch 'obsd-master'
commit
a0fee328bf
|
@ -55,11 +55,11 @@ cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
|
||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
struct options *oo = s->options;
|
struct options *oo = s->options;
|
||||||
struct window *w = wp->window;
|
struct window *w = wp->window;
|
||||||
struct grid_cell gc;
|
struct grid_cell fgc, bgc;
|
||||||
u_int idx, px, py, i, j, xoff, yoff, sx, sy;
|
u_int pane, idx, px, py, i, j, xoff, yoff, sx, sy;
|
||||||
int colour, active_colour;
|
int colour, active_colour;
|
||||||
char buf[16], *ptr;
|
char buf[16], lbuf[16], rbuf[16], *ptr;
|
||||||
size_t len;
|
size_t len, llen, rlen;
|
||||||
|
|
||||||
if (wp->xoff + wp->sx <= ctx->ox ||
|
if (wp->xoff + wp->sx <= ctx->ox ||
|
||||||
wp->xoff >= ctx->ox + ctx->sx ||
|
wp->xoff >= ctx->ox + ctx->sx ||
|
||||||
|
@ -109,29 +109,50 @@ cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
|
||||||
px = sx / 2;
|
px = sx / 2;
|
||||||
py = sy / 2;
|
py = sy / 2;
|
||||||
|
|
||||||
if (window_pane_index(wp, &idx) != 0)
|
if (window_pane_index(wp, &pane) != 0)
|
||||||
fatalx("index not found");
|
fatalx("index not found");
|
||||||
len = xsnprintf(buf, sizeof buf, "%u", idx);
|
len = xsnprintf(buf, sizeof buf, "%u", pane);
|
||||||
|
|
||||||
if (sx < len)
|
if (sx < len)
|
||||||
return;
|
return;
|
||||||
colour = options_get_number(oo, "display-panes-colour");
|
colour = options_get_number(oo, "display-panes-colour");
|
||||||
active_colour = options_get_number(oo, "display-panes-active-colour");
|
active_colour = options_get_number(oo, "display-panes-active-colour");
|
||||||
|
|
||||||
|
memcpy(&fgc, &grid_default_cell, sizeof fgc);
|
||||||
|
memcpy(&bgc, &grid_default_cell, sizeof bgc);
|
||||||
|
if (w->active == wp) {
|
||||||
|
fgc.fg = active_colour;
|
||||||
|
bgc.bg = active_colour;
|
||||||
|
} else {
|
||||||
|
fgc.fg = colour;
|
||||||
|
bgc.bg = colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
rlen = xsnprintf(rbuf, sizeof rbuf, "%ux%u", wp->sx, wp->sy);
|
||||||
|
if (pane > 9 && pane < 35)
|
||||||
|
llen = xsnprintf(lbuf, sizeof lbuf, "%c", 'a' + (pane - 10));
|
||||||
|
else
|
||||||
|
llen = 0;
|
||||||
|
|
||||||
if (sx < len * 6 || sy < 5) {
|
if (sx < len * 6 || sy < 5) {
|
||||||
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
tty_attributes(tty, &fgc, &grid_default_cell, NULL);
|
||||||
goto draw_text;
|
if (sx >= len + llen + 1) {
|
||||||
|
len += llen + 1;
|
||||||
|
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
||||||
|
tty_putn(tty, buf, len, len);
|
||||||
|
tty_putn(tty, " ", 1, 1);
|
||||||
|
tty_putn(tty, lbuf, llen, llen);
|
||||||
|
} else {
|
||||||
|
tty_cursor(tty, xoff + px - len / 2, yoff + py);
|
||||||
|
tty_putn(tty, buf, len, len);
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
px -= len * 3;
|
px -= len * 3;
|
||||||
py -= 2;
|
py -= 2;
|
||||||
|
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
tty_attributes(tty, &bgc, &grid_default_cell, NULL);
|
||||||
if (w->active == wp)
|
|
||||||
gc.bg = active_colour;
|
|
||||||
else
|
|
||||||
gc.bg = colour;
|
|
||||||
tty_attributes(tty, &gc, &grid_default_cell, NULL);
|
|
||||||
for (ptr = buf; *ptr != '\0'; ptr++) {
|
for (ptr = buf; *ptr != '\0'; ptr++) {
|
||||||
if (*ptr < '0' || *ptr > '9')
|
if (*ptr < '0' || *ptr > '9')
|
||||||
continue;
|
continue;
|
||||||
|
@ -147,20 +168,20 @@ cmd_display_panes_draw_pane(struct screen_redraw_ctx *ctx,
|
||||||
px += 6;
|
px += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = xsnprintf(buf, sizeof buf, "%ux%u", wp->sx, wp->sy);
|
if (sy <= 6)
|
||||||
if (sx < len || sy < 6)
|
goto out;
|
||||||
return;
|
tty_attributes(tty, &fgc, &grid_default_cell, NULL);
|
||||||
tty_cursor(tty, xoff + sx - len, yoff);
|
if (rlen != 0 && sx >= rlen) {
|
||||||
|
tty_cursor(tty, xoff + sx - rlen, yoff);
|
||||||
draw_text:
|
tty_putn(tty, rbuf, rlen, rlen);
|
||||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
}
|
||||||
if (w->active == wp)
|
if (llen != 0) {
|
||||||
gc.fg = active_colour;
|
tty_cursor(tty, xoff + sx / 2 + len * 3 - llen - 1,
|
||||||
else
|
yoff + py + 5);
|
||||||
gc.fg = colour;
|
tty_putn(tty, lbuf, llen, llen);
|
||||||
tty_attributes(tty, &gc, &grid_default_cell, NULL);
|
}
|
||||||
tty_puts(tty, buf);
|
|
||||||
|
|
||||||
|
out:
|
||||||
tty_cursor(tty, 0, 0);
|
tty_cursor(tty, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,11 +218,21 @@ cmd_display_panes_key(struct client *c, struct key_event *event)
|
||||||
struct window *w = c->session->curw->window;
|
struct window *w = c->session->curw->window;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
enum cmd_parse_status status;
|
enum cmd_parse_status status;
|
||||||
|
u_int index;
|
||||||
|
key_code key;
|
||||||
|
|
||||||
if (event->key < '0' || event->key > '9')
|
if (event->key >= '0' && event->key <= '9')
|
||||||
|
index = event->key - '0';
|
||||||
|
else if ((event->key & KEYC_MASK_MODIFIERS) == 0) {
|
||||||
|
key = (event->key & KEYC_MASK_KEY);
|
||||||
|
if (key >= 'a' && key <= 'z')
|
||||||
|
index = 10 + (key - 'a');
|
||||||
|
else
|
||||||
|
return (-1);
|
||||||
|
} else
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
wp = window_pane_at_index(w, event->key - '0');
|
wp = window_pane_at_index(w, index);
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return (1);
|
return (1);
|
||||||
window_unzoom(w);
|
window_unzoom(w);
|
||||||
|
|
|
@ -34,8 +34,8 @@ const struct cmd_entry cmd_set_environment_entry = {
|
||||||
.name = "set-environment",
|
.name = "set-environment",
|
||||||
.alias = "setenv",
|
.alias = "setenv",
|
||||||
|
|
||||||
.args = { "hgrt:u", 1, 2 },
|
.args = { "Fhgrt:u", 1, 2 },
|
||||||
.usage = "[-hgru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
.usage = "[-Fhgru] " CMD_TARGET_SESSION_USAGE " name [value]",
|
||||||
|
|
||||||
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
.target = { 't', CMD_FIND_SESSION, CMD_FIND_CANFAIL },
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
struct cmd_find_state *target = cmdq_get_target(item);
|
struct cmd_find_state *target = cmdq_get_target(item);
|
||||||
struct environ *env;
|
struct environ *env;
|
||||||
const char *name, *value, *tflag;
|
const char *name, *value, *tflag;
|
||||||
|
char *expand = NULL;
|
||||||
|
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
||||||
|
|
||||||
name = args->argv[0];
|
name = args->argv[0];
|
||||||
if (*name == '\0') {
|
if (*name == '\0') {
|
||||||
|
@ -63,6 +65,8 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
|
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
value = NULL;
|
value = NULL;
|
||||||
|
else if (args_has(args, 'F'))
|
||||||
|
value = expand = format_single_from_target(item, args->argv[1]);
|
||||||
else
|
else
|
||||||
value = args->argv[1];
|
value = args->argv[1];
|
||||||
|
|
||||||
|
@ -75,7 +79,8 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
cmdq_error(item, "no such session: %s", tflag);
|
cmdq_error(item, "no such session: %s", tflag);
|
||||||
else
|
else
|
||||||
cmdq_error(item, "no current session");
|
cmdq_error(item, "no current session");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
env = target->s->environ;
|
env = target->s->environ;
|
||||||
}
|
}
|
||||||
|
@ -83,25 +88,31 @@ cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
if (args_has(args, 'u')) {
|
if (args_has(args, 'u')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(item, "can't specify a value with -u");
|
cmdq_error(item, "can't specify a value with -u");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
environ_unset(env, name);
|
environ_unset(env, name);
|
||||||
} else if (args_has(args, 'r')) {
|
} else if (args_has(args, 'r')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
cmdq_error(item, "can't specify a value with -r");
|
cmdq_error(item, "can't specify a value with -r");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
environ_clear(env, name);
|
environ_clear(env, name);
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
cmdq_error(item, "no value specified");
|
cmdq_error(item, "no value specified");
|
||||||
return (CMD_RETURN_ERROR);
|
retval = CMD_RETURN_ERROR;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'h'))
|
if (args_has(args, 'h'))
|
||||||
environ_set(env, name, ENVIRON_HIDDEN, "%s", value);
|
environ_set(env, name, ENVIRON_HIDDEN, "%s", value);
|
||||||
else
|
else
|
||||||
environ_set(env, name, 0, "%s", value);
|
environ_set(env, name, 0, "%s", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (CMD_RETURN_NORMAL);
|
out:
|
||||||
|
free(expand);
|
||||||
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ const struct cmd_entry cmd_source_file_entry = {
|
||||||
.name = "source-file",
|
.name = "source-file",
|
||||||
.alias = "source",
|
.alias = "source",
|
||||||
|
|
||||||
.args = { "nqv", 1, -1 },
|
.args = { "Fnqv", 1, -1 },
|
||||||
.usage = "[-nqv] path ...",
|
.usage = "[-Fnqv] path ...",
|
||||||
|
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.exec = cmd_source_file_exec
|
.exec = cmd_source_file_exec
|
||||||
|
@ -126,7 +126,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
struct cmd_source_file_data *cdata;
|
struct cmd_source_file_data *cdata;
|
||||||
struct client *c = cmdq_get_client(item);
|
struct client *c = cmdq_get_client(item);
|
||||||
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
enum cmd_retval retval = CMD_RETURN_NORMAL;
|
||||||
char *pattern, *cwd;
|
char *pattern, *cwd, *expand = NULL;
|
||||||
const char *path, *error;
|
const char *path, *error;
|
||||||
glob_t g;
|
glob_t g;
|
||||||
int i, result;
|
int i, result;
|
||||||
|
@ -145,7 +145,12 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB);
|
utf8_stravis(&cwd, server_client_get_cwd(c, NULL), VIS_GLOB);
|
||||||
|
|
||||||
for (i = 0; i < args->argc; i++) {
|
for (i = 0; i < args->argc; i++) {
|
||||||
path = args->argv[i];
|
if (args_has(args, 'F')) {
|
||||||
|
free(expand);
|
||||||
|
expand = format_single_from_target(item, args->argv[i]);
|
||||||
|
path = expand;
|
||||||
|
} else
|
||||||
|
path = args->argv[i];
|
||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
cmd_source_file_add(cdata, "-");
|
cmd_source_file_add(cdata, "-");
|
||||||
continue;
|
continue;
|
||||||
|
@ -172,6 +177,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
free(pattern);
|
free(pattern);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
free(expand);
|
||||||
free(pattern);
|
free(pattern);
|
||||||
|
|
||||||
for (j = 0; j < g.gl_pathc; j++)
|
for (j = 0; j < g.gl_pathc; j++)
|
||||||
|
|
14
tmux.1
14
tmux.1
|
@ -1407,7 +1407,7 @@ and
|
||||||
.Fl T
|
.Fl T
|
||||||
show debugging information about jobs and terminals.
|
show debugging information about jobs and terminals.
|
||||||
.It Xo Ic source-file
|
.It Xo Ic source-file
|
||||||
.Op Fl nqv
|
.Op Fl Fnqv
|
||||||
.Ar path
|
.Ar path
|
||||||
.Ar ...
|
.Ar ...
|
||||||
.Xc
|
.Xc
|
||||||
|
@ -1418,6 +1418,11 @@ Execute commands from one or more files specified by
|
||||||
.Xr glob 7
|
.Xr glob 7
|
||||||
patterns).
|
patterns).
|
||||||
If
|
If
|
||||||
|
.Fl F
|
||||||
|
is present, then
|
||||||
|
.Ar path
|
||||||
|
is expanded as a format.
|
||||||
|
If
|
||||||
.Fl q
|
.Fl q
|
||||||
is given, no error will be returned if
|
is given, no error will be returned if
|
||||||
.Ar path
|
.Ar path
|
||||||
|
@ -5102,7 +5107,7 @@ section).
|
||||||
Commands to alter and view the environment are:
|
Commands to alter and view the environment are:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic set-environment
|
.It Xo Ic set-environment
|
||||||
.Op Fl hgru
|
.Op Fl Fhgru
|
||||||
.Op Fl t Ar target-session
|
.Op Fl t Ar target-session
|
||||||
.Ar name Op Ar value
|
.Ar name Op Ar value
|
||||||
.Xc
|
.Xc
|
||||||
|
@ -5113,6 +5118,11 @@ If
|
||||||
is used, the change is made in the global environment; otherwise, it is applied
|
is used, the change is made in the global environment; otherwise, it is applied
|
||||||
to the session environment for
|
to the session environment for
|
||||||
.Ar target-session .
|
.Ar target-session .
|
||||||
|
If
|
||||||
|
.Fl F
|
||||||
|
is present, then
|
||||||
|
.Ar value
|
||||||
|
is expanded as a format.
|
||||||
The
|
The
|
||||||
.Fl u
|
.Fl u
|
||||||
flag unsets a variable.
|
flag unsets a variable.
|
||||||
|
|
Loading…
Reference in New Issue