mirror of
https://github.com/tmux/tmux.git
synced 2024-11-19 10:58:51 +00:00
Merge branch 'obsd-master'
This commit is contained in:
commit
d346d692eb
@ -513,8 +513,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
|
|||||||
int focus_start = -1, focus_end = -1;
|
int focus_start = -1, focus_end = -1;
|
||||||
int list_state = -1, fill = -1;
|
int list_state = -1, fill = -1;
|
||||||
enum style_align list_align = STYLE_ALIGN_DEFAULT;
|
enum style_align list_align = STYLE_ALIGN_DEFAULT;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc, current_default;
|
||||||
struct style sy;
|
struct style sy, saved_sy;
|
||||||
struct utf8_data *ud = &sy.gc.data;
|
struct utf8_data *ud = &sy.gc.data;
|
||||||
const char *cp, *end;
|
const char *cp, *end;
|
||||||
enum utf8_state more;
|
enum utf8_state more;
|
||||||
@ -523,7 +523,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
|
|||||||
struct format_ranges frs;
|
struct format_ranges frs;
|
||||||
struct style_range *sr;
|
struct style_range *sr;
|
||||||
|
|
||||||
style_set(&sy, base);
|
memcpy(¤t_default, base, sizeof current_default);
|
||||||
|
style_set(&sy, ¤t_default);
|
||||||
TAILQ_INIT(&frs);
|
TAILQ_INIT(&frs);
|
||||||
log_debug("%s: %s", __func__, expanded);
|
log_debug("%s: %s", __func__, expanded);
|
||||||
|
|
||||||
@ -535,7 +536,7 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
|
|||||||
for (i = 0; i < TOTAL; i++) {
|
for (i = 0; i < TOTAL; i++) {
|
||||||
screen_init(&s[i], size, 1, 0);
|
screen_init(&s[i], size, 1, 0);
|
||||||
screen_write_start(&ctx[i], NULL, &s[i]);
|
screen_write_start(&ctx[i], NULL, &s[i]);
|
||||||
screen_write_clearendofline(&ctx[i], base->bg);
|
screen_write_clearendofline(&ctx[i], current_default.bg);
|
||||||
width[i] = 0;
|
width[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +582,8 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
tmp = xstrndup(cp + 2, end - (cp + 2));
|
tmp = xstrndup(cp + 2, end - (cp + 2));
|
||||||
if (style_parse(&sy, base, tmp) != 0) {
|
style_copy(&saved_sy, &sy);
|
||||||
|
if (style_parse(&sy, ¤t_default, tmp) != 0) {
|
||||||
log_debug("%s: invalid style '%s'", __func__, tmp);
|
log_debug("%s: invalid style '%s'", __func__, tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
cp = end + 1;
|
cp = end + 1;
|
||||||
@ -595,6 +597,15 @@ format_draw(struct screen_write_ctx *octx, const struct grid_cell *base,
|
|||||||
if (sy.fill != 8)
|
if (sy.fill != 8)
|
||||||
fill = sy.fill;
|
fill = sy.fill;
|
||||||
|
|
||||||
|
/* If this style pushed or popped the default, update it. */
|
||||||
|
if (sy.default_type == STYLE_DEFAULT_PUSH) {
|
||||||
|
memcpy(¤t_default, &saved_sy.gc, sizeof current_default);
|
||||||
|
sy.default_type = STYLE_DEFAULT_BASE;
|
||||||
|
} else if (sy.default_type == STYLE_DEFAULT_POP) {
|
||||||
|
memcpy(¤t_default, base, sizeof current_default);
|
||||||
|
sy.default_type = STYLE_DEFAULT_BASE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check the list state. */
|
/* Check the list state. */
|
||||||
switch (sy.list) {
|
switch (sy.list) {
|
||||||
case STYLE_LIST_ON:
|
case STYLE_LIST_ON:
|
||||||
|
@ -91,7 +91,9 @@ static const char *options_table_window_size_list[] = {
|
|||||||
"}" \
|
"}" \
|
||||||
"}" \
|
"}" \
|
||||||
"]" \
|
"]" \
|
||||||
|
"#[push-default]" \
|
||||||
"#{T:window-status-format}" \
|
"#{T:window-status-format}" \
|
||||||
|
"#[pop-default]" \
|
||||||
"#[norange default]" \
|
"#[norange default]" \
|
||||||
"#{?window_end_flag,,#{window-status-separator}}" \
|
"#{?window_end_flag,,#{window-status-separator}}" \
|
||||||
"," \
|
"," \
|
||||||
@ -116,7 +118,9 @@ static const char *options_table_window_size_list[] = {
|
|||||||
"}" \
|
"}" \
|
||||||
"}" \
|
"}" \
|
||||||
"]" \
|
"]" \
|
||||||
|
"#[push-default]" \
|
||||||
"#{T:window-status-current-format}" \
|
"#{T:window-status-current-format}" \
|
||||||
|
"#[pop-default]" \
|
||||||
"#[norange list=on default]" \
|
"#[norange list=on default]" \
|
||||||
"#{?window_end_flag,,#{window-status-separator}}" \
|
"#{?window_end_flag,,#{window-status-separator}}" \
|
||||||
"}" \
|
"}" \
|
||||||
|
39
style.c
39
style.c
@ -36,13 +36,15 @@ static struct style style_default = {
|
|||||||
STYLE_ALIGN_DEFAULT,
|
STYLE_ALIGN_DEFAULT,
|
||||||
STYLE_LIST_OFF,
|
STYLE_LIST_OFF,
|
||||||
|
|
||||||
STYLE_RANGE_NONE, 0
|
STYLE_RANGE_NONE, 0,
|
||||||
|
|
||||||
|
STYLE_DEFAULT_BASE
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse an embedded style of the form "fg=colour,bg=colour,bright,...".
|
* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". Note
|
||||||
* Note that this adds onto the given style, so it must have been initialized
|
* that this adds onto the given style, so it must have been initialized
|
||||||
* alredy.
|
* already.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
||||||
@ -74,7 +76,11 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
|||||||
sy->gc.bg = base->bg;
|
sy->gc.bg = base->bg;
|
||||||
sy->gc.attr = base->attr;
|
sy->gc.attr = base->attr;
|
||||||
sy->gc.flags = base->flags;
|
sy->gc.flags = base->flags;
|
||||||
} else if (strcasecmp(tmp, "nolist") == 0)
|
} else if (strcasecmp(tmp, "push-default") == 0)
|
||||||
|
sy->default_type = STYLE_DEFAULT_PUSH;
|
||||||
|
else if (strcasecmp(tmp, "pop-default") == 0)
|
||||||
|
sy->default_type = STYLE_DEFAULT_POP;
|
||||||
|
else if (strcasecmp(tmp, "nolist") == 0)
|
||||||
sy->list = STYLE_LIST_OFF;
|
sy->list = STYLE_LIST_OFF;
|
||||||
else if (strncasecmp(tmp, "list=", 5) == 0) {
|
else if (strncasecmp(tmp, "list=", 5) == 0) {
|
||||||
if (strcasecmp(tmp + 5, "on") == 0)
|
if (strcasecmp(tmp + 5, "on") == 0)
|
||||||
@ -218,6 +224,14 @@ style_tostring(struct style *sy)
|
|||||||
tmp);
|
tmp);
|
||||||
comma = ",";
|
comma = ",";
|
||||||
}
|
}
|
||||||
|
if (sy->default_type != STYLE_DEFAULT_BASE) {
|
||||||
|
if (sy->default_type == STYLE_DEFAULT_PUSH)
|
||||||
|
tmp = "push-default";
|
||||||
|
else if (sy->default_type == STYLE_DEFAULT_POP)
|
||||||
|
tmp = "pop-default";
|
||||||
|
off += xsnprintf(s + off, sizeof s - off, "%s%s", comma, tmp);
|
||||||
|
comma = ",";
|
||||||
|
}
|
||||||
if (sy->fill != 8) {
|
if (sy->fill != 8) {
|
||||||
off += xsnprintf(s + off, sizeof s - off, "%sfill=%s", comma,
|
off += xsnprintf(s + off, sizeof s - off, "%sfill=%s", comma,
|
||||||
colour_tostring(sy->fill));
|
colour_tostring(sy->fill));
|
||||||
@ -257,21 +271,6 @@ style_apply(struct grid_cell *gc, struct options *oo, const char *name)
|
|||||||
gc->attr |= sy->gc.attr;
|
gc->attr |= sy->gc.attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply a style, updating if default. */
|
|
||||||
void
|
|
||||||
style_apply_update(struct grid_cell *gc, struct options *oo, const char *name)
|
|
||||||
{
|
|
||||||
struct style *sy;
|
|
||||||
|
|
||||||
sy = options_get_style(oo, name);
|
|
||||||
if (sy->gc.fg != 8)
|
|
||||||
gc->fg = sy->gc.fg;
|
|
||||||
if (sy->gc.bg != 8)
|
|
||||||
gc->bg = sy->gc.bg;
|
|
||||||
if (sy->gc.attr != 0)
|
|
||||||
gc->attr |= sy->gc.attr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize style from cell. */
|
/* Initialize style from cell. */
|
||||||
void
|
void
|
||||||
style_set(struct style *sy, const struct grid_cell *gc)
|
style_set(struct style *sy, const struct grid_cell *gc)
|
||||||
|
18
tmux.1
18
tmux.1
@ -4340,7 +4340,9 @@ and
|
|||||||
.Pp
|
.Pp
|
||||||
A style may be the single term
|
A style may be the single term
|
||||||
.Ql default
|
.Ql default
|
||||||
to specify the default style (which may inherit from another option) or a space
|
to specify the default style (which may come from an option, for example
|
||||||
|
.Ic status-style
|
||||||
|
in the status line) or a space
|
||||||
or comma separated list of the following:
|
or comma separated list of the following:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Ic fg=colour
|
.It Ic fg=colour
|
||||||
@ -4419,6 +4421,20 @@ and
|
|||||||
.Ic list=right-marker
|
.Ic list=right-marker
|
||||||
mark the text to be used to mark that text has been trimmed from the left or
|
mark the text to be used to mark that text has been trimmed from the left or
|
||||||
right of the list if there is not enough space.
|
right of the list if there is not enough space.
|
||||||
|
.It Xo Ic push-default ,
|
||||||
|
.Ic pop-default
|
||||||
|
.Xc
|
||||||
|
Store the current colours and attributes as the default or reset to the previous
|
||||||
|
default.
|
||||||
|
A
|
||||||
|
.Ic push-default
|
||||||
|
affects any subsequent use of the
|
||||||
|
.Ic default
|
||||||
|
term until a
|
||||||
|
.Ic pop-default .
|
||||||
|
Only one default may be pushed (each
|
||||||
|
.Ic push-default
|
||||||
|
replaces the previous saved default).
|
||||||
.It Xo Ic range=left ,
|
.It Xo Ic range=left ,
|
||||||
.Ic range=right ,
|
.Ic range=right ,
|
||||||
.Ic range=window|X ,
|
.Ic range=window|X ,
|
||||||
|
11
tmux.h
11
tmux.h
@ -682,6 +682,13 @@ struct style_range {
|
|||||||
};
|
};
|
||||||
TAILQ_HEAD(style_ranges, style_range);
|
TAILQ_HEAD(style_ranges, style_range);
|
||||||
|
|
||||||
|
/* Style default. */
|
||||||
|
enum style_default_type {
|
||||||
|
STYLE_DEFAULT_BASE,
|
||||||
|
STYLE_DEFAULT_PUSH,
|
||||||
|
STYLE_DEFAULT_POP
|
||||||
|
};
|
||||||
|
|
||||||
/* Style option. */
|
/* Style option. */
|
||||||
struct style {
|
struct style {
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
@ -692,6 +699,8 @@ struct style {
|
|||||||
|
|
||||||
enum style_range_type range_type;
|
enum style_range_type range_type;
|
||||||
u_int range_argument;
|
u_int range_argument;
|
||||||
|
|
||||||
|
enum style_default_type default_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Virtual screen. */
|
/* Virtual screen. */
|
||||||
@ -2652,8 +2661,6 @@ int style_parse(struct style *,const struct grid_cell *,
|
|||||||
const char *style_tostring(struct style *);
|
const char *style_tostring(struct style *);
|
||||||
void style_apply(struct grid_cell *, struct options *,
|
void style_apply(struct grid_cell *, struct options *,
|
||||||
const char *);
|
const char *);
|
||||||
void style_apply_update(struct grid_cell *, struct options *,
|
|
||||||
const char *);
|
|
||||||
int style_equal(struct style *, struct style *);
|
int style_equal(struct style *, struct style *);
|
||||||
void style_set(struct style *, const struct grid_cell *);
|
void style_set(struct style *, const struct grid_cell *);
|
||||||
void style_copy(struct style *, struct style *);
|
void style_copy(struct style *, struct style *);
|
||||||
|
Loading…
Reference in New Issue
Block a user