I was thinking that you do this in tty_open: if (!tty_term_has(tty->term, TTYC_BCE) tty->flags |= TTY_NOBCE;
And use that instead of calling tty_term_has all the time. But actually it probably makes little difference, just using tty_term_has is probably fine. As far as the diff below goes: - I don't think you need to allocate the gc with malloc, just put it inside the wp directly and initialize it to grid_default_cell. - You only need to swap it in if the current fg == 8 || bg == 8. You can do this just in tty_reset and tty_attributes and it should catch everything. You shouldn't need to change tty_draw_line except to take a struct window_pane argument. - I think the window colour can still be a window option but I would drop it (or drop the pane colours and just do the window) for now and add it as a separate change after one is working. - I would drop get_wp_default_grid_colours in favour of a function in tty.c that did something like: void tty_default_colours(struct grid_cell *gc, struct window_pane *wp) { if (wp == NULL) return; if (gc->fg == 8 && !(gc->flags & GRID_FLAG_FG256)) { gc.fg = wp->colgc.fg; gc.flags &= ~GRID_FLAG_FG256; gc.flags |= (wp->colgc.flags & GRID_FLAG_FG256); } /* same for bg, you get the idea */ } This relies on BCE working properly so you can set the cell defaults to anything of course. On Fri, Feb 13, 2015 at 06:50:55PM -0600, J Raynor wrote: > I've attached a new patch for pane colors. You use the display-panes > command to set the colors now, and the color changes take place in > tty_reset. > > There's no bce stuff in this patch. > > For bce, you mentioned a TTY_NOBCE flag. Could you give a little more > detail about what you're looking for? Where would this flag be set or > passed in? > > For functions that need to check for bce support, like > tty_cmd_insertcharacter, the function needs to check whether there's > bce support, but also whether a default color has been set, unless you > want a tty without bce support to always fake things like ICH, EL, and > DCH, even if no color has been set. If you don't want to always fake > bce, then it seems a single flag won't work. > > If you're just looking to keep things concise, there could be a > function that returns whether bce needs to be faked. For example, if > the patch attached to this email has been applied, here's a diff for > what tty_cmd_clearline would look like with this proposed function: > > --- tty.c 2015-02-13 16:37:48.000000000 -0600 > +++ tty.c.new 2015-02-13 18:34:49.000000000 -0600 > @@ -830,7 +830,9 @@ > > tty_cursor_pane(tty, ctx, 0, ctx->ocy); > > - if (tty_pane_full_width(tty, ctx) && tty_term_has(tty->term, TTYC_EL)) > + if (tty_pane_full_width(tty, ctx) && > + tty_term_has(tty->term, TTYC_EL) && > + !need_fake_bce(tty, wp)) > tty_putcode(tty, TTYC_EL); > else > tty_repeat_space(tty, screen_size_x(s)); > > > > No need to declare and set a fake_bce variable, or to do a color > check. The need_fake_bce function would take care of returning the > right info. Should I pursue a patch with bce support implemented > using that function? > diff --git a/cmd-display-panes.c b/cmd-display-panes.c > index 9ce8971..1994aa4 100644 > --- a/cmd-display-panes.c > +++ b/cmd-display-panes.c > @@ -18,18 +18,23 @@ > > #include <sys/types.h> > > +#include <stdlib.h> > +#include <string.h> > + > #include "tmux.h" > > /* > - * Display panes on a client. > + * Display panes on a client, or get/set pane default fg/bg colours. > */ > > enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_q *); > > +int cmd_display_panes_initgc(const char *, struct grid_cell **); > + > const struct cmd_entry cmd_display_panes_entry = { > "display-panes", "displayp", > - "t:", 0, 0, > - CMD_TARGET_CLIENT_USAGE, > + "gt:A:P:W:", 0, 0, > + "[-g] [-A style] [-P style] [-W style] " CMD_TARGET_CLIENT_USAGE, > 0, > cmd_display_panes_exec > }; > @@ -37,13 +42,120 @@ const struct cmd_entry cmd_display_panes_entry = { > enum cmd_retval > cmd_display_panes_exec(struct cmd *self, struct cmd_q *cmdq) > { > - struct args *args = self->args; > - struct client *c; > + struct args *args = self->args; > + struct client *c; > + struct session *s; > + struct winlink *wl; > + struct window_pane *wp; > + int nflags = 0; > + struct grid_cell *gc; > + const char *str; > + > + if (args_has(args, 'g')) nflags++; > + if (args_has(args, 'A')) nflags++; > + if (args_has(args, 'P')) nflags++; > + if (args_has(args, 'W')) nflags++; > + > + if (nflags == 0) { > + > + if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL) > + return (CMD_RETURN_ERROR); > + > + server_set_identify(c); > + > + return (CMD_RETURN_NORMAL); > + } > > - if ((c = cmd_find_client(cmdq, args_get(args, 't'), 0)) == NULL) > + > + if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) > return (CMD_RETURN_ERROR); > > - server_set_identify(c); > + if (args_has(args, 'g')) { > + > + if (nflags > 1) { > + cmdq_error(cmdq, "don't use -A, -P, or -W with -g"); > + return (CMD_RETURN_ERROR); > + } > + > + gc = wp->window->apcolgc; > + if (gc == NULL) > + str = "\"\""; > + else > + str = style_tostring(gc); > + cmdq_print(cmdq, "active-pane %s", str); > + > + > + gc = wp->colgc; > + if (gc == NULL) > + str = "\"\""; > + else > + str = style_tostring(gc); > + cmdq_print(cmdq, "pane %s", str); > + > + > + gc = wp->window->colgc; > + if (gc == NULL) > + str = "\"\""; > + else > + str = style_tostring(gc); > + cmdq_print(cmdq, "window %s", str); > + > + return (CMD_RETURN_NORMAL); > + } > + > + > + if (args_has(args, 'A')) { > + if (cmd_display_panes_initgc(args_get(args, 'A'), &gc) == -1) { > + cmdq_error(cmdq, "bad colour style"); > + return (CMD_RETURN_ERROR); > + } > + free(wp->window->apcolgc); > + wp->window->apcolgc = gc; > + server_redraw_window(wp->window); > + } > + > + if (args_has(args, 'P')) { > + if (cmd_display_panes_initgc(args_get(args, 'P'), &gc) == -1) { > + cmdq_error(cmdq, "bad colour style"); > + return (CMD_RETURN_ERROR); > + } > + free(wp->colgc); > + wp->colgc = gc; > + wp->flags |= PANE_REDRAW; > + } > + > + if (args_has(args, 'W')) { > + if (cmd_display_panes_initgc(args_get(args, 'W'), &gc) == -1) { > + cmdq_error(cmdq, "bad colour style"); > + return (CMD_RETURN_ERROR); > + } > + free(wp->window->colgc); > + wp->window->colgc = gc; > + server_redraw_window(wp->window); > + } > > return (CMD_RETURN_NORMAL); > } > + > +int > +cmd_display_panes_initgc(const char *str, struct grid_cell **gcp) > +{ > + int ret; > + > + if (*str == '\0') > + *gcp = NULL; > + else { > + *gcp = xmalloc(sizeof **gcp); > + memcpy(*gcp, &grid_default_cell, sizeof **gcp); > + ret = style_parse(&grid_default_cell, *gcp, str); > + > + if (ret == -1) { > + free(*gcp); > + return (ret); > + } > + > + (*gcp)->attr = grid_default_cell.attr; > + } > + > + return (0); > +} > diff --git a/colour.c b/colour.c > index 9e90596..eeb6625 100644 > --- a/colour.c > +++ b/colour.c > @@ -287,3 +287,16 @@ colour_256to16(u_char c) > > return (table[c]); > } > + > +const struct grid_cell * > +get_wp_default_grid_colours(const struct window_pane *wp) > +{ > + if (wp->colgc != NULL) > + return (wp->colgc); > + > + if (wp == wp->window->active && wp->window->apcolgc != NULL) > + return (wp->window->apcolgc); > + > + > + return (wp->window->colgc); > +} > diff --git a/screen-redraw.c b/screen-redraw.c > index c2b2ece..9b1bb83 100644 > --- a/screen-redraw.c > +++ b/screen-redraw.c > @@ -249,7 +249,7 @@ screen_redraw_screen(struct client *c, int draw_panes, > int draw_status, > screen_redraw_draw_panes(c, top); > if (draw_status) > screen_redraw_draw_status(c, top); > - tty_reset(tty); > + tty_reset(tty, NULL); > } > > /* Draw a single pane. */ > @@ -266,8 +266,8 @@ screen_redraw_pane(struct client *c, struct window_pane > *wp) > yoff++; > > for (i = 0; i < wp->sy; i++) > - tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff); > - tty_reset(&c->tty); > + tty_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff, wp); > + tty_reset(&c->tty, NULL); > } > > /* Draw the borders. */ > @@ -354,7 +354,7 @@ screen_redraw_draw_panes(struct client *c, u_int top) > continue; > s = wp->screen; > for (i = 0; i < wp->sy; i++) > - tty_draw_line(tty, s, i, wp->xoff, top + wp->yoff); > + tty_draw_line(tty, s, i, wp->xoff, top + wp->yoff, wp); > if (c->flags & CLIENT_IDENTIFY) > screen_redraw_draw_number(c, wp); > } > @@ -367,9 +367,9 @@ screen_redraw_draw_status(struct client *c, u_int top) > struct tty *tty = &c->tty; > > if (top) > - tty_draw_line(tty, &c->status, 0, 0, 0); > + tty_draw_line(tty, &c->status, 0, 0, 0, NULL); > else > - tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1); > + tty_draw_line(tty, &c->status, 0, 0, tty->sy - 1, NULL); > } > > /* Draw number on a pane. */ > diff --git a/server-client.c b/server-client.c > index 3ca9907..3206b6e 100644 > --- a/server-client.c > +++ b/server-client.c > @@ -691,7 +691,7 @@ server_client_reset_state(struct client *c) > > /* Set the terminal mode and reset attributes. */ > tty_update_mode(&c->tty, mode, s); > - tty_reset(&c->tty); > + tty_reset(&c->tty, NULL); > } > > /* Repeat time callback. */ > diff --git a/tmux.1 b/tmux.1 > index f615dd0..ec13752 100644 > --- a/tmux.1 > +++ b/tmux.1 > @@ -1305,9 +1305,16 @@ flag, see the > .Sx FORMATS > section. > This command works only if at least one client is attached. > -.It Ic display-panes Op Fl t Ar target-client > +.It Xo Ic display-panes > +.Op Fl g > +.Op Fl A Ar style > +.Op Fl P Ar style > +.Op Fl W Ar style > +.Op Fl t Ar target-client > +.Xc > .D1 (alias: Ic displayp ) > -Display a visible indicator of each pane shown by > +If no flags have been specified, display a visible indicator of > +each pane shown by > .Ar target-client . > See the > .Ic display-panes-time , > @@ -1320,6 +1327,29 @@ While the indicator is on screen, a pane may be > selected with the > to > .Ql 9 > keys. > +.Pp > +With > +.Fl A > +, > +.Fl P > +, or > +.Fl W > +a style argument can be passed to change a window or pane's > +default foreground and background colour. The > +.Fl W > +flag will set the default colour style for panes in the window. The > +.Fl A > +flag will set the colour style a pane will have whenever it becomes the > +active pane in the window. The > +.Fl P > +flag will set the colour style for a pane, overriding whatever > +style has been set with > +.Fl W > +or > +.Fl A > +\&. To clear a style, specify the empty string. The > +.Fl g > +flag will show what colour styles have been set. > .It Xo Ic find-window > .Op Fl CNT > .Op Fl F Ar format > diff --git a/tmux.h b/tmux.h > index e296ac7..7635de7 100644 > --- a/tmux.h > +++ b/tmux.h > @@ -900,6 +900,9 @@ struct window_pane { > > struct input_ctx ictx; > > + /* Default fg/bg grid cell colours */ > + struct grid_cell *colgc; > + > int pipe_fd; > struct bufferevent *pipe_event; > size_t pipe_off; > @@ -953,6 +956,10 @@ struct window { > > struct options options; > > + /* Default fg/bg grid cell colours for window and active pane */ > + struct grid_cell *colgc; > + struct grid_cell *apcolgc; > + > u_int references; > }; > ARRAY_DECL(windows, struct window *); > @@ -1605,7 +1612,7 @@ void environ_push(struct environ *); > void tty_init_termios(int, struct termios *, struct bufferevent *); > void tty_raw(struct tty *, const char *); > void tty_attributes(struct tty *, const struct grid_cell *); > -void tty_reset(struct tty *); > +void tty_reset(struct tty *, const struct window_pane *); > void tty_region_pane(struct tty *, const struct tty_ctx *, u_int, u_int); > void tty_region(struct tty *, u_int, u_int); > void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, u_int); > @@ -1628,7 +1635,8 @@ 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_force_cursor_colour(struct tty *, const char *); > -void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int); > +void tty_draw_line(struct tty *, struct screen *, u_int, u_int, u_int, > + const struct window_pane *); > int tty_open(struct tty *, char **); > void tty_close(struct tty *); > void tty_free(struct tty *); > @@ -1956,6 +1964,7 @@ void colour_set_bg(struct grid_cell *, int); > const char *colour_tostring(int); > int colour_fromstring(const char *); > u_char colour_256to16(u_char); > +const struct grid_cell *get_wp_default_grid_colours(const struct window_pane > *); > > /* attributes.c */ > const char *attributes_tostring(u_char); > diff --git a/tty.c b/tty.c > index 1bb8981..da1010e 100644 > --- a/tty.c > +++ b/tty.c > @@ -604,19 +604,20 @@ tty_redraw_region(struct tty *tty, const struct tty_ctx > *ctx) > > if (ctx->ocy < ctx->orupper || ctx->ocy > ctx->orlower) { > for (i = ctx->ocy; i < screen_size_y(s); i++) > - tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff, wp); > } else { > for (i = ctx->orupper; i <= ctx->orlower; i++) > - tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, s, i, ctx->xoff, ctx->yoff, wp); > } > } > > void > -tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int > oy) > +tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int > oy, > + const struct window_pane *wp) > { > - const struct grid_cell *gc; > + const struct grid_cell *gc, *colgc = NULL; > struct grid_line *gl; > - struct grid_cell tmpgc; > + struct grid_cell tmpgc, colourgc; > struct utf8_data ud; > u_int i, sx; > > @@ -640,26 +641,40 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int > py, u_int ox, u_int oy) > (oy + py != tty->cy + 1 && tty->cy != s->rlower + oy)) > tty_cursor(tty, ox, oy + py); > > + if (wp != NULL) > + colgc = get_wp_default_grid_colours(wp); > + > for (i = 0; i < sx; i++) { > gc = grid_view_peek_cell(s->grid, i, py); > + memcpy(&colourgc, gc, sizeof *gc); > + if (colgc != NULL && colourgc.fg == 8) { > + colourgc.fg = colgc->fg; > + colourgc.flags &= ~GRID_FLAG_FG256; > + colourgc.flags |= (colgc->flags & GRID_FLAG_FG256); > + } > + if (colgc != NULL && colourgc.bg == 8) { > + colourgc.bg = colgc->bg; > + colourgc.flags &= ~GRID_FLAG_BG256; > + colourgc.flags |= (colgc->flags & GRID_FLAG_BG256); > + } > if (screen_check_selection(s, i, py)) { > memcpy(&tmpgc, &s->sel.cell, sizeof tmpgc); > - grid_cell_get(gc, &ud); > + grid_cell_get(&colourgc, &ud); > grid_cell_set(&tmpgc, &ud); > - tmpgc.flags = gc->flags & > + tmpgc.flags = colourgc.flags & > ~(GRID_FLAG_FG256|GRID_FLAG_BG256); > tmpgc.flags |= s->sel.cell.flags & > (GRID_FLAG_FG256|GRID_FLAG_BG256); > tty_cell(tty, &tmpgc); > } else > - tty_cell(tty, gc); > + tty_cell(tty, &colourgc); > } > > if (sx >= tty->sx) { > tty_update_mode(tty, tty->mode, s); > return; > } > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_cursor(tty, ox + sx, oy + py); > if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx && > @@ -713,11 +728,12 @@ tty_cmd_insertcharacter(struct tty *tty, const struct > tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > > if (!tty_pane_full_width(tty, ctx)) { > - tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff, > + wp); > return; > } > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > @@ -725,7 +741,8 @@ tty_cmd_insertcharacter(struct tty *tty, const struct > tty_ctx *ctx) > tty_term_has(tty->term, TTYC_ICH1)) > tty_emulate_repeat(tty, TTYC_ICH, TTYC_ICH1, ctx->num); > else > - tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff, > + wp); > } > > void > @@ -736,11 +753,12 @@ tty_cmd_deletecharacter(struct tty *tty, const struct > tty_ctx *ctx) > if (!tty_pane_full_width(tty, ctx) || > (!tty_term_has(tty->term, TTYC_DCH) && > !tty_term_has(tty->term, TTYC_DCH1))) { > - tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff, > + wp); > return; > } > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > @@ -754,7 +772,7 @@ tty_cmd_clearcharacter(struct tty *tty, const struct > tty_ctx *ctx) > { > u_int i; > > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > @@ -776,7 +794,7 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx > *ctx) > return; > } > > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -794,7 +812,7 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx > *ctx) > return; > } > > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -808,7 +826,7 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx > *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_cursor_pane(tty, ctx, 0, ctx->ocy); > > @@ -824,7 +842,7 @@ tty_cmd_clearendofline(struct tty *tty, const struct > tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > @@ -837,7 +855,7 @@ tty_cmd_clearendofline(struct tty *tty, const struct > tty_ctx *ctx) > void > tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) > { > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > > if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -861,7 +879,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct > tty_ctx *ctx) > return; > } > > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); > @@ -894,7 +912,7 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx > *ctx) > if (ctx->num && !(tty->term->flags & TERM_EARLYWRAP)) > return; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -909,7 +927,7 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct > tty_ctx *ctx) > struct screen *s = wp->screen; > u_int i, j; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -942,7 +960,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct > tty_ctx *ctx) > struct screen *s = wp->screen; > u_int i, j; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, 0, 0); > @@ -969,7 +987,7 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx > *ctx) > struct screen *s = wp->screen; > u_int i, j; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, 0, 0); > @@ -997,7 +1015,7 @@ tty_cmd_alignmenttest(struct tty *tty, const struct > tty_ctx *ctx) > struct screen *s = wp->screen; > u_int i, j; > > - tty_reset(tty); > + tty_reset(tty, wp); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > > @@ -1015,6 +1033,10 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx > *ctx) > struct screen *s = wp->screen; > u_int cx; > u_int width; > + struct grid_cell tmpgc; > + const struct grid_cell *colgc; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > > @@ -1043,7 +1065,22 @@ tty_cmd_cell(struct tty *tty, const struct tty_ctx > *ctx) > } else > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > - tty_cell(tty, ctx->cell); > + > + memcpy(&tmpgc, ctx->cell, sizeof tmpgc); > + if (colgc != NULL) { > + if (ctx->cell->fg == 8) { > + tmpgc.fg = colgc->fg; > + tmpgc.flags &= ~GRID_FLAG_FG256; > + tmpgc.flags |= (colgc->flags & GRID_FLAG_FG256); > + } > + if (ctx->cell->bg == 8) { > + tmpgc.bg = colgc->bg; > + tmpgc.flags &= ~GRID_FLAG_BG256; > + tmpgc.flags |= (colgc->flags & GRID_FLAG_BG256); > + } > + } > + > + tty_cell(tty, &tmpgc); > } > > void > @@ -1055,7 +1092,7 @@ tty_cmd_utf8character(struct tty *tty, const struct > tty_ctx *ctx) > * Cannot rely on not being a partial character, so just redraw the > * whole line. > */ > - tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff); > + tty_draw_line(tty, wp->screen, ctx->ocy, ctx->xoff, ctx->yoff, wp); > } > > void > @@ -1088,7 +1125,7 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx > *ctx) > tty->cx = tty->cy = UINT_MAX; > tty->rupper = tty->rlower = UINT_MAX; > > - tty_reset(tty); > + tty_reset(tty, ctx->wp); > tty_cursor(tty, 0, 0); > } > > @@ -1131,17 +1168,26 @@ tty_cell(struct tty *tty, const struct grid_cell *gc) > } > > void > -tty_reset(struct tty *tty) > +tty_reset(struct tty *tty, const struct window_pane *wp) > { > struct grid_cell *gc = &tty->cell; > + const struct grid_cell *colgc = NULL; > > - if (memcmp(gc, &grid_default_cell, sizeof *gc) == 0) > + if (wp != NULL) > + colgc = get_wp_default_grid_colours(wp); > + > + if (colgc == NULL && > + memcmp(gc, &grid_default_cell, sizeof *gc) == 0) > return; > > if ((gc->attr & GRID_ATTR_CHARSET) && tty_use_acs(tty)) > tty_putcode(tty, TTYC_RMACS); > tty_putcode(tty, TTYC_SGR0); > memcpy(gc, &grid_default_cell, sizeof *gc); > + > + if (colgc != NULL) > + tty_attributes(tty, colgc); > + > } > > /* Set region inside pane. */ > @@ -1340,7 +1386,7 @@ tty_attributes(struct tty *tty, const struct grid_cell > *gc) > > /* If any bits are being cleared, reset everything. */ > if (tc->attr & ~gc2.attr) > - tty_reset(tty); > + tty_reset(tty, NULL); > > /* > * Set the colours. This may call tty_reset() (so it comes next) and > @@ -1409,7 +1455,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc) > */ > have_ax = tty_term_has(tty->term, TTYC_AX); > if (!have_ax && tty_term_has(tty->term, TTYC_OP)) > - tty_reset(tty); > + tty_reset(tty, NULL); > else { > if (fg_default && > (tc->fg != 8 || tc->flags & GRID_FLAG_FG256)) { > diff --git a/window.c b/window.c > index 5412963..ca44cbe 100644 > --- a/window.c > +++ b/window.c > @@ -288,6 +288,9 @@ window_create1(u_int sx, u_int sy) > w->sx = sx; > w->sy = sy; > > + w->colgc = NULL; > + w->apcolgc = NULL; > + > options_init(&w->options, &global_w_options); > if (options_get_number(&w->options, "automatic-rename")) > queue_window_name(w); > @@ -357,6 +360,8 @@ window_destroy(struct window *w) > window_destroy_panes(w); > > free(w->name); > + free(w->colgc); > + free(w->apcolgc); > free(w); > } > > @@ -704,6 +709,8 @@ window_pane_create(struct window *w, u_int sx, u_int sy, > u_int hlimit) > > wp->saved_grid = NULL; > > + wp->colgc = NULL; > + > screen_init(&wp->base, sx, sy, hlimit); > wp->screen = &wp->base; > > @@ -742,6 +749,7 @@ window_pane_destroy(struct window_pane *wp) > RB_REMOVE(window_pane_tree, &all_window_panes, wp); > > close(wp->cwd); > + free(wp->colgc); > free(wp->shell); > cmd_free_argv(wp->argc, wp->argv); > free(wp); ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users