=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.86 retrieving revision 1.87 diff -u -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 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.86 2016/04/29 13:21:33 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.87 2016/05/27 23:02:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -23,11 +23,15 @@ #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 *); +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,14 +348,10 @@ } /* Set up context for TTY command. */ -void -screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, - int save_last) +static void +screen_write_initctx(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; + struct screen *s = ctx->s; ttyctx->wp = ctx->wp; @@ -360,11 +360,17 @@ ttyctx->orlower = s->rlower; ttyctx->orupper = s->rupper; +} - if (!save_last) - return; +/* 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; - /* 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); @@ -507,7 +513,7 @@ struct grid_cell gc; u_int xx, yy; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); memcpy(&gc, &grid_default_cell, sizeof gc); utf8_set(&gc.data, 'E'); @@ -542,7 +548,7 @@ if (nx == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + 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,7 +572,7 @@ if (nx == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + 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,7 +596,7 @@ if (nx == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + 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,7 +621,7 @@ if (ny == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); grid_view_insert_lines(s->grid, s->cy, ny); @@ -629,7 +635,7 @@ if (ny == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_insert_lines(s->grid, s->cy, ny); @@ -656,7 +662,7 @@ if (ny == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); grid_view_delete_lines(s->grid, s->cy, ny); @@ -670,7 +676,7 @@ if (ny == 0) return; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); if (s->cy < s->rupper || s->cy > s->rlower) grid_view_delete_lines(s->grid, s->cy, ny); @@ -688,7 +694,7 @@ struct screen *s = ctx->s; struct tty_ctx ttyctx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1); @@ -703,7 +709,7 @@ struct tty_ctx ttyctx; u_int sx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); @@ -721,7 +727,7 @@ struct tty_ctx ttyctx; u_int sx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); @@ -755,7 +761,7 @@ struct screen *s = ctx->s; struct tty_ctx ttyctx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); if (s->cy == s->rupper) grid_view_scroll_region_down(s->grid, s->rupper, s->rlower); @@ -795,7 +801,7 @@ struct grid_line *gl; struct tty_ctx ttyctx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); gl = &s->grid->linedata[s->grid->hsize + s->cy]; if (wrapped) @@ -829,7 +835,7 @@ struct tty_ctx ttyctx; u_int sx, sy; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); sy = screen_size_y(s); @@ -854,7 +860,7 @@ struct tty_ctx ttyctx; u_int sx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); sx = screen_size_x(s); @@ -877,7 +883,7 @@ u_int sx = screen_size_x(s); u_int sy = screen_size_y(s); - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); /* Scroll into history if it is enabled. */ if (s->grid->flags & GRID_HISTORY) @@ -931,14 +937,15 @@ */ if (width == 0) { if (screen_write_combine(ctx, &gc->data) == 0) { - screen_write_initctx(ctx, &ttyctx, 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, 1); + 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,7 +1015,7 @@ } /* Combine a UTF-8 zero-width character onto the previous. */ -int +static int screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud) { struct screen *s = ctx->s; @@ -1049,7 +1056,7 @@ * character, it is necessary to also overwrite any other cells which covered * by the same character. */ -void +static void screen_write_overwrite(struct screen_write_ctx *ctx, u_int width) { struct screen *s = ctx->s; @@ -1094,7 +1101,7 @@ { struct tty_ctx ttyctx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); ttyctx.ptr = str; ttyctx.num = len; @@ -1104,9 +1111,9 @@ void screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len) { - struct tty_ctx ttyctx; + struct tty_ctx ttyctx; - screen_write_initctx(ctx, &ttyctx, 0); + screen_write_initctx(ctx, &ttyctx); ttyctx.ptr = str; ttyctx.num = len;