mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add E: format to expand a format twice (useful to expand the value of an
option).
This commit is contained in:
parent
71e00c718c
commit
9032ac2a05
13
format.c
13
format.c
@ -94,6 +94,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2)
|
|||||||
#define FORMAT_DIRNAME 0x4
|
#define FORMAT_DIRNAME 0x4
|
||||||
#define FORMAT_QUOTE 0x8
|
#define FORMAT_QUOTE 0x8
|
||||||
#define FORMAT_LITERAL 0x10
|
#define FORMAT_LITERAL 0x10
|
||||||
|
#define FORMAT_EXPAND 0x20
|
||||||
|
|
||||||
/* Entry in format tree. */
|
/* Entry in format tree. */
|
||||||
struct format_entry {
|
struct format_entry {
|
||||||
@ -1012,7 +1013,7 @@ format_build_modifiers(struct format_tree *ft, const char **s, u_int *count)
|
|||||||
cp++;
|
cp++;
|
||||||
|
|
||||||
/* Check single character modifiers with no arguments. */
|
/* Check single character modifiers with no arguments. */
|
||||||
if (strchr("lmCbdtq", cp[0]) != NULL && format_is_end(cp[1])) {
|
if (strchr("lmCbdtqE", cp[0]) != NULL && format_is_end(cp[1])) {
|
||||||
format_add_modifier(&list, count, cp, 1, NULL, 0);
|
format_add_modifier(&list, count, cp, 1, NULL, 0);
|
||||||
cp++;
|
cp++;
|
||||||
continue;
|
continue;
|
||||||
@ -1189,6 +1190,9 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
|||||||
case 'q':
|
case 'q':
|
||||||
modifiers |= FORMAT_QUOTE;
|
modifiers |= FORMAT_QUOTE;
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
modifiers |= FORMAT_EXPAND;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (fm->size == 2) {
|
} else if (fm->size == 2) {
|
||||||
if (strcmp(fm->modifier, "||") == 0 ||
|
if (strcmp(fm->modifier, "||") == 0 ||
|
||||||
@ -1289,6 +1293,13 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
|
|||||||
value = xstrdup("");
|
value = xstrdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expand again if required. */
|
||||||
|
if (modifiers & FORMAT_EXPAND) {
|
||||||
|
new = format_expand(ft, value);
|
||||||
|
free(value);
|
||||||
|
value = new;
|
||||||
|
}
|
||||||
|
|
||||||
/* Perform substitution if any. */
|
/* Perform substitution if any. */
|
||||||
if (sub != NULL) {
|
if (sub != NULL) {
|
||||||
new = format_substitute(value, sub->argv[0], sub->argv[1]);
|
new = format_substitute(value, sub->argv[0], sub->argv[1]);
|
||||||
|
6
tmux.1
6
tmux.1
@ -3713,6 +3713,12 @@ of the variable respectively.
|
|||||||
will escape
|
will escape
|
||||||
.Xr sh 1
|
.Xr sh 1
|
||||||
special characters.
|
special characters.
|
||||||
|
.Ql E:
|
||||||
|
will expand the format twice, for example
|
||||||
|
.Ql #{E:status-left}
|
||||||
|
is the result of expanding the content of the
|
||||||
|
.Ic status-left
|
||||||
|
option rather than the content itself.
|
||||||
A prefix of the form
|
A prefix of the form
|
||||||
.Ql s/foo/bar/:
|
.Ql s/foo/bar/:
|
||||||
will substitute
|
will substitute
|
||||||
|
Loading…
Reference in New Issue
Block a user