Hi Looks like the right idea - please break the BCE stuff out into a separate diff and we can check it separately. I suggest adding a flag TTY_NOBCE rather than looking up TTYC_BCE every time.
Also I don't want a new command, so this will need to be a flag (or two: one for fg, one for for bg) on another command. Perhaps select-pane or resize-pane? Or just display-panes? I think you should do the default colour changes in tty_reset or perhaps tty_colours rather than everywhere it gets passed in. Thanks On Wed, Feb 11, 2015 at 10:03:21PM -0600, J Raynor wrote: > > This will not work as it is on terminals which do not support BCE. To > > make it do so you will pretty much have to make tmux support BCE :-). > > Ok, it now works on systems that don't support BCE. I've attached a new > patch. > diff --git a/cmd-display-panes.c b/cmd-display-panes.c > index 9ce8971..150b6f4 100644 > --- a/cmd-display-panes.c > +++ b/cmd-display-panes.c > @@ -18,14 +18,28 @@ > > #include <sys/types.h> > > +#include <stdlib.h> > +#include <string.h> > + > #include "tmux.h" > > /* > * Display panes on a client. > + * > + * Set or get pane default fg/bg colours. > */ > > +enum cmd_retval cmd_colour_pane_exec(struct cmd *, struct cmd_q *); > enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_q *); > > +const struct cmd_entry cmd_colour_pane_entry = { > + "colour-pane", "colourp", > + "gt:APW", 0, 1, > + CMD_TARGET_PANE_USAGE " [-A|P|W] colour-style", > + 0, > + cmd_colour_pane_exec > +}; > + > const struct cmd_entry cmd_display_panes_entry = { > "display-panes", "displayp", > "t:", 0, 0, > @@ -47,3 +61,107 @@ cmd_display_panes_exec(struct cmd *self, struct cmd_q > *cmdq) > > return (CMD_RETURN_NORMAL); > } > + > +enum cmd_retval > +cmd_colour_pane_exec(struct cmd *self, struct cmd_q *cmdq) > +{ > + struct args *args = self->args; > + struct session *s; > + struct winlink *wl; > + struct window_pane *wp; > + int ret, nflags = 0; > + struct grid_cell *gc; > + const char *str; > + > + > + > + if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL) > + return (CMD_RETURN_ERROR); > + > + 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 || nflags > 1) { > + cmdq_error(cmdq, "need exactly 1 of -g, -A, -P, or -W"); > + return (CMD_RETURN_ERROR); > + } > + > + if (args_has(args, 'g')) { > + if (args->argc > 0) { > + cmdq_error(cmdq, "don't specify style 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->argc == 0) { > + cmdq_error(cmdq, "need a style argument"); > + return (CMD_RETURN_ERROR); > + } > + > + str = args->argv[0]; > + if (*str == '\0') > + gc = NULL; > + else { > + gc = xmalloc(sizeof *gc); > + memcpy(gc, &grid_default_cell, sizeof *gc); > + ret = style_parse(&grid_default_cell, gc, str); > + > + if (ret == -1) { > + free(gc); > + cmdq_error(cmdq, "bad colour style"); > + return (CMD_RETURN_ERROR); > + } > + > + gc->attr = grid_default_cell.attr; > + } > + > + if (args_has(args, 'A')) { > + free(wp->window->apcolgc); > + wp->window->apcolgc = gc; > + server_redraw_window(wp->window); > + return (CMD_RETURN_NORMAL); > + } > + > + if (args_has(args, 'P')) { > + free(wp->colgc); > + wp->colgc = gc; > + wp->flags |= PANE_REDRAW; > + return (CMD_RETURN_NORMAL); > + } > + > + if (args_has(args, 'W')) { > + free(wp->window->colgc); > + wp->window->colgc = gc; > + server_redraw_window(wp->window); > + return (CMD_RETURN_NORMAL); > + } > + > + return (CMD_RETURN_NORMAL); > +} > diff --git a/cmd.c b/cmd.c > index eeffe4c..e54b23e 100644 > --- a/cmd.c > +++ b/cmd.c > @@ -39,6 +39,7 @@ const struct cmd_entry *cmd_table[] = { > &cmd_choose_window_entry, > &cmd_clear_history_entry, > &cmd_clock_mode_entry, > + &cmd_colour_pane_entry, > &cmd_command_prompt_entry, > &cmd_confirm_before_entry, > &cmd_copy_mode_entry, > 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..4a780f6 100644 > --- a/screen-redraw.c > +++ b/screen-redraw.c > @@ -266,7 +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_draw_line(&c->tty, wp->screen, i, wp->xoff, yoff, > + get_wp_default_grid_colours(wp)); > tty_reset(&c->tty); > } > > @@ -354,7 +355,8 @@ 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, > + get_wp_default_grid_colours(wp)); > if (c->flags & CLIENT_IDENTIFY) > screen_redraw_draw_number(c, wp); > } > @@ -367,9 +369,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/tmux.h b/tmux.h > index e296ac7..0f32777 100644 > --- a/tmux.h > +++ b/tmux.h > @@ -154,6 +154,7 @@ enum key_code { > enum tty_code_code { > TTYC_AX = 0, > TTYC_ACSC, /* acs_chars, ac */ > + TTYC_BCE, > TTYC_BEL, /* bell, bl */ > TTYC_BLINK, /* enter_blink_mode, mb */ > TTYC_BOLD, /* enter_bold_mode, md */ > @@ -900,6 +901,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 +957,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 *); > @@ -1628,7 +1636,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 grid_cell *); > int tty_open(struct tty *, char **); > void tty_close(struct tty *); > void tty_free(struct tty *); > @@ -1739,6 +1748,7 @@ extern const struct cmd_entry cmd_choose_tree_entry; > extern const struct cmd_entry cmd_choose_window_entry; > extern const struct cmd_entry cmd_clear_history_entry; > extern const struct cmd_entry cmd_clock_mode_entry; > +extern const struct cmd_entry cmd_colour_pane_entry; > extern const struct cmd_entry cmd_command_prompt_entry; > extern const struct cmd_entry cmd_confirm_before_entry; > extern const struct cmd_entry cmd_copy_mode_entry; > @@ -1956,6 +1966,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-term.c b/tty-term.c > index 365da5f..456f81e 100644 > --- a/tty-term.c > +++ b/tty-term.c > @@ -38,6 +38,7 @@ struct tty_terms tty_terms = > LIST_HEAD_INITIALIZER(tty_terms); > const struct tty_term_code_entry tty_term_codes[NTTYCODE] = { > { TTYC_ACSC, TTYCODE_STRING, "acsc" }, > { TTYC_AX, TTYCODE_FLAG, "AX" }, > + { TTYC_BCE, TTYCODE_STRING, "bce" }, > { TTYC_BEL, TTYCODE_STRING, "bel" }, > { TTYC_BLINK, TTYCODE_STRING, "blink" }, > { TTYC_BOLD, TTYCODE_STRING, "bold" }, > diff --git a/tty.c b/tty.c > index 1bb8981..63ce2eb 100644 > --- a/tty.c > +++ b/tty.c > @@ -604,21 +604,25 @@ 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, > + get_wp_default_grid_colours(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, > + get_wp_default_grid_colours(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 grid_cell *colgc) > { > const struct grid_cell *gc; > struct grid_line *gl; > - struct grid_cell tmpgc; > + struct grid_cell tmpgc, colourgc; > struct utf8_data ud; > - u_int i, sx; > + u_int i, sx, fake_bce = 0; > + > > tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s); > > @@ -628,6 +632,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int > py, u_int ox, u_int oy) > if (sx > tty->sx) > sx = tty->sx; > > + > /* > * Don't move the cursor to the start permission if it will wrap there > * itself. > @@ -642,17 +647,28 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int > py, u_int ox, u_int oy) > > 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) { > @@ -660,14 +676,21 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int > py, u_int ox, u_int oy) > return; > } > tty_reset(tty); > + if (colgc != NULL && colgc->bg != 8) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > + > > tty_cursor(tty, ox + sx, oy + py); > if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx && > - tty_term_has(tty->term, TTYC_EL)) > + tty_term_has(tty->term, TTYC_EL) && !fake_bce) > tty_putcode(tty, TTYC_EL); > else > tty_repeat_space(tty, screen_size_x(s) - sx); > tty_update_mode(tty, tty->mode, s); > + > } > > void > @@ -711,36 +734,56 @@ void > tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx) > { > struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(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, > + colgc); > return; > } > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > - if (tty_term_has(tty->term, TTYC_ICH) || > - tty_term_has(tty->term, TTYC_ICH1)) > + if (!fake_bce && (tty_term_has(tty->term, TTYC_ICH) || > + 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, > + get_wp_default_grid_colours(wp)); > } > > void > tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) > { > struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > > - if (!tty_pane_full_width(tty, ctx) || > + colgc = get_wp_default_grid_colours(wp); > + if (colgc != NULL && !tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + > + if (!tty_pane_full_width(tty, ctx) || fake_bce || > (!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, > + colgc); > return; > } > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > @@ -753,12 +796,22 @@ void > tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx) > { > u_int i; > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > > - if (tty_term_has(tty->term, TTYC_ECH)) > + if (tty_term_has(tty->term, TTYC_ECH) && !fake_bce) > tty_putcode1(tty, TTYC_ECH, ctx->num); > else { > for (i = 0; i < ctx->num; i++) > @@ -769,7 +822,15 @@ tty_cmd_clearcharacter(struct tty *tty, const struct > tty_ctx *ctx) > void > tty_cmd_insertline(struct tty *tty, const struct tty_ctx *ctx) > { > - if (!tty_pane_full_width(tty, ctx) || > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > + if (colgc != NULL && !tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + > + if (!tty_pane_full_width(tty, ctx) || fake_bce || > !tty_term_has(tty->term, TTYC_CSR) || > !tty_term_has(tty->term, TTYC_IL1)) { > tty_redraw_region(tty, ctx); > @@ -777,6 +838,8 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx > *ctx) > } > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -787,7 +850,15 @@ tty_cmd_insertline(struct tty *tty, const struct tty_ctx > *ctx) > void > tty_cmd_deleteline(struct tty *tty, const struct tty_ctx *ctx) > { > - if (!tty_pane_full_width(tty, ctx) || > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > + if (colgc != NULL && !tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + > + if (!tty_pane_full_width(tty, ctx) || fake_bce || > !tty_term_has(tty->term, TTYC_CSR) || > !tty_term_has(tty->term, TTYC_DL1)) { > tty_redraw_region(tty, ctx); > @@ -795,6 +866,8 @@ tty_cmd_deleteline(struct tty *tty, const struct tty_ctx > *ctx) > } > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -807,12 +880,22 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx > *ctx) > { > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > 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) && !fake_bce) > tty_putcode(tty, TTYC_EL); > else > tty_repeat_space(tty, screen_size_x(s)); > @@ -823,12 +906,22 @@ tty_cmd_clearendofline(struct tty *tty, const struct > tty_ctx *ctx) > { > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > tty_cursor_pane(tty, ctx, ctx->ocx, 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) && !fake_bce) > tty_putcode(tty, TTYC_EL); > else > tty_repeat_space(tty, screen_size_x(s) - ctx->ocx); > @@ -837,9 +930,21 @@ tty_cmd_clearendofline(struct tty *tty, const struct > tty_ctx *ctx) > void > tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) > { > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > + > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > - if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) { > + if (ctx->xoff == 0 && > + tty_term_has(tty->term, TTYC_EL1) && !fake_bce) { > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > tty_putcode(tty, TTYC_EL1); > } else { > @@ -851,10 +956,18 @@ tty_cmd_clearstartofline(struct tty *tty, const struct > tty_ctx *ctx) > void > tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) > { > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > + if (colgc != NULL && !tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + > if (ctx->ocy != ctx->orupper) > return; > > - if (!tty_pane_full_width(tty, ctx) || > + if (!tty_pane_full_width(tty, ctx) || fake_bce || > !tty_term_has(tty->term, TTYC_CSR) || > !tty_term_has(tty->term, TTYC_RI)) { > tty_redraw_region(tty, ctx); > @@ -862,6 +975,8 @@ tty_cmd_reverseindex(struct tty *tty, const struct > tty_ctx *ctx) > } > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->orupper); > @@ -873,11 +988,17 @@ void > tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) > { > struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > + if (colgc != NULL && !tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > > if (ctx->ocy != ctx->orlower) > return; > > - if (!tty_pane_full_width(tty, ctx) || > + if (!tty_pane_full_width(tty, ctx) || fake_bce || > !tty_term_has(tty->term, TTYC_CSR)) { > if (tty_large_region(tty, ctx)) > wp->flags |= PANE_REDRAW; > @@ -895,6 +1016,8 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx > *ctx) > return; > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); > tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); > @@ -908,13 +1031,23 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct > tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > u_int i, j; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, ctx->ocx, 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) && !fake_bce) { > tty_putcode(tty, TTYC_EL); > if (ctx->ocy != screen_size_y(s) - 1) { > tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1); > @@ -941,13 +1074,23 @@ tty_cmd_clearstartofscreen(struct tty *tty, const > struct tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > u_int i, j; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) { > + tty_attributes(tty, colgc); > + if (!tty_term_has(tty->term, TTYC_BCE)) > + fake_bce = 1; > + } > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, 0, 0); > > - 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) && !fake_bce) { > for (i = 0; i < ctx->ocy; i++) { > tty_putcode(tty, TTYC_EL); > tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1); > @@ -968,13 +1111,20 @@ tty_cmd_clearscreen(struct tty *tty, const struct > tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > u_int i, j; > + const struct grid_cell *colgc; > + int fake_bce = 0; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > tty_cursor_pane(tty, ctx, 0, 0); > > - 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) && !fake_bce) { > for (i = 0; i < screen_size_y(s); i++) { > tty_putcode(tty, TTYC_EL); > if (i != screen_size_y(s) - 1) { > @@ -996,8 +1146,13 @@ tty_cmd_alignmenttest(struct tty *tty, const struct > tty_ctx *ctx) > struct window_pane *wp = ctx->wp; > struct screen *s = wp->screen; > u_int i, j; > + const struct grid_cell *colgc; > + > + colgc = get_wp_default_grid_colours(wp); > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > > tty_region_pane(tty, ctx, 0, screen_size_y(s) - 1); > > @@ -1015,6 +1170,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,19 +1202,37 @@ 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 > tty_cmd_utf8character(struct tty *tty, const struct tty_ctx *ctx) > { > struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + > + colgc = get_wp_default_grid_colours(wp); > > /* > * 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, colgc); > } > > void > @@ -1079,6 +1256,11 @@ tty_cmd_setselection(struct tty *tty, const struct > tty_ctx *ctx) > void > tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) > { > + struct window_pane *wp = ctx->wp; > + const struct grid_cell *colgc; > + > + colgc = get_wp_default_grid_colours(wp); > + > u_int i; > u_char *str = ctx->ptr; > > @@ -1089,6 +1271,8 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx > *ctx) > tty->rupper = tty->rlower = UINT_MAX; > > tty_reset(tty); > + if (colgc != NULL) > + tty_attributes(tty, colgc); > tty_cursor(tty, 0, 0); > } > > 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