{"action":"created","issue":{"url":"https://api.github.com/repos/tmux/tmux/issues/534","repository_url":"https://api.github.com/repos/tmux/tmux","labels_url":"https://api.github.com/repos/tmux/tmux/issues/534/labels{/name}","comments_url":"https://api.github.com/repos/tmux/tmux/issues/534/comments","events_url":"https://api.github.com/repos/tmux/tmux/issues/534/events","html_url":"https://github.com/tmux/tmux/issues/534","id":177527649,"number":534,"title":"Support BCE for EL sequences","user":{"login":"sphaugh","id":8660255,"avatar_url":"https://avatars.githubusercontent.com/u/8660255?v=3","gravatar_id":"","url":"https://api.github.com/users/sphaugh","html_url":"https://github.com/sphaugh","followers_url":"https://api.github.com/users/sphaugh/followers","following_url":"https://api.github.com/users/sphaugh/following{/other_user}","gists_url":"https://api.github.com/users/sphaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/sphaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphaugh/subscriptions","organizations_url":"https://api.github.com/users/sphaugh/orgs","repos_url":"https://api.github.com/users/sphaugh/repos","events_url":"https://api.github.com/users/sphaugh/events{/privacy}","received_events_url":"https://api.github.com/users/sphaugh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-09-16T21:49:22Z","updated_at":"2016-10-04T20:33:20Z","closed_at":null,"body":"Trying to implement BCE (just plain EL for now), here are my changes so far:\r\n\r\n```\r\nindex 8160679..d7f7f86 100644\r\n--- a/grid-view.c\r\n+++ b/grid-view.c\r\n@@ -80,6 +80,17 @@ grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)\r\n        grid_clear(gd, px, py, nx, ny);\r\n }\r\n\r\n+/* Clear area using the specified background color. */\r\n+void\r\n+grid_view_clear_bce(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny,\r\n+        u_char bg)\r\n+{\r\n+       px = grid_view_x(gd, px);\r\n+       py = grid_view_y(gd, py);\r\n+\r\n+       grid_clear_bce(gd, px, py, nx, ny, bg);\r\n+}\r\n+\r\n /* Scroll region up. */\r\n void\r\n grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower)\r\ndiff --git a/grid.c b/grid.c\r\nindex 50766a8..b9e964c 100644\r\n--- a/grid.c\r\n+++ b/grid.c\r\n@@ -61,6 +61,14 @@ grid_clear_cell(struct grid *gd, u_int px, u_int py)\r\n        gd->linedata[py].celldata[px] = grid_default_entry;\r\n }\r\n\r\n+/* Copy default into cell, then apply the specified background color. */\r\n+static void\r\n+grid_clear_cell_bce(struct grid *gd, u_int px, u_int py, u_char bg)\r\n+{\r\n+       gd->linedata[py].celldata[px] = grid_default_entry;\r\n+       gd->linedata[py].celldata[px].data.bg = bg;\r\n+}\r\n+\r\n /* Check grid y position. */\r\n static int\r\n grid_check_y(struct grid *gd, u_int py)\r\n@@ -386,6 +394,41 @@ grid_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny)\r\n        }\r\n }\r\n\r\n+/* Clear area using the specified background color. */\r\n+void\r\n+grid_clear_bce(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny,\r\n+        u_char bg)\r\n+{\r\n+       u_int   xx, yy;\r\n+\r\n+       if (nx == 0 || ny == 0)\r\n+               return;\r\n+\r\n+       if (px == 0 && nx == gd->sx) {\r\n+               grid_clear_lines(gd, py, ny);\r\n+               return;\r\n+       }\r\n+\r\n+       if (grid_check_y(gd, py) != 0)\r\n+               return;\r\n+       if (grid_check_y(gd, py + ny - 1) != 0)\r\n+               return;\r\n+\r\n+       for (yy = py; yy < py + ny; yy++) {\r\n+               if (px >= gd->linedata[yy].cellsize)\r\n+                       continue;\r\n+               if (px + nx >= gd->linedata[yy].cellsize) {\r\n+                       gd->linedata[yy].cellsize = px;\r\n+                       continue;\r\n+               }\r\n+               for (xx = px; xx < px + nx; xx++) {\r\n+                       if (xx >= gd->linedata[yy].cellsize)\r\n+                               break;\r\n+                       grid_clear_cell_bce(gd, xx, yy, bg);\r\n+               }\r\n+       }\r\n+}\r\n+\r\n /* Clear lines. This just frees and truncates the lines. */\r\n void\r\n grid_clear_lines(struct grid *gd, u_int py, u_int ny)\r\ndiff --git a/input.c b/input.c\r\nindex 289a25c..39bcbd1 100644\r\n--- a/input.c\r\n+++ b/input.c\r\n@@ -953,6 +953,20 @@ input_get(struct input_ctx *ictx, u_int validx, int minval, int defval)\r\n        return (retval);\r\n }\r\n\r\n+/* Get the foreground color. */\r\n+int\r\n+input_get_fg(struct input_ctx *ictx)\r\n+{\r\n+       return ictx->cell.cell.fg;\r\n+}\r\n+\r\n+/* Get the background color. */\r\n+int\r\n+input_get_bg(struct input_ctx *ictx)\r\n+{\r\n+       return ictx->cell.cell.bg;\r\n+}\r\n+\r\n /* Reply to terminal query. */\r\n void\r\n input_reply(struct input_ctx *ictx, const char *fmt, ...)\r\ndiff --git a/screen-write.c b/screen-write.c\r\nindex 94ce359..5d1fc1b 100644\r\n--- a/screen-write.c\r\n+++ b/screen-write.c\r\n@@ -810,13 +810,20 @@ screen_write_clearendofline(struct screen_write_ctx *ctx)\r\n        struct grid_line        *gl;\r\n        struct tty_ctx           ttyctx;\r\n        u_int                    sx = screen_size_x(s);\r\n+       u_char                   bg;\r\n+\r\n+       if (ctx->wp) {\r\n+               bg = input_get_bg(ctx->wp->ictx);\r\n+       } else {\r\n+               bg = 8;\r\n+       }\r\n\r\n        screen_write_initctx(ctx, &ttyctx);\r\n\r\n        gl = &s->grid->linedata[s->grid->hsize + s->cy];\r\n-       if (s->cx <= sx - 1 && s->cx < gl->cellsize) {\r\n+       if (s->cx <= sx - 1 && s->cx <= gl->cellsize) {\r\n                screen_dirty_clear(s, s->cx, s->cy, sx - 1, s->cy);\r\n-               grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);\r\n+               grid_view_clear_bce(s->grid, s->cx, s->cy, sx - s->cx, 1, bg);\r\n        } else\r\n                return;\r\n\r\ndiff --git a/tmux.h b/tmux.h\r\nindex 1610b95..6cf413d 100644\r\n--- a/tmux.h\r\n+++ b/tmux.h\r\n@@ -1972,6 +1972,8 @@ void       input_free(struct window_pane *);\r\n void    input_reset(struct window_pane *, int);\r\n struct evbuffer *input_pending(struct window_pane *);\r\n void    input_parse(struct window_pane *);\r\n+int input_get_fg(struct input_ctx *);\r\n+int input_get_bg(struct input_ctx *);\r\n\r\n /* input-key.c */\r\n void    input_key(struct window_pane *, key_code, struct mouse_event *);\r\n@@ -2007,6 +2009,7 @@ const struct grid_line *grid_peek_line(struct grid *, u_int);\r\n void    grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);\r\n void    grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);\r\n void    grid_clear(struct grid *, u_int, u_int, u_int, u_int);\r\n+void    grid_clear_bce(struct grid *, u_int, u_int, u_int, u_int, u_char);\r\n void    grid_clear_lines(struct grid *, u_int, u_int);\r\n void    grid_move_lines(struct grid *, u_int, u_int, u_int);\r\n void    grid_move_cells(struct grid *, u_int, u_int, u_int, u_int);\r\n@@ -2022,6 +2025,7 @@ void       grid_view_set_cell(struct grid *, u_int, u_int,\r\n             const struct grid_cell *);\r\n void    grid_view_clear_history(struct grid *);\r\n void    grid_view_clear(struct grid *, u_int, u_int, u_int, u_int);\r\n+void    grid_view_clear_bce(struct grid *, u_int, u_int, u_int, u_int, u_char);\r\n void    grid_view_scroll_region_up(struct grid *, u_int, u_int);\r\n void    grid_view_scroll_region_down(struct grid *, u_int, u_int);\r\n void    grid_view_insert_lines(struct grid *, u_int, u_int);\r\ndiff --git a/tty.c b/tty.c\r\nindex b94a18b..f174a25 100644\r\n--- a/tty.c\r\n+++ b/tty.c\r\n@@ -859,8 +859,12 @@ tty_cmd_clearendofline(struct tty *tty, const struct tty_ctx *ctx)\r\n {\r\n        struct window_pane      *wp = ctx->wp;\r\n        struct screen           *s = wp->screen;\r\n+       struct grid_cell    gc;\r\n\r\n-       tty_attributes(tty, &grid_default_cell, wp);\r\n+       memcpy(&gc, &grid_default_cell, sizeof gc);\r\n+       gc.bg = input_get_bg(wp->ictx);\r\n+\r\n+       tty_attributes(tty, &gc, wp);\r\n\r\n        tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy);\r\n```\r\n\r\n* Am I doing this right?\r\n* Hints for screen-redraw?\r\n* ~~Why does this make double-width characters show as blank occasionally?~~ #535 "},"comment":{"url":"https://api.github.com/repos/tmux/tmux/issues/comments/251504600","html_url":"https://github.com/tmux/tmux/issues/534#issuecomment-251504600","issue_url":"https://api.github.com/repos/tmux/tmux/issues/534","id":251504600,"user":{"login":"sphaugh","id":8660255,"avatar_url":"https://avatars.githubusercontent.com/u/8660255?v=3","gravatar_id":"","url":"https://api.github.com/users/sphaugh","html_url":"https://github.com/sphaugh","followers_url":"https://api.github.com/users/sphaugh/followers","following_url":"https://api.github.com/users/sphaugh/following{/other_user}","gists_url":"https://api.github.com/users/sphaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/sphaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphaugh/subscriptions","organizations_url":"https://api.github.com/users/sphaugh/orgs","repos_url":"https://api.github.com/users/sphaugh/repos","events_url":"https://api.github.com/users/sphaugh/events{/privacy}","received_events_url":"https://api.github.com/users/sphaugh/received_events","type":"User","site_admin":false},"created_at":"2016-10-04T20:33:20Z","updated_at":"2016-10-04T20:33:20Z","body":"[bce.patch.txt](https://github.com/tmux/tmux/files/509473/bce.patch.txt)\r\n"}}
{"actor":{"display_login":"sphaugh"}}