mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Break the save-last-cell code into a separate function (so it can be
called conditionally later).
This commit is contained in:
parent
9892d80d6f
commit
382222af8e
@ -23,10 +23,14 @@
|
||||
|
||||
#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
|
||||
@ -344,14 +348,10 @@ screen_write_copy(struct screen_write_ctx *ctx,
|
||||
}
|
||||
|
||||
/* 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 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx,
|
||||
|
||||
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 @@ screen_write_alignmenttest(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
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 @@ screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
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 @@ screen_write_clearcharacter(struct screen_write_ctx *ctx, u_int nx)
|
||||
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 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
||||
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 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
|
||||
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 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
||||
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 @@ screen_write_deleteline(struct screen_write_ctx *ctx, u_int ny)
|
||||
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 @@ screen_write_clearline(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_clearendofline(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_clearstartofline(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_reverseindex(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
|
||||
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 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_clearscreen(struct screen_write_ctx *ctx)
|
||||
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 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
*/
|
||||
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 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
}
|
||||
|
||||
/* 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 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct utf8_data *ud)
|
||||
* 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 @@ screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len)
|
||||
{
|
||||
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 @@ screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len)
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user