mirror of
https://github.com/tmux/tmux.git
synced 2025-01-13 03:48:51 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
5fce21728e
@ -74,7 +74,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
struct environ *env;
|
struct environ *env;
|
||||||
struct termios tio, *tiop;
|
struct termios tio, *tiop;
|
||||||
const char *newname, *target, *update, *errstr, *template;
|
const char *newname, *target, *update, *errstr, *template;
|
||||||
const char *path, *cwd, *to_free;
|
const char *path, *cwd, *to_free = NULL;
|
||||||
char **argv, *cmd, *cause, *cp;
|
char **argv, *cmd, *cause, *cp;
|
||||||
int detached, already_attached, idx, argc;
|
int detached, already_attached, idx, argc;
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
@ -118,7 +118,12 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((target = args_get(args, 't')) == NULL)
|
if ((target = args_get(args, 't')) != NULL) {
|
||||||
|
if (groupwith == NULL) {
|
||||||
|
cmdq_error(cmdq, "no such session: %s", target);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else
|
||||||
groupwith = NULL;
|
groupwith = NULL;
|
||||||
|
|
||||||
/* Set -d if no client. */
|
/* Set -d if no client. */
|
||||||
@ -132,7 +137,6 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
already_attached = 1;
|
already_attached = 1;
|
||||||
|
|
||||||
/* Get the new session working directory. */
|
/* Get the new session working directory. */
|
||||||
to_free = NULL;
|
|
||||||
if (args_has(args, 'c')) {
|
if (args_has(args, 'c')) {
|
||||||
ft = format_create(cmdq, 0);
|
ft = format_create(cmdq, 0);
|
||||||
format_defaults(ft, c, NULL, NULL, NULL);
|
format_defaults(ft, c, NULL, NULL, NULL);
|
||||||
@ -208,7 +212,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (!args_has(args, 't') && args->argc != 0) {
|
if (!args_has(args, 't') && args->argc != 0) {
|
||||||
argc = args->argc;
|
argc = args->argc;
|
||||||
argv = args->argv;
|
argv = args->argv;
|
||||||
} else if (target == NULL) {
|
} else if (groupwith == NULL) {
|
||||||
cmd = options_get_string(global_s_options, "default-command");
|
cmd = options_get_string(global_s_options, "default-command");
|
||||||
if (cmd != NULL && *cmd != '\0') {
|
if (cmd != NULL && *cmd != '\0') {
|
||||||
argc = 1;
|
argc = 1;
|
||||||
@ -257,7 +261,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
* If a target session is given, this is to be part of a session group,
|
* If a target session is given, this is to be part of a session group,
|
||||||
* so add it to the group and synchronize.
|
* so add it to the group and synchronize.
|
||||||
*/
|
*/
|
||||||
if (args_has(args, 't')) {
|
if (groupwith != NULL) {
|
||||||
session_group_add(groupwith, s);
|
session_group_add(groupwith, s);
|
||||||
session_group_synchronize_to(s);
|
session_group_synchronize_to(s);
|
||||||
session_select(s, RB_MIN(winlinks, &s->windows)->idx);
|
session_select(s, RB_MIN(winlinks, &s->windows)->idx);
|
||||||
|
12
format.c
12
format.c
@ -701,7 +701,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
|||||||
char *copy, *copy0, *endptr, *ptr, *found, *new, *value;
|
char *copy, *copy0, *endptr, *ptr, *found, *new, *value;
|
||||||
char *from = NULL, *to = NULL;
|
char *from = NULL, *to = NULL;
|
||||||
size_t valuelen, newlen, fromlen, tolen, used;
|
size_t valuelen, newlen, fromlen, tolen, used;
|
||||||
u_long limit = 0;
|
long limit = 0;
|
||||||
int modifiers = 0, brackets;
|
int modifiers = 0, brackets;
|
||||||
|
|
||||||
/* Make a copy of the key. */
|
/* Make a copy of the key. */
|
||||||
@ -713,8 +713,8 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
|||||||
switch (copy[0]) {
|
switch (copy[0]) {
|
||||||
case '=':
|
case '=':
|
||||||
errno = 0;
|
errno = 0;
|
||||||
limit = strtoul(copy + 1, &endptr, 10);
|
limit = strtol(copy + 1, &endptr, 10);
|
||||||
if (errno == ERANGE && limit == ULONG_MAX)
|
if (errno == ERANGE && (limit == LONG_MIN || limit == LONG_MAX))
|
||||||
break;
|
break;
|
||||||
if (*endptr != ':')
|
if (*endptr != ':')
|
||||||
break;
|
break;
|
||||||
@ -830,10 +830,14 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Truncate the value if needed. */
|
/* Truncate the value if needed. */
|
||||||
if (limit != 0) {
|
if (limit > 0) {
|
||||||
new = utf8_trimcstr(value, limit);
|
new = utf8_trimcstr(value, limit);
|
||||||
free(value);
|
free(value);
|
||||||
value = new;
|
value = new;
|
||||||
|
} else if (limit < 0) {
|
||||||
|
new = utf8_rtrimcstr(value, -limit);
|
||||||
|
free(value);
|
||||||
|
value = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand the buffer and copy in the value. */
|
/* Expand the buffer and copy in the value. */
|
||||||
|
14
grid.c
14
grid.c
@ -452,6 +452,12 @@ grid_string_cells_fg(const struct grid_cell *gc, int *values)
|
|||||||
values[n++] = 38;
|
values[n++] = 38;
|
||||||
values[n++] = 5;
|
values[n++] = 5;
|
||||||
values[n++] = gc->fg;
|
values[n++] = gc->fg;
|
||||||
|
} else if (gc->flags & GRID_FLAG_FGRGB) {
|
||||||
|
values[n++] = 38;
|
||||||
|
values[n++] = 2;
|
||||||
|
values[n++] = gc->fg_rgb.r;
|
||||||
|
values[n++] = gc->fg_rgb.g;
|
||||||
|
values[n++] = gc->fg_rgb.b;
|
||||||
} else {
|
} else {
|
||||||
switch (gc->fg) {
|
switch (gc->fg) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -493,6 +499,12 @@ grid_string_cells_bg(const struct grid_cell *gc, int *values)
|
|||||||
values[n++] = 48;
|
values[n++] = 48;
|
||||||
values[n++] = 5;
|
values[n++] = 5;
|
||||||
values[n++] = gc->bg;
|
values[n++] = gc->bg;
|
||||||
|
} else if (gc->flags & GRID_FLAG_BGRGB) {
|
||||||
|
values[n++] = 48;
|
||||||
|
values[n++] = 2;
|
||||||
|
values[n++] = gc->bg_rgb.r;
|
||||||
|
values[n++] = gc->bg_rgb.g;
|
||||||
|
values[n++] = gc->bg_rgb.b;
|
||||||
} else {
|
} else {
|
||||||
switch (gc->bg) {
|
switch (gc->bg) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -532,7 +544,7 @@ void
|
|||||||
grid_string_cells_code(const struct grid_cell *lastgc,
|
grid_string_cells_code(const struct grid_cell *lastgc,
|
||||||
const struct grid_cell *gc, char *buf, size_t len, int escape_c0)
|
const struct grid_cell *gc, char *buf, size_t len, int escape_c0)
|
||||||
{
|
{
|
||||||
int oldc[16], newc[16], s[32];
|
int oldc[64], newc[64], s[128];
|
||||||
size_t noldc, nnewc, n, i;
|
size_t noldc, nnewc, n, i;
|
||||||
u_int attr = gc->attr;
|
u_int attr = gc->attr;
|
||||||
u_int lastattr = lastgc->attr;
|
u_int lastattr = lastgc->attr;
|
||||||
|
10
tmux.1
10
tmux.1
@ -3381,9 +3381,13 @@ if not.
|
|||||||
A limit may be placed on the length of the resultant string by prefixing it
|
A limit may be placed on the length of the resultant string by prefixing it
|
||||||
by an
|
by an
|
||||||
.Ql = ,
|
.Ql = ,
|
||||||
a number and a colon, so
|
a number and a colon.
|
||||||
.Ql #{=10:pane_title}
|
Positive numbers count from the start of the string and negative from the end,
|
||||||
will include at most the first 10 characters of the pane title.
|
so
|
||||||
|
.Ql #{=5:pane_title}
|
||||||
|
will include at most the first 5 characters of the pane title, or
|
||||||
|
.Ql #{=-5:pane_title}
|
||||||
|
the last 5 characters.
|
||||||
Prefixing a time variable with
|
Prefixing a time variable with
|
||||||
.Ql t:
|
.Ql t:
|
||||||
will convert it to a string, so if
|
will convert it to a string, so if
|
||||||
|
1
tmux.h
1
tmux.h
@ -2326,6 +2326,7 @@ char *utf8_sanitize(const char *);
|
|||||||
struct utf8_data *utf8_fromcstr(const char *);
|
struct utf8_data *utf8_fromcstr(const char *);
|
||||||
char *utf8_tocstr(struct utf8_data *);
|
char *utf8_tocstr(struct utf8_data *);
|
||||||
u_int utf8_cstrwidth(const char *);
|
u_int utf8_cstrwidth(const char *);
|
||||||
|
char *utf8_rtrimcstr(const char *, u_int);
|
||||||
char *utf8_trimcstr(const char *, u_int);
|
char *utf8_trimcstr(const char *, u_int);
|
||||||
char *utf8_padcstr(const char *, u_int);
|
char *utf8_padcstr(const char *, u_int);
|
||||||
|
|
||||||
|
37
utf8.c
37
utf8.c
@ -723,6 +723,43 @@ utf8_trimcstr(const char *s, u_int width)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Trim UTF-8 string to width. Caller frees. */
|
||||||
|
char *
|
||||||
|
utf8_rtrimcstr(const char *s, u_int width)
|
||||||
|
{
|
||||||
|
struct utf8_data *tmp, *next, *end;
|
||||||
|
char *out;
|
||||||
|
u_int at;
|
||||||
|
|
||||||
|
tmp = utf8_fromcstr(s);
|
||||||
|
|
||||||
|
for (end = tmp; end->size != 0; end++)
|
||||||
|
/* nothing */;
|
||||||
|
if (end == tmp) {
|
||||||
|
free(tmp);
|
||||||
|
return (xstrdup(""));
|
||||||
|
}
|
||||||
|
next = end - 1;
|
||||||
|
|
||||||
|
at = 0;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (at + next->width > width) {
|
||||||
|
next++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
at += next->width;
|
||||||
|
|
||||||
|
if (next == tmp)
|
||||||
|
break;
|
||||||
|
next--;
|
||||||
|
}
|
||||||
|
|
||||||
|
out = utf8_tocstr(next);
|
||||||
|
free(tmp);
|
||||||
|
return (out);
|
||||||
|
}
|
||||||
|
|
||||||
/* Pad UTF-8 string to width. Caller frees. */
|
/* Pad UTF-8 string to width. Caller frees. */
|
||||||
char *
|
char *
|
||||||
utf8_padcstr(const char *s, u_int width)
|
utf8_padcstr(const char *s, u_int width)
|
||||||
|
Loading…
Reference in New Issue
Block a user