I've attached a patch that adds the BCE functionality I did before.
It's more concise this time.  You have to apply the other patch first,
the one that does pane colors for bce terminals.

As for the other stuff, I misunderstood what you were referring to.  I
thought you were looking for a different implementation of bce support
for what I had already done.  I'll take a look at getting full
support.
diff --git a/tmux.h b/tmux.h
index 4751cbd..c21fbb4 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,	/* background colour erase */
 	TTYC_BEL,	/* bell, bl */
 	TTYC_BLINK,	/* enter_blink_mode, mb */
 	TTYC_BOLD,	/* enter_bold_mode, md */
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 257ebf8..0f33f15 100644
--- a/tty.c
+++ b/tty.c
@@ -50,6 +50,7 @@ void	tty_repeat_space(struct tty *, u_int);
 void	tty_cell(struct tty *, const struct grid_cell *,
 	    const struct window_pane *);
 void	tty_default_colours(struct grid_cell *, const struct window_pane *);
+int	need_fake_bce(const struct tty *, const struct window_pane *);
 
 #define tty_use_acs(tty) \
 	(tty_term_has((tty)->term, TTYC_ACSC) && !((tty)->flags & TTY_UTF8))
@@ -666,7 +667,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy,
 
 	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) && !need_fake_bce(tty, wp))
 		tty_putcode(tty, TTYC_EL);
 	else
 		tty_repeat_space(tty, screen_size_x(s) - sx);
@@ -725,8 +726,8 @@ tty_cmd_insertcharacter(struct tty *tty, const struct tty_ctx *ctx)
 
 	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 (!need_fake_bce(tty, wp) && (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,
@@ -738,7 +739,7 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx)
 {
 	struct window_pane	*wp = ctx->wp;
 
-	if (!tty_pane_full_width(tty, ctx) ||
+	if (!tty_pane_full_width(tty, ctx) || need_fake_bce(tty, wp) ||
 	    (!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,
@@ -764,7 +765,7 @@ tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx)
 
 	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) && !need_fake_bce(tty, ctx->wp))
 		tty_putcode1(tty, TTYC_ECH, ctx->num);
 	else {
 		for (i = 0; i < ctx->num; i++)
@@ -775,7 +776,7 @@ 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) ||
+	if (!tty_pane_full_width(tty, ctx) || need_fake_bce(tty, ctx->wp) ||
 	    !tty_term_has(tty->term, TTYC_CSR) ||
 	    !tty_term_has(tty->term, TTYC_IL1)) {
 		tty_redraw_region(tty, ctx);
@@ -793,7 +794,7 @@ 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) ||
+	if (!tty_pane_full_width(tty, ctx) || need_fake_bce(tty, ctx->wp) ||
 	    !tty_term_has(tty->term, TTYC_CSR) ||
 	    !tty_term_has(tty->term, TTYC_DL1)) {
 		tty_redraw_region(tty, ctx);
@@ -818,7 +819,8 @@ tty_cmd_clearline(struct tty *tty, const struct tty_ctx *ctx)
 
 	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) && !need_fake_bce(tty, wp) &&
+	    tty_term_has(tty->term, TTYC_EL))
 		tty_putcode(tty, TTYC_EL);
 	else
 		tty_repeat_space(tty, screen_size_x(s));
@@ -834,7 +836,8 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)
 
 	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) && !need_fake_bce(tty, wp))
 		tty_putcode(tty, TTYC_EL);
 	else
 		tty_repeat_space(tty, screen_size_x(s) - ctx->ocx);
@@ -845,7 +848,8 @@ tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx)
 {
 	tty_attributes(tty, &grid_default_cell, ctx->wp);
 
-	if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1)) {
+	if (ctx->xoff == 0 && tty_term_has(tty->term, TTYC_EL1) &&
+	    !need_fake_bce(tty, ctx->wp)) {
 		tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);
 		tty_putcode(tty, TTYC_EL1);
 	} else {
@@ -860,7 +864,7 @@ tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx)
 	if (ctx->ocy != ctx->orupper)
 		return;
 
-	if (!tty_pane_full_width(tty, ctx) ||
+	if (!tty_pane_full_width(tty, ctx) || need_fake_bce(tty, ctx->wp) ||
 	    !tty_term_has(tty->term, TTYC_CSR) ||
 	    !tty_term_has(tty->term, TTYC_RI)) {
 		tty_redraw_region(tty, ctx);
@@ -883,7 +887,7 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx)
 	if (ctx->ocy != ctx->orlower)
 		return;
 
-	if (!tty_pane_full_width(tty, ctx) ||
+	if (!tty_pane_full_width(tty, ctx) || need_fake_bce(tty, wp) ||
 	    !tty_term_has(tty->term, TTYC_CSR)) {
 		if (tty_large_region(tty, ctx))
 			wp->flags |= PANE_REDRAW;
@@ -920,7 +924,8 @@ tty_cmd_clearendofscreen(struct tty *tty, const struct tty_ctx *ctx)
 	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) && !need_fake_bce(tty, wp)) {
 		tty_putcode(tty, TTYC_EL);
 		if (ctx->ocy != screen_size_y(s) - 1) {
 			tty_cursor_pane(tty, ctx, 0, ctx->ocy + 1);
@@ -953,7 +958,8 @@ tty_cmd_clearstartofscreen(struct tty *tty, const struct tty_ctx *ctx)
 	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) && !need_fake_bce(tty, wp)) {
 		for (i = 0; i < ctx->ocy; i++) {
 			tty_putcode(tty, TTYC_EL);
 			tty_emulate_repeat(tty, TTYC_CUD, TTYC_CUD1, 1);
@@ -980,7 +986,8 @@ tty_cmd_clearscreen(struct tty *tty, const struct tty_ctx *ctx)
 	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) && !need_fake_bce(tty, wp)) {
 		for (i = 0; i < screen_size_y(s); i++) {
 			tty_putcode(tty, TTYC_EL);
 			if (i != screen_size_y(s) - 1) {
@@ -1664,3 +1671,17 @@ tty_default_colours(struct grid_cell *gc, const struct window_pane *wp)
 		}
 	}
 }
+
+int
+need_fake_bce(const struct tty *tty, const struct window_pane *wp)
+{
+	struct grid_cell	gc;
+
+	memcpy(&gc, &grid_default_cell, sizeof gc);
+	tty_default_colours(&gc, wp);
+
+	if (gc.bg == 8 && !(gc.flags & GRID_FLAG_BG256))
+		return (0);
+	else
+		return (!tty_term_has(tty->term, TTYC_BCE));
+}
------------------------------------------------------------------------------
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

Reply via email to