mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Add a wrapper (struct style) around styles rather than using the
grid_cell directly. There will be some non-cell members soon.
This commit is contained in:
parent
1e9f8a3523
commit
13f9a061ac
@ -90,6 +90,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
struct window *w = wl->window;
|
||||
struct session *s = item->target.s;
|
||||
struct window_pane *wp = item->target.wp, *lastwp, *markedwp;
|
||||
struct style *sy = &wp->style;
|
||||
char *pane_title;
|
||||
const char *style;
|
||||
|
||||
@ -142,19 +143,16 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||
}
|
||||
|
||||
if (args_has(self->args, 'P') || args_has(self->args, 'g')) {
|
||||
if (args_has(args, 'P')) {
|
||||
style = args_get(args, 'P');
|
||||
memcpy(&wp->colgc, &grid_default_cell,
|
||||
sizeof wp->colgc);
|
||||
if (style_parse(&grid_default_cell, &wp->colgc,
|
||||
style) == -1) {
|
||||
if ((style = args_get(args, 'P')) != NULL) {
|
||||
style_set(sy, &grid_default_cell);
|
||||
if (style_parse(sy, &grid_default_cell, style) == -1) {
|
||||
cmdq_error(item, "bad style: %s", style);
|
||||
return (CMD_RETURN_ERROR);
|
||||
}
|
||||
wp->flags |= PANE_REDRAW;
|
||||
}
|
||||
if (args_has(self->args, 'g'))
|
||||
cmdq_print(item, "%s", style_tostring(&wp->colgc));
|
||||
cmdq_print(item, "%s", style_tostring(sy));
|
||||
return (CMD_RETURN_NORMAL);
|
||||
}
|
||||
|
||||
|
4
input.c
4
input.c
@ -2340,7 +2340,7 @@ input_osc_10(struct input_ctx *ictx, const char *p)
|
||||
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3)
|
||||
goto bad;
|
||||
|
||||
wp->colgc.fg = colour_join_rgb(r, g, b);
|
||||
wp->style.gc.fg = colour_join_rgb(r, g, b);
|
||||
wp->flags |= PANE_REDRAW;
|
||||
|
||||
return;
|
||||
@ -2359,7 +2359,7 @@ input_osc_11(struct input_ctx *ictx, const char *p)
|
||||
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3)
|
||||
goto bad;
|
||||
|
||||
wp->colgc.bg = colour_join_rgb(r, g, b);
|
||||
wp->style.gc.bg = colour_join_rgb(r, g, b);
|
||||
wp->flags |= PANE_REDRAW;
|
||||
|
||||
return;
|
||||
|
30
options.c
30
options.c
@ -39,7 +39,7 @@ struct options_entry {
|
||||
union {
|
||||
char *string;
|
||||
long long number;
|
||||
struct grid_cell style;
|
||||
struct style style;
|
||||
struct {
|
||||
const char **array;
|
||||
u_int arraysize;
|
||||
@ -177,8 +177,8 @@ options_default(struct options *oo, const struct options_table_entry *oe)
|
||||
else if (oe->type == OPTIONS_TABLE_STRING)
|
||||
o->string = xstrdup(oe->default_str);
|
||||
else if (oe->type == OPTIONS_TABLE_STYLE) {
|
||||
memcpy(&o->style, &grid_default_cell, sizeof o->style);
|
||||
style_parse(&grid_default_cell, &o->style, oe->default_str);
|
||||
style_set(&o->style, &grid_default_cell);
|
||||
style_parse(&o->style, &grid_default_cell, oe->default_str);
|
||||
} else
|
||||
o->number = oe->default_num;
|
||||
return (o);
|
||||
@ -504,7 +504,7 @@ options_get_number(struct options *oo, const char *name)
|
||||
return (o->number);
|
||||
}
|
||||
|
||||
const struct grid_cell *
|
||||
struct style *
|
||||
options_get_style(struct options *oo, const char *name)
|
||||
{
|
||||
struct options_entry *o;
|
||||
@ -576,17 +576,17 @@ options_set_style(struct options *oo, const char *name, int append,
|
||||
const char *value)
|
||||
{
|
||||
struct options_entry *o;
|
||||
struct grid_cell gc;
|
||||
struct style sy;
|
||||
|
||||
if (*name == '@')
|
||||
fatalx("user option %s must be a string", name);
|
||||
|
||||
o = options_get_only(oo, name);
|
||||
if (o != NULL && append && OPTIONS_IS_STYLE(o))
|
||||
memcpy(&gc, &o->style, sizeof gc);
|
||||
style_copy(&sy, &o->style);
|
||||
else
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
if (style_parse(&grid_default_cell, &gc, value) == -1)
|
||||
style_set(&sy, &grid_default_cell);
|
||||
if (style_parse(&sy, &grid_default_cell, value) == -1)
|
||||
return (NULL);
|
||||
if (o == NULL) {
|
||||
o = options_default(oo, options_parent_table_entry(oo, name));
|
||||
@ -596,7 +596,7 @@ options_set_style(struct options *oo, const char *name, int append,
|
||||
|
||||
if (!OPTIONS_IS_STYLE(o))
|
||||
fatalx("option %s is not a style", name);
|
||||
memcpy(&o->style, &gc, sizeof o->style);
|
||||
style_copy(&o->style, &sy);
|
||||
return (o);
|
||||
}
|
||||
|
||||
@ -657,11 +657,11 @@ options_style_update_new(struct options *oo, struct options_entry *o)
|
||||
new = options_set_style(oo, newname, 0, "default");
|
||||
|
||||
if (strstr(o->name, "-bg") != NULL)
|
||||
new->style.bg = o->number;
|
||||
new->style.gc.bg = o->number;
|
||||
else if (strstr(o->name, "-fg") != NULL)
|
||||
new->style.fg = o->number;
|
||||
new->style.gc.fg = o->number;
|
||||
else if (strstr(o->name, "-attr") != NULL)
|
||||
new->style.attr = o->number;
|
||||
new->style.gc.attr = o->number;
|
||||
}
|
||||
|
||||
void
|
||||
@ -674,13 +674,13 @@ options_style_update_old(struct options *oo, struct options_entry *o)
|
||||
|
||||
xsnprintf(newname, sizeof newname, "%.*s-bg", size, o->name);
|
||||
if (options_get(oo, newname) != NULL)
|
||||
options_set_number(oo, newname, o->style.bg);
|
||||
options_set_number(oo, newname, o->style.gc.bg);
|
||||
|
||||
xsnprintf(newname, sizeof newname, "%.*s-fg", size, o->name);
|
||||
if (options_get(oo, newname) != NULL)
|
||||
options_set_number(oo, newname, o->style.fg);
|
||||
options_set_number(oo, newname, o->style.gc.fg);
|
||||
|
||||
xsnprintf(newname, sizeof newname, "%.*s-attr", size, o->name);
|
||||
if (options_get(oo, newname) != NULL)
|
||||
options_set_number(oo, newname, o->style.attr);
|
||||
options_set_number(oo, newname, o->style.gc.attr);
|
||||
}
|
||||
|
@ -327,15 +327,15 @@ void
|
||||
screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||
const struct grid_cell *gcp, const char *fmt, ...)
|
||||
{
|
||||
struct grid_cell gc;
|
||||
struct utf8_data *ud = &gc.data;
|
||||
struct style sy;
|
||||
struct utf8_data *ud = &sy.gc.data;
|
||||
va_list ap;
|
||||
char *msg;
|
||||
u_char *ptr, *last;
|
||||
size_t left, size = 0;
|
||||
enum utf8_state more;
|
||||
|
||||
memcpy(&gc, gcp, sizeof gc);
|
||||
style_set(&sy, gcp);
|
||||
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
@ -352,7 +352,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||
}
|
||||
*last = '\0';
|
||||
|
||||
style_parse(gcp, &gc, ptr);
|
||||
style_parse(&sy, gcp, ptr);
|
||||
ptr = last + 1;
|
||||
continue;
|
||||
}
|
||||
@ -370,22 +370,22 @@ screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
|
||||
continue;
|
||||
if (maxlen > 0 && size + ud->width > (size_t)maxlen) {
|
||||
while (size < (size_t)maxlen) {
|
||||
screen_write_putc(ctx, &gc, ' ');
|
||||
screen_write_putc(ctx, &sy.gc, ' ');
|
||||
size++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
size += ud->width;
|
||||
screen_write_cell(ctx, &gc);
|
||||
screen_write_cell(ctx, &sy.gc);
|
||||
} else {
|
||||
if (maxlen > 0 && size + 1 > (size_t)maxlen)
|
||||
break;
|
||||
|
||||
if (*ptr == '\001')
|
||||
gc.attr ^= GRID_ATTR_CHARSET;
|
||||
sy.gc.attr ^= GRID_ATTR_CHARSET;
|
||||
else if (*ptr > 0x1f && *ptr < 0x7f) {
|
||||
size++;
|
||||
screen_write_putc(ctx, &gc, *ptr);
|
||||
screen_write_putc(ctx, &sy.gc, *ptr);
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
|
152
style.c
152
style.c
@ -23,27 +23,40 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
/* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */
|
||||
/* Mask for bits not included in style. */
|
||||
#define STYLE_ATTR_MASK (~GRID_ATTR_CHARSET)
|
||||
|
||||
/* Default style. */
|
||||
static struct style style_default = {
|
||||
{ 0, 0, 8, 8, { { ' ' }, 0, 1, 1 } }
|
||||
};
|
||||
|
||||
/*
|
||||
* Parse an embedded style of the form "fg=colour,bg=colour,bright,...".
|
||||
* Note that this adds onto the given style, so it must have been initialized
|
||||
* alredy.
|
||||
*/
|
||||
int
|
||||
style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
||||
const char *in)
|
||||
style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
||||
{
|
||||
struct grid_cell savedgc;
|
||||
const char delimiters[] = " ,";
|
||||
char tmp[32];
|
||||
int val, fg, bg, attr, flags;
|
||||
size_t end;
|
||||
struct grid_cell *gc = &sy->gc;
|
||||
struct grid_cell saved;
|
||||
const char delimiters[] = " ,";
|
||||
char tmp[32];
|
||||
int value, fg, bg, attr, flags;
|
||||
size_t end;
|
||||
|
||||
if (*in == '\0')
|
||||
return (0);
|
||||
if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
|
||||
return (-1);
|
||||
memcpy(&savedgc, gc, sizeof savedgc);
|
||||
memcpy(&saved, base, sizeof saved);
|
||||
|
||||
fg = gc->fg;
|
||||
bg = gc->bg;
|
||||
attr = gc->attr;
|
||||
flags = gc->flags;
|
||||
|
||||
do {
|
||||
end = strcspn(in, delimiters);
|
||||
if (end > (sizeof tmp) - 1)
|
||||
@ -52,39 +65,40 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
||||
tmp[end] = '\0';
|
||||
|
||||
if (strcasecmp(tmp, "default") == 0) {
|
||||
fg = defgc->fg;
|
||||
bg = defgc->bg;
|
||||
attr = defgc->attr;
|
||||
flags = defgc->flags;
|
||||
fg = base->fg;
|
||||
bg = base->bg;
|
||||
attr = base->attr;
|
||||
flags = base->flags;
|
||||
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
|
||||
if ((val = colour_fromstring(tmp + 3)) == -1)
|
||||
if ((value = colour_fromstring(tmp + 3)) == -1)
|
||||
goto error;
|
||||
if (*in == 'f' || *in == 'F') {
|
||||
if (val != 8)
|
||||
fg = val;
|
||||
if (value != 8)
|
||||
fg = value;
|
||||
else
|
||||
fg = defgc->fg;
|
||||
fg = base->fg;
|
||||
} else if (*in == 'b' || *in == 'B') {
|
||||
if (val != 8)
|
||||
bg = val;
|
||||
if (value != 8)
|
||||
bg = value;
|
||||
else
|
||||
bg = defgc->bg;
|
||||
bg = base->bg;
|
||||
} else
|
||||
goto error;
|
||||
} else if (strcasecmp(tmp, "none") == 0)
|
||||
attr = 0;
|
||||
else if (end > 2 && strncasecmp(tmp, "no", 2) == 0) {
|
||||
if ((val = attributes_fromstring(tmp + 2)) == -1)
|
||||
if ((value = attributes_fromstring(tmp + 2)) == -1)
|
||||
goto error;
|
||||
attr &= ~val;
|
||||
attr &= ~value;
|
||||
} else {
|
||||
if ((val = attributes_fromstring(tmp)) == -1)
|
||||
if ((value = attributes_fromstring(tmp)) == -1)
|
||||
goto error;
|
||||
attr |= val;
|
||||
attr |= value;
|
||||
}
|
||||
|
||||
in += end + strspn(in + end, delimiters);
|
||||
} while (*in != '\0');
|
||||
|
||||
gc->fg = fg;
|
||||
gc->bg = bg;
|
||||
gc->attr = attr;
|
||||
@ -93,33 +107,35 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
|
||||
return (0);
|
||||
|
||||
error:
|
||||
memcpy(gc, &savedgc, sizeof *gc);
|
||||
memcpy(gc, &saved, sizeof *gc);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* Convert style to a string. */
|
||||
const char *
|
||||
style_tostring(struct grid_cell *gc)
|
||||
style_tostring(struct style *sy)
|
||||
{
|
||||
int off = 0, comma = 0;
|
||||
static char s[256];
|
||||
struct grid_cell *gc = &sy->gc;
|
||||
int off = 0;
|
||||
const char *comma = "";
|
||||
static char s[256];
|
||||
|
||||
*s = '\0';
|
||||
|
||||
if (gc->fg != 8) {
|
||||
off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(gc->fg));
|
||||
comma = 1;
|
||||
off += xsnprintf(s + off, sizeof s - off, "%sfg=%s",
|
||||
comma, colour_tostring(gc->fg));
|
||||
comma = ",";
|
||||
}
|
||||
|
||||
if (gc->bg != 8) {
|
||||
off += xsnprintf(s + off, sizeof s - off, "%sbg=%s",
|
||||
comma ? "," : "", colour_tostring(gc->bg));
|
||||
comma = 1;
|
||||
comma, colour_tostring(gc->bg));
|
||||
comma = ",";
|
||||
}
|
||||
|
||||
if (gc->attr != 0 && gc->attr != GRID_ATTR_CHARSET) {
|
||||
xsnprintf(s + off, sizeof s - off, "%s%s",
|
||||
comma ? "," : "", attributes_tostring(gc->attr));
|
||||
comma, attributes_tostring(gc->attr));
|
||||
comma = ",";
|
||||
}
|
||||
|
||||
if (*s == '\0')
|
||||
@ -131,38 +147,64 @@ style_tostring(struct grid_cell *gc)
|
||||
void
|
||||
style_apply(struct grid_cell *gc, struct options *oo, const char *name)
|
||||
{
|
||||
const struct grid_cell *gcp;
|
||||
struct style *sy;
|
||||
|
||||
memcpy(gc, &grid_default_cell, sizeof *gc);
|
||||
gcp = options_get_style(oo, name);
|
||||
gc->fg = gcp->fg;
|
||||
gc->bg = gcp->bg;
|
||||
gc->attr |= gcp->attr;
|
||||
sy = options_get_style(oo, name);
|
||||
gc->fg = sy->gc.fg;
|
||||
gc->bg = sy->gc.bg;
|
||||
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)
|
||||
{
|
||||
const struct grid_cell *gcp;
|
||||
struct style *sy;
|
||||
|
||||
gcp = options_get_style(oo, name);
|
||||
if (gcp->fg != 8)
|
||||
gc->fg = gcp->fg;
|
||||
if (gcp->bg != 8)
|
||||
gc->bg = gcp->bg;
|
||||
if (gcp->attr != 0)
|
||||
gc->attr |= gcp->attr;
|
||||
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. */
|
||||
void
|
||||
style_set(struct style *sy, const struct grid_cell *gc)
|
||||
{
|
||||
memset(sy, 0, sizeof *sy);
|
||||
memcpy(&sy->gc, gc, sizeof sy->gc);
|
||||
}
|
||||
|
||||
/* Copy style. */
|
||||
void
|
||||
style_copy(struct style *dst, struct style *src)
|
||||
{
|
||||
memcpy(dst, src, sizeof *dst);
|
||||
}
|
||||
|
||||
/* Check if two styles are the same. */
|
||||
int
|
||||
style_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
|
||||
style_equal(struct style *sy1, struct style *sy2)
|
||||
{
|
||||
return (gc1->fg == gc2->fg &&
|
||||
gc1->bg == gc2->bg &&
|
||||
(gc1->flags & ~GRID_FLAG_PADDING) ==
|
||||
(gc2->flags & ~GRID_FLAG_PADDING) &&
|
||||
(gc1->attr & ~GRID_ATTR_CHARSET) ==
|
||||
(gc2->attr & ~GRID_ATTR_CHARSET));
|
||||
struct grid_cell *gc1 = &sy1->gc;
|
||||
struct grid_cell *gc2 = &sy2->gc;
|
||||
|
||||
if (gc1->fg != gc2->fg)
|
||||
return (0);
|
||||
if (gc1->bg != gc2->bg)
|
||||
return (0);
|
||||
if ((gc1->attr & STYLE_ATTR_MASK) != (gc2->attr & STYLE_ATTR_MASK))
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Is this style default? */
|
||||
int
|
||||
style_is_default(struct style *sy)
|
||||
{
|
||||
return (style_equal(sy, &style_default));
|
||||
}
|
||||
|
32
tmux.h
32
tmux.h
@ -634,6 +634,11 @@ struct grid {
|
||||
struct grid_line *linedata;
|
||||
};
|
||||
|
||||
/* Style option. */
|
||||
struct style {
|
||||
struct grid_cell gc;
|
||||
};
|
||||
|
||||
/* Hook data structures. */
|
||||
struct hook {
|
||||
const char *name;
|
||||
@ -778,8 +783,7 @@ struct window_pane {
|
||||
|
||||
struct input_ctx *ictx;
|
||||
|
||||
struct grid_cell colgc;
|
||||
|
||||
struct style style;
|
||||
int *palette;
|
||||
|
||||
int pipe_fd;
|
||||
@ -847,8 +851,8 @@ struct window {
|
||||
|
||||
struct options *options;
|
||||
|
||||
struct grid_cell style;
|
||||
struct grid_cell active_style;
|
||||
struct style style;
|
||||
struct style active_style;
|
||||
|
||||
u_int references;
|
||||
TAILQ_HEAD(, winlink) winlinks;
|
||||
@ -1649,7 +1653,7 @@ struct options_entry *options_match_get(struct options *, const char *, int *,
|
||||
int, int *);
|
||||
const char *options_get_string(struct options *, const char *);
|
||||
long long options_get_number(struct options *, const char *);
|
||||
const struct grid_cell *options_get_style(struct options *, const char *);
|
||||
struct style *options_get_style(struct options *, const char *);
|
||||
struct options_entry * printflike(4, 5) options_set_string(struct options *,
|
||||
const char *, int, const char *, ...);
|
||||
struct options_entry *options_set_number(struct options *, const char *,
|
||||
@ -1707,7 +1711,7 @@ void tty_update_window_offset(struct window *);
|
||||
void tty_update_client_offset(struct client *);
|
||||
void tty_raw(struct tty *, const char *);
|
||||
void tty_attributes(struct tty *, const struct grid_cell *,
|
||||
const struct window_pane *);
|
||||
struct window_pane *);
|
||||
void tty_reset(struct tty *);
|
||||
void tty_region_off(struct tty *);
|
||||
void tty_margin_off(struct tty *);
|
||||
@ -1729,7 +1733,7 @@ void tty_start_tty(struct tty *);
|
||||
void tty_stop_tty(struct tty *);
|
||||
void tty_set_title(struct tty *, const char *);
|
||||
void tty_update_mode(struct tty *, int, struct screen *);
|
||||
void tty_draw_line(struct tty *, const struct window_pane *, struct screen *,
|
||||
void tty_draw_line(struct tty *, struct window_pane *, struct screen *,
|
||||
u_int, u_int, u_int, u_int, u_int);
|
||||
int tty_open(struct tty *, char **);
|
||||
void tty_close(struct tty *);
|
||||
@ -2207,7 +2211,7 @@ void window_pane_alternate_off(struct window_pane *,
|
||||
void window_pane_set_palette(struct window_pane *, u_int, int);
|
||||
void window_pane_unset_palette(struct window_pane *, u_int);
|
||||
void window_pane_reset_palette(struct window_pane *);
|
||||
int window_pane_get_palette(const struct window_pane *, int);
|
||||
int window_pane_get_palette(struct window_pane *, int);
|
||||
int window_pane_set_mode(struct window_pane *,
|
||||
const struct window_mode *, struct cmd_find_state *,
|
||||
struct args *);
|
||||
@ -2420,14 +2424,16 @@ __dead void printflike(1, 2) fatal(const char *, ...);
|
||||
__dead void printflike(1, 2) fatalx(const char *, ...);
|
||||
|
||||
/* style.c */
|
||||
int style_parse(const struct grid_cell *,
|
||||
struct grid_cell *, const char *);
|
||||
const char *style_tostring(struct grid_cell *);
|
||||
int style_parse(struct style *,const struct grid_cell *,
|
||||
const char *);
|
||||
const char *style_tostring(struct style *);
|
||||
void style_apply(struct grid_cell *, struct options *,
|
||||
const char *);
|
||||
void style_apply_update(struct grid_cell *, struct options *,
|
||||
const char *);
|
||||
int style_equal(const struct grid_cell *,
|
||||
const struct grid_cell *);
|
||||
int style_equal(struct style *, struct style *);
|
||||
void style_set(struct style *, const struct grid_cell *);
|
||||
void style_copy(struct style *, struct style *);
|
||||
int style_is_default(struct style *);
|
||||
|
||||
#endif /* TMUX_H */
|
||||
|
79
tty.c
79
tty.c
@ -45,9 +45,9 @@ static void tty_cursor_pane_unless_wrap(struct tty *,
|
||||
const struct tty_ctx *, u_int, u_int);
|
||||
static void tty_invalidate(struct tty *);
|
||||
static void tty_colours(struct tty *, const struct grid_cell *);
|
||||
static void tty_check_fg(struct tty *, const struct window_pane *,
|
||||
static void tty_check_fg(struct tty *, struct window_pane *,
|
||||
struct grid_cell *);
|
||||
static void tty_check_bg(struct tty *, const struct window_pane *,
|
||||
static void tty_check_bg(struct tty *, struct window_pane *,
|
||||
struct grid_cell *);
|
||||
static void tty_colours_fg(struct tty *, const struct grid_cell *);
|
||||
static void tty_colours_bg(struct tty *, const struct grid_cell *);
|
||||
@ -58,18 +58,16 @@ static void tty_region(struct tty *, u_int, u_int);
|
||||
static void tty_margin_pane(struct tty *, const struct tty_ctx *);
|
||||
static void tty_margin(struct tty *, u_int, u_int);
|
||||
static int tty_large_region(struct tty *, const struct tty_ctx *);
|
||||
static int tty_fake_bce(const struct tty *, const struct window_pane *,
|
||||
u_int);
|
||||
static int tty_fake_bce(const struct tty *, struct window_pane *, u_int);
|
||||
static void tty_redraw_region(struct tty *, const struct tty_ctx *);
|
||||
static void tty_emulate_repeat(struct tty *, enum tty_code_code,
|
||||
enum tty_code_code, u_int);
|
||||
static void tty_repeat_space(struct tty *, u_int);
|
||||
static void tty_draw_pane(struct tty *, const struct tty_ctx *, u_int);
|
||||
static void tty_cell(struct tty *, const struct grid_cell *,
|
||||
const struct window_pane *);
|
||||
static void tty_default_colours(struct grid_cell *,
|
||||
const struct window_pane *);
|
||||
static void tty_default_attributes(struct tty *, const struct window_pane *,
|
||||
struct window_pane *);
|
||||
static void tty_default_colours(struct grid_cell *, struct window_pane *);
|
||||
static void tty_default_attributes(struct tty *, struct window_pane *,
|
||||
u_int);
|
||||
|
||||
#define tty_use_margin(tty) \
|
||||
@ -847,7 +845,7 @@ tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
|
||||
* emulated.
|
||||
*/
|
||||
static int
|
||||
tty_fake_bce(const struct tty *tty, const struct window_pane *wp, u_int bg)
|
||||
tty_fake_bce(const struct tty *tty, struct window_pane *wp, u_int bg)
|
||||
{
|
||||
struct grid_cell gc;
|
||||
|
||||
@ -956,8 +954,8 @@ tty_clamp_line(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
|
||||
|
||||
/* Clear a line. */
|
||||
static void
|
||||
tty_clear_line(struct tty *tty, const struct window_pane *wp, u_int py,
|
||||
u_int px, u_int nx, u_int bg)
|
||||
tty_clear_line(struct tty *tty, struct window_pane *wp, u_int py, u_int px,
|
||||
u_int nx, u_int bg)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
|
||||
@ -1075,8 +1073,8 @@ tty_clamp_area(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
|
||||
|
||||
/* Clear an area, adjusting to visible part of pane. */
|
||||
static void
|
||||
tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py,
|
||||
u_int ny, u_int px, u_int nx, u_int bg)
|
||||
tty_clear_area(struct tty *tty, struct window_pane *wp, u_int py, u_int ny,
|
||||
u_int px, u_int nx, u_int bg)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
u_int yy;
|
||||
@ -1198,8 +1196,8 @@ tty_check_codeset(struct tty *tty, const struct grid_cell *gc)
|
||||
}
|
||||
|
||||
void
|
||||
tty_draw_line(struct tty *tty, const struct window_pane *wp,
|
||||
struct screen *s, u_int px, u_int py, u_int nx, u_int atx, u_int aty)
|
||||
tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s,
|
||||
u_int px, u_int py, u_int nx, u_int atx, u_int aty)
|
||||
{
|
||||
struct grid *gd = s->grid;
|
||||
struct grid_cell gc, last;
|
||||
@ -1802,8 +1800,7 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx)
|
||||
}
|
||||
|
||||
static void
|
||||
tty_cell(struct tty *tty, const struct grid_cell *gc,
|
||||
const struct window_pane *wp)
|
||||
tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp)
|
||||
{
|
||||
const struct grid_cell *gcp;
|
||||
|
||||
@ -2117,7 +2114,7 @@ out:
|
||||
|
||||
void
|
||||
tty_attributes(struct tty *tty, const struct grid_cell *gc,
|
||||
const struct window_pane *wp)
|
||||
struct window_pane *wp)
|
||||
{
|
||||
struct grid_cell *tc = &tty->cell, gc2;
|
||||
int changed;
|
||||
@ -2265,8 +2262,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc)
|
||||
}
|
||||
|
||||
static void
|
||||
tty_check_fg(struct tty *tty, const struct window_pane *wp,
|
||||
struct grid_cell *gc)
|
||||
tty_check_fg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc)
|
||||
{
|
||||
u_char r, g, b;
|
||||
u_int colours;
|
||||
@ -2326,8 +2322,7 @@ tty_check_fg(struct tty *tty, const struct window_pane *wp,
|
||||
}
|
||||
|
||||
static void
|
||||
tty_check_bg(struct tty *tty, const struct window_pane *wp,
|
||||
struct grid_cell *gc)
|
||||
tty_check_bg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc)
|
||||
{
|
||||
u_char r, g, b;
|
||||
u_int colours;
|
||||
@ -2499,32 +2494,32 @@ fallback_256:
|
||||
}
|
||||
|
||||
static void
|
||||
tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
|
||||
tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
|
||||
{
|
||||
struct window *w = wp->window;
|
||||
struct options *oo = w->options;
|
||||
const struct grid_cell *agc, *pgc, *wgc;
|
||||
struct style *active, *pane, *window;
|
||||
int c;
|
||||
|
||||
if (w->flags & WINDOW_STYLECHANGED) {
|
||||
w->flags &= ~WINDOW_STYLECHANGED;
|
||||
agc = options_get_style(oo, "window-active-style");
|
||||
memcpy(&w->active_style, agc, sizeof w->active_style);
|
||||
wgc = options_get_style(oo, "window-style");
|
||||
memcpy(&w->style, wgc, sizeof w->style);
|
||||
active = options_get_style(oo, "window-active-style");
|
||||
style_copy(&w->active_style, active);
|
||||
window = options_get_style(oo, "window-style");
|
||||
style_copy(&w->style, window);
|
||||
} else {
|
||||
agc = &w->active_style;
|
||||
wgc = &w->style;
|
||||
active = &w->active_style;
|
||||
window = &w->style;
|
||||
}
|
||||
pgc = &wp->colgc;
|
||||
pane = &wp->style;
|
||||
|
||||
if (gc->fg == 8) {
|
||||
if (pgc->fg != 8)
|
||||
gc->fg = pgc->fg;
|
||||
else if (wp == w->active && agc->fg != 8)
|
||||
gc->fg = agc->fg;
|
||||
if (pane->gc.fg != 8)
|
||||
gc->fg = pane->gc.fg;
|
||||
else if (wp == w->active && active->gc.fg != 8)
|
||||
gc->fg = active->gc.fg;
|
||||
else
|
||||
gc->fg = wgc->fg;
|
||||
gc->fg = window->gc.fg;
|
||||
|
||||
if (gc->fg != 8) {
|
||||
c = window_pane_get_palette(wp, gc->fg);
|
||||
@ -2534,12 +2529,12 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
|
||||
}
|
||||
|
||||
if (gc->bg == 8) {
|
||||
if (pgc->bg != 8)
|
||||
gc->bg = pgc->bg;
|
||||
else if (wp == w->active && agc->bg != 8)
|
||||
gc->bg = agc->bg;
|
||||
if (pane->gc.bg != 8)
|
||||
gc->bg = pane->gc.bg;
|
||||
else if (wp == w->active && active->gc.bg != 8)
|
||||
gc->bg = active->gc.bg;
|
||||
else
|
||||
gc->bg = wgc->bg;
|
||||
gc->bg = window->gc.bg;
|
||||
|
||||
if (gc->bg != 8) {
|
||||
c = window_pane_get_palette(wp, gc->bg);
|
||||
@ -2550,7 +2545,7 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
|
||||
}
|
||||
|
||||
static void
|
||||
tty_default_attributes(struct tty *tty, const struct window_pane *wp, u_int bg)
|
||||
tty_default_attributes(struct tty *tty, struct window_pane *wp, u_int bg)
|
||||
{
|
||||
static struct grid_cell gc;
|
||||
|
||||
|
22
window.c
22
window.c
@ -470,7 +470,7 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
|
||||
void
|
||||
window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
||||
{
|
||||
const struct grid_cell *gc;
|
||||
struct style *sy;
|
||||
|
||||
if (wp == w->active)
|
||||
return;
|
||||
@ -479,21 +479,21 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
||||
* If window-style and window-active-style are the same, we don't need
|
||||
* to redraw panes when switching active panes.
|
||||
*/
|
||||
gc = options_get_style(w->options, "window-active-style");
|
||||
if (style_equal(gc, options_get_style(w->options, "window-style")))
|
||||
sy = options_get_style(w->options, "window-active-style");
|
||||
if (style_equal(sy, options_get_style(w->options, "window-style")))
|
||||
return;
|
||||
|
||||
/*
|
||||
* If the now active or inactive pane do not have a custom style or if
|
||||
* the palette is different, they need to be redrawn.
|
||||
*/
|
||||
if (window_pane_get_palette(w->active, w->active->colgc.fg) != -1 ||
|
||||
window_pane_get_palette(w->active, w->active->colgc.bg) != -1 ||
|
||||
style_equal(&grid_default_cell, &w->active->colgc))
|
||||
if (window_pane_get_palette(w->active, w->active->style.gc.fg) != -1 ||
|
||||
window_pane_get_palette(w->active, w->active->style.gc.bg) != -1 ||
|
||||
style_is_default(&w->active->style))
|
||||
w->active->flags |= PANE_REDRAW;
|
||||
if (window_pane_get_palette(wp, wp->colgc.fg) != -1 ||
|
||||
window_pane_get_palette(wp, wp->colgc.bg) != -1 ||
|
||||
style_equal(&grid_default_cell, &wp->colgc))
|
||||
if (window_pane_get_palette(wp, wp->style.gc.fg) != -1 ||
|
||||
window_pane_get_palette(wp, wp->style.gc.bg) != -1 ||
|
||||
style_is_default(&wp->style))
|
||||
wp->flags |= PANE_REDRAW;
|
||||
}
|
||||
|
||||
@ -826,7 +826,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
|
||||
|
||||
wp->saved_grid = NULL;
|
||||
|
||||
memcpy(&wp->colgc, &grid_default_cell, sizeof wp->colgc);
|
||||
style_set(&wp->style, &grid_default_cell);
|
||||
|
||||
screen_init(&wp->base, sx, sy, hlimit);
|
||||
wp->screen = &wp->base;
|
||||
@ -1179,7 +1179,7 @@ window_pane_reset_palette(struct window_pane *wp)
|
||||
}
|
||||
|
||||
int
|
||||
window_pane_get_palette(const struct window_pane *wp, int c)
|
||||
window_pane_get_palette(struct window_pane *wp, int c)
|
||||
{
|
||||
int new;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user