=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.86 retrieving revision 1.87 diff -c -r1.86 -r1.87 *** src/usr.bin/tmux/screen-write.c 2016/04/29 13:21:33 1.86 --- src/usr.bin/tmux/screen-write.c 2016/05/27 23:02:17 1.87 *************** *** 1,4 **** ! /* $OpenBSD: screen-write.c,v 1.86 2016/04/29 13:21:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen-write.c,v 1.87 2016/05/27 23:02:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 23,33 **** #include "tmux.h" ! void screen_write_initctx(struct screen_write_ctx *, struct tty_ctx *, int); ! void screen_write_overwrite(struct screen_write_ctx *, u_int); ! int screen_write_combine(struct screen_write_ctx *, ! const struct utf8_data *); /* Initialise writing with a window. */ void screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp, --- 23,37 ---- #include "tmux.h" ! static void screen_write_initctx(struct screen_write_ctx *, ! struct tty_ctx *); ! static void screen_write_save_last(struct screen_write_ctx *, ! struct tty_ctx *); + static void screen_write_overwrite(struct screen_write_ctx *, u_int); + static int screen_write_combine(struct screen_write_ctx *, + const struct utf8_data *); + /* Initialise writing with a window. */ void screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp, *************** *** 344,357 **** } /* Set up context for TTY command. */ ! void ! screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, ! int save_last) { ! struct screen *s = ctx->s; ! struct grid *gd = s->grid; ! struct grid_cell gc; ! u_int xx; ttyctx->wp = ctx->wp; --- 348,357 ---- } /* Set up context for TTY command. */ ! static void ! screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx) { ! struct screen *s = ctx->s; ttyctx->wp = ctx->wp; *************** *** 360,370 **** ttyctx->orlower = s->rlower; ttyctx->orupper = s->rupper; ! if (!save_last) ! return; - /* Save the last cell on the screen. */ memcpy(&gc, &grid_default_cell, sizeof gc); for (xx = 1; xx <= screen_size_x(s); xx++) { grid_view_get_cell(gd, screen_size_x(s) - xx, s->cy, &gc); --- 360,376 ---- ttyctx->orlower = s->rlower; ttyctx->orupper = s->rupper; + } ! /* Save last cell on screen. */ ! static void ! screen_write_save_last(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx) ! { ! struct screen *s = ctx->s; ! struct grid *gd = s->grid; ! struct grid_cell gc; ! u_int xx; memcpy(&gc, &grid_default_cell, sizeof gc); for (xx = 1; xx <= screen_size_x(s); xx++) { grid_view_get_cell(gd, screen_size_x(s) - xx, s->cy, &gc); *************** *** 507,513 **** struct grid_cell gc; u_int xx, yy; ! screen_write_initctx(ctx, &ttyctx, 0); memcpy(&gc, &grid_default_cell, sizeof gc); utf8_set(&gc.data, 'E'); --- 513,519 ---- struct grid_cell gc; u_int xx, yy; ! screen_write_initctx(ctx, &ttyctx); memcpy(&gc, &grid_default_cell, sizeof gc); utf8_set(&gc.data, 'E'); *************** *** 542,548 **** if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cx <= screen_size_x(s) - 1) grid_view_insert_cells(s->grid, s->cx, s->cy, nx); --- 548,554 ---- if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx); if (s->cx <= screen_size_x(s) - 1) grid_view_insert_cells(s->grid, s->cx, s->cy, nx); *************** *** 566,572 **** if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cx <= screen_size_x(s) - 1) grid_view_delete_cells(s->grid, s->cx, s->cy, nx); --- 572,578 ---- if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx); if (s->cx <= screen_size_x(s) - 1) grid_view_delete_cells(s->grid, s->cx, s->cy, nx); *************** *** 590,596 **** if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cx <= screen_size_x(s) - 1) grid_view_clear(s->grid, s->cx, s->cy, nx, 1); --- 596,602 ---- if (nx == 0) return; ! screen_write_initctx(ctx, &ttyctx); if (s->cx <= screen_size_x(s) - 1) grid_view_clear(s->grid, s->cx, s->cy, nx, 1); *************** *** 615,621 **** if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); grid_view_insert_lines(s->grid, s->cy, ny); --- 621,627 ---- if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx); grid_view_insert_lines(s->grid, s->cy, ny); *************** *** 629,635 **** if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_insert_lines(s->grid, s->cy, ny); --- 635,641 ---- if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_insert_lines(s->grid, s->cy, ny); *************** *** 656,662 **** if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); grid_view_delete_lines(s->grid, s->cy, ny); --- 662,668 ---- if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx); grid_view_delete_lines(s->grid, s->cy, ny); *************** *** 670,676 **** if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_delete_lines(s->grid, s->cy, ny); --- 676,682 ---- if (ny == 0) return; ! screen_write_initctx(ctx, &ttyctx); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_delete_lines(s->grid, s->cy, ny); *************** *** 688,694 **** struct screen *s = ctx->s; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx, 0); grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1); --- 694,700 ---- struct screen *s = ctx->s; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx); grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1); *************** *** 703,709 **** struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx, 0); sx = screen_size_x(s); --- 709,715 ---- struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); *************** *** 721,727 **** struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx, 0); sx = screen_size_x(s); --- 727,733 ---- struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); *************** *** 755,761 **** struct screen *s = ctx->s; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx, 0); if (s->cy == s->rupper) grid_view_scroll_region_down(s->grid, s->rupper, s->rlower); --- 761,767 ---- struct screen *s = ctx->s; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx); if (s->cy == s->rupper) grid_view_scroll_region_down(s->grid, s->rupper, s->rlower); *************** *** 795,801 **** struct grid_line *gl; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx, 0); gl = &s->grid->linedata[s->grid->hsize + s->cy]; if (wrapped) --- 801,807 ---- struct grid_line *gl; struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx); gl = &s->grid->linedata[s->grid->hsize + s->cy]; if (wrapped) *************** *** 829,835 **** struct tty_ctx ttyctx; u_int sx, sy; ! screen_write_initctx(ctx, &ttyctx, 0); sx = screen_size_x(s); sy = screen_size_y(s); --- 835,841 ---- struct tty_ctx ttyctx; u_int sx, sy; ! screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); sy = screen_size_y(s); *************** *** 854,860 **** struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx, 0); sx = screen_size_x(s); --- 860,866 ---- struct tty_ctx ttyctx; u_int sx; ! screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); *************** *** 877,883 **** u_int sx = screen_size_x(s); u_int sy = screen_size_y(s); ! screen_write_initctx(ctx, &ttyctx, 0); /* Scroll into history if it is enabled. */ if (s->grid->flags & GRID_HISTORY) --- 883,889 ---- u_int sx = screen_size_x(s); u_int sy = screen_size_y(s); ! screen_write_initctx(ctx, &ttyctx); /* Scroll into history if it is enabled. */ if (s->grid->flags & GRID_HISTORY) *************** *** 931,944 **** */ if (width == 0) { if (screen_write_combine(ctx, &gc->data) == 0) { ! screen_write_initctx(ctx, &ttyctx, 0); tty_write(tty_cmd_utf8character, &ttyctx); } return; } /* Initialise the redraw context, saving the last cell. */ ! screen_write_initctx(ctx, &ttyctx, 1); /* If in insert mode, make space for the cells. */ if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) { --- 937,951 ---- */ if (width == 0) { if (screen_write_combine(ctx, &gc->data) == 0) { ! screen_write_initctx(ctx, &ttyctx); tty_write(tty_cmd_utf8character, &ttyctx); } return; } /* Initialise the redraw context, saving the last cell. */ ! screen_write_initctx(ctx, &ttyctx); ! screen_write_save_last(ctx, &ttyctx); /* If in insert mode, make space for the cells. */ if ((s->mode & MODE_INSERT) && s->cx <= screen_size_x(s) - width) { *************** *** 1008,1014 **** } /* Combine a UTF-8 zero-width character onto the previous. */ ! int screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud) { struct screen *s = ctx->s; --- 1015,1021 ---- } /* Combine a UTF-8 zero-width character onto the previous. */ ! static int screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud) { struct screen *s = ctx->s; *************** *** 1049,1055 **** * character, it is necessary to also overwrite any other cells which covered * by the same character. */ ! void screen_write_overwrite(struct screen_write_ctx *ctx, u_int width) { struct screen *s = ctx->s; --- 1056,1062 ---- * character, it is necessary to also overwrite any other cells which covered * by the same character. */ ! static void screen_write_overwrite(struct screen_write_ctx *ctx, u_int width) { struct screen *s = ctx->s; *************** *** 1094,1100 **** { struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx, 0); ttyctx.ptr = str; ttyctx.num = len; --- 1101,1107 ---- { struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx); ttyctx.ptr = str; ttyctx.num = len; *************** *** 1104,1112 **** void screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len) { ! struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx, 0); ttyctx.ptr = str; ttyctx.num = len; --- 1111,1119 ---- void screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len) { ! struct tty_ctx ttyctx; ! screen_write_initctx(ctx, &ttyctx); ttyctx.ptr = str; ttyctx.num = len;