mirror of
https://github.com/tmux/tmux.git
synced 2024-10-31 22:58:49 +00:00
Use a grid cell not a style for the pane style.
This commit is contained in:
parent
c30e765c7b
commit
79b4d83952
23
grid.c
23
grid.c
@ -211,19 +211,28 @@ grid_check_y(struct grid *gd, const char *from, u_int py)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if two styles are (visibly) the same. */
|
||||||
|
int
|
||||||
|
grid_cells_look_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
|
||||||
|
{
|
||||||
|
if (gc1->fg != gc2->fg || gc1->bg != gc2->bg)
|
||||||
|
return (0);
|
||||||
|
if (gc1->attr != gc2->attr || gc1->flags != gc2->flags)
|
||||||
|
return (0);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Compare grid cells. Return 1 if equal, 0 if not. */
|
/* Compare grid cells. Return 1 if equal, 0 if not. */
|
||||||
int
|
int
|
||||||
grid_cells_equal(const struct grid_cell *gca, const struct grid_cell *gcb)
|
grid_cells_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
|
||||||
{
|
{
|
||||||
if (gca->fg != gcb->fg || gca->bg != gcb->bg)
|
if (!grid_cells_look_equal(gc1, gc2))
|
||||||
return (0);
|
return (0);
|
||||||
if (gca->attr != gcb->attr || gca->flags != gcb->flags)
|
if (gc1->data.width != gc2->data.width)
|
||||||
return (0);
|
return (0);
|
||||||
if (gca->data.width != gcb->data.width)
|
if (gc1->data.size != gc2->data.size)
|
||||||
return (0);
|
return (0);
|
||||||
if (gca->data.size != gcb->data.size)
|
return (memcmp(gc1->data.data, gc2->data.data, gc1->data.size) == 0);
|
||||||
return (0);
|
|
||||||
return (memcmp(gca->data.data, gcb->data.data, gca->data.size) == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free one line. */
|
/* Free one line. */
|
||||||
|
29
style.c
29
style.c
@ -59,6 +59,7 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
|||||||
return (0);
|
return (0);
|
||||||
style_copy(&saved, sy);
|
style_copy(&saved, sy);
|
||||||
|
|
||||||
|
log_debug("%s: %s", __func__, in);
|
||||||
do {
|
do {
|
||||||
while (*in != '\0' && strchr(delimiters, *in) != NULL)
|
while (*in != '\0' && strchr(delimiters, *in) != NULL)
|
||||||
in++;
|
in++;
|
||||||
@ -71,6 +72,7 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
|
|||||||
memcpy(tmp, in, end);
|
memcpy(tmp, in, end);
|
||||||
tmp[end] = '\0';
|
tmp[end] = '\0';
|
||||||
|
|
||||||
|
log_debug("%s: %s", __func__, tmp);
|
||||||
if (strcasecmp(tmp, "default") == 0) {
|
if (strcasecmp(tmp, "default") == 0) {
|
||||||
sy->gc.fg = base->fg;
|
sy->gc.fg = base->fg;
|
||||||
sy->gc.bg = base->bg;
|
sy->gc.bg = base->bg;
|
||||||
@ -285,30 +287,3 @@ style_copy(struct style *dst, struct style *src)
|
|||||||
{
|
{
|
||||||
memcpy(dst, src, sizeof *dst);
|
memcpy(dst, src, sizeof *dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if two styles are (visibly) the same. */
|
|
||||||
int
|
|
||||||
style_equal(struct style *sy1, struct style *sy2)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
if (sy1->fill != sy2->fill)
|
|
||||||
return (0);
|
|
||||||
if (sy1->align != sy2->align)
|
|
||||||
return (0);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Is this style default? */
|
|
||||||
int
|
|
||||||
style_is_default(struct style *sy)
|
|
||||||
{
|
|
||||||
return (style_equal(sy, &style_default));
|
|
||||||
}
|
|
||||||
|
8
tmux.h
8
tmux.h
@ -930,8 +930,8 @@ struct window_pane {
|
|||||||
|
|
||||||
struct input_ctx *ictx;
|
struct input_ctx *ictx;
|
||||||
|
|
||||||
struct style cached_style;
|
struct grid_cell cached_gc;
|
||||||
struct style cached_active_style;
|
struct grid_cell cached_active_gc;
|
||||||
int *palette;
|
int *palette;
|
||||||
|
|
||||||
int pipe_fd;
|
int pipe_fd;
|
||||||
@ -2365,6 +2365,8 @@ int attributes_fromstring(const char *);
|
|||||||
extern const struct grid_cell grid_default_cell;
|
extern const struct grid_cell grid_default_cell;
|
||||||
void grid_empty_line(struct grid *, u_int, u_int);
|
void grid_empty_line(struct grid *, u_int, u_int);
|
||||||
int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
|
int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
|
||||||
|
int grid_cells_look_equal(const struct grid_cell *,
|
||||||
|
const struct grid_cell *);
|
||||||
struct grid *grid_create(u_int, u_int, u_int);
|
struct grid *grid_create(u_int, u_int, u_int);
|
||||||
void grid_destroy(struct grid *);
|
void grid_destroy(struct grid *);
|
||||||
int grid_compare(struct grid *, struct grid *);
|
int grid_compare(struct grid *, struct grid *);
|
||||||
@ -2821,10 +2823,8 @@ 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 *);
|
||||||
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 *);
|
||||||
int style_is_default(struct style *);
|
|
||||||
|
|
||||||
/* spawn.c */
|
/* spawn.c */
|
||||||
struct winlink *spawn_window(struct spawn_context *, char **);
|
struct winlink *spawn_window(struct spawn_context *, char **);
|
||||||
|
24
tty.c
24
tty.c
@ -2690,27 +2690,19 @@ static void
|
|||||||
tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
|
tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct options *oo = wp->options;
|
struct options *oo = wp->options;
|
||||||
struct style *style, *active_style;
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (wp->flags & PANE_STYLECHANGED) {
|
if (wp->flags & PANE_STYLECHANGED) {
|
||||||
wp->flags &= ~PANE_STYLECHANGED;
|
wp->flags &= ~PANE_STYLECHANGED;
|
||||||
|
style_apply(&wp->cached_active_gc, oo, "window-active-style");
|
||||||
active_style = options_get_style(oo, "window-active-style");
|
style_apply(&wp->cached_gc, oo, "window-style");
|
||||||
style = options_get_style(oo, "window-style");
|
|
||||||
|
|
||||||
style_copy(&wp->cached_active_style, active_style);
|
|
||||||
style_copy(&wp->cached_style, style);
|
|
||||||
} else {
|
|
||||||
active_style = &wp->cached_active_style;
|
|
||||||
style = &wp->cached_style;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gc->fg == 8) {
|
if (gc->fg == 8) {
|
||||||
if (wp == wp->window->active && active_style->gc.fg != 8)
|
if (wp == wp->window->active && wp->cached_active_gc.fg != 8)
|
||||||
gc->fg = active_style->gc.fg;
|
gc->fg = wp->cached_active_gc.fg;
|
||||||
else
|
else
|
||||||
gc->fg = style->gc.fg;
|
gc->fg = wp->cached_gc.fg;
|
||||||
|
|
||||||
if (gc->fg != 8) {
|
if (gc->fg != 8) {
|
||||||
c = window_pane_get_palette(wp, gc->fg);
|
c = window_pane_get_palette(wp, gc->fg);
|
||||||
@ -2720,10 +2712,10 @@ tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gc->bg == 8) {
|
if (gc->bg == 8) {
|
||||||
if (wp == wp->window->active && active_style->gc.bg != 8)
|
if (wp == wp->window->active && wp->cached_active_gc.bg != 8)
|
||||||
gc->bg = active_style->gc.bg;
|
gc->bg = wp->cached_active_gc.bg;
|
||||||
else
|
else
|
||||||
gc->bg = style->gc.bg;
|
gc->bg = wp->cached_gc.bg;
|
||||||
|
|
||||||
if (gc->bg != 8) {
|
if (gc->bg != 8) {
|
||||||
c = window_pane_get_palette(wp, gc->bg);
|
c = window_pane_get_palette(wp, gc->bg);
|
||||||
|
18
window.c
18
window.c
@ -495,8 +495,8 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
|
|||||||
void
|
void
|
||||||
window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct style *sy1, *sy2;
|
struct grid_cell *gc1, *gc2;
|
||||||
int c1, c2;
|
int c1, c2;
|
||||||
|
|
||||||
if (wp == w->active)
|
if (wp == w->active)
|
||||||
return;
|
return;
|
||||||
@ -506,18 +506,18 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
|
|||||||
* If the active and inactive styles or palettes are different,
|
* If the active and inactive styles or palettes are different,
|
||||||
* need to redraw the panes.
|
* need to redraw the panes.
|
||||||
*/
|
*/
|
||||||
sy1 = &wp->cached_style;
|
gc1 = &wp->cached_gc;
|
||||||
sy2 = &wp->cached_active_style;
|
gc2 = &wp->cached_active_gc;
|
||||||
if (!style_equal(sy1, sy2))
|
if (!grid_cells_look_equal(gc1, gc2))
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
else {
|
else {
|
||||||
c1 = window_pane_get_palette(wp, sy1->gc.fg);
|
c1 = window_pane_get_palette(wp, gc1->fg);
|
||||||
c2 = window_pane_get_palette(wp, sy2->gc.fg);
|
c2 = window_pane_get_palette(wp, gc2->fg);
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
else {
|
else {
|
||||||
c1 = window_pane_get_palette(wp, sy1->gc.bg);
|
c1 = window_pane_get_palette(wp, gc1->bg);
|
||||||
c2 = window_pane_get_palette(wp, sy2->gc.bg);
|
c2 = window_pane_get_palette(wp, gc2->bg);
|
||||||
if (c1 != c2)
|
if (c1 != c2)
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user