Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2020-06-03 00:01:20 +01:00
commit 62c0617d79
5 changed files with 33 additions and 12 deletions

View File

@ -45,6 +45,13 @@ grid_view_set_cell(struct grid *gd, u_int px, u_int py,
grid_set_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py), gc); grid_set_cell(gd, grid_view_x(gd, px), grid_view_y(gd, py), gc);
} }
/* Set padding. */
void
grid_view_set_padding(struct grid *gd, u_int px, u_int py)
{
grid_set_padding(gd, grid_view_x(gd, px), grid_view_y(gd, py));
}
/* Set cells. */ /* Set cells. */
void void
grid_view_set_cells(struct grid *gd, u_int px, u_int py, grid_view_set_cells(struct grid *gd, u_int px, u_int py,

21
grid.c
View File

@ -40,8 +40,16 @@ const struct grid_cell grid_default_cell = {
{ { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0 { { ' ' }, 0, 1, 1 }, 0, 0, 8, 8, 0
}; };
/*
* Padding grid cell data. Padding cells are the only zero width cell that
* appears in the grid - because of this, they are always extended cells.
*/
static const struct grid_cell grid_padding_cell = {
{ { '!' }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0
};
/* Cleared grid cell data. */ /* Cleared grid cell data. */
const struct grid_cell grid_cleared_cell = { static const struct grid_cell grid_cleared_cell = {
{ { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0 { { ' ' }, 0, 1, 1 }, 0, GRID_FLAG_CLEARED, 8, 8, 0
}; };
static const struct grid_cell_entry grid_cleared_entry = { static const struct grid_cell_entry grid_cleared_entry = {
@ -524,7 +532,7 @@ grid_get_cell(struct grid *gd, u_int px, u_int py, struct grid_cell *gc)
grid_get_cell1(&gd->linedata[py], px, gc); grid_get_cell1(&gd->linedata[py], px, gc);
} }
/* Set cell at relative position. */ /* Set cell at position. */
void void
grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
{ {
@ -547,7 +555,14 @@ grid_set_cell(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc)
grid_store_cell(gce, gc, gc->data.data[0]); grid_store_cell(gce, gc, gc->data.data[0]);
} }
/* Set cells at relative position. */ /* Set padding at position. */
void
grid_set_padding(struct grid *gd, u_int px, u_int py)
{
grid_set_cell(gd, px, py, &grid_padding_cell);
}
/* Set cells at position. */
void void
grid_set_cells(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc, grid_set_cells(struct grid *gd, u_int px, u_int py, const struct grid_cell *gc,
const char *s, size_t slen) const char *s, size_t slen)

View File

@ -38,10 +38,6 @@ static int screen_write_overwrite(struct screen_write_ctx *,
static const struct grid_cell *screen_write_combine(struct screen_write_ctx *, static const struct grid_cell *screen_write_combine(struct screen_write_ctx *,
const struct utf8_data *, u_int *); const struct utf8_data *, u_int *);
static const struct grid_cell screen_write_pad_cell = {
{ { 0 }, 0, 0, 0 }, 0, GRID_FLAG_PADDING, 8, 8, 0
};
struct screen_write_collect_item { struct screen_write_collect_item {
u_int x; u_int x;
int wrapped; int wrapped;
@ -1774,7 +1770,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
*/ */
for (xx = s->cx + 1; xx < s->cx + width; xx++) { for (xx = s->cx + 1; xx < s->cx + width; xx++) {
log_debug("%s: new padding at %u,%u", __func__, xx, s->cy); log_debug("%s: new padding at %u,%u", __func__, xx, s->cy);
grid_view_set_cell(gd, xx, s->cy, &screen_write_pad_cell); grid_view_set_padding(gd, xx, s->cy);
skip = 0; skip = 0;
} }

2
tmux.h
View File

@ -2501,6 +2501,7 @@ void grid_clear_history(struct grid *);
const struct grid_line *grid_peek_line(struct grid *, u_int); const struct grid_line *grid_peek_line(struct grid *, u_int);
void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *); void grid_set_cell(struct grid *, u_int, u_int, const struct grid_cell *);
void grid_set_padding(struct grid *, u_int, u_int);
void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *, void grid_set_cells(struct grid *, u_int, u_int, const struct grid_cell *,
const char *, size_t); const char *, size_t);
struct grid_line *grid_get_line(struct grid *, u_int); struct grid_line *grid_get_line(struct grid *, u_int);
@ -2522,6 +2523,7 @@ u_int grid_line_length(struct grid *, u_int);
void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *); void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
void grid_view_set_cell(struct grid *, u_int, u_int, void grid_view_set_cell(struct grid *, u_int, u_int,
const struct grid_cell *); const struct grid_cell *);
void grid_view_set_padding(struct grid *, u_int, u_int);
void grid_view_set_cells(struct grid *, u_int, u_int, void grid_view_set_cells(struct grid *, u_int, u_int,
const struct grid_cell *, const char *, size_t); const struct grid_cell *, const char *, size_t);
void grid_view_clear_history(struct grid *, u_int); void grid_view_clear_history(struct grid *, u_int);

7
tty.c
View File

@ -1380,9 +1380,10 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
screen_select_cell(s, &last, gcp); screen_select_cell(s, &last, gcp);
else else
memcpy(&last, gcp, sizeof last); memcpy(&last, gcp, sizeof last);
if (!tty_check_overlay(tty, atx + ux, aty)) if (!tty_check_overlay(tty, atx + ux, aty)) {
if (~gcp->flags & GRID_FLAG_PADDING)
ux += gcp->data.width; ux += gcp->data.width;
else if (ux + gcp->data.width > nx) { } else if (ux + gcp->data.width > nx) {
tty_attributes(tty, &last, defaults, palette); tty_attributes(tty, &last, defaults, palette);
tty_cursor(tty, atx + ux, aty); tty_cursor(tty, atx + ux, aty);
for (j = 0; j < gcp->data.width; j++) { for (j = 0; j < gcp->data.width; j++) {
@ -1397,7 +1398,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int px, u_int py, u_int nx,
for (j = 0; j < gcp->data.size; j++) for (j = 0; j < gcp->data.size; j++)
tty_putc(tty, gcp->data.data[j]); tty_putc(tty, gcp->data.data[j]);
ux += gcp->data.width; ux += gcp->data.width;
} else { } else if (~gcp->flags & GRID_FLAG_PADDING) {
memcpy(buf + len, gcp->data.data, gcp->data.size); memcpy(buf + len, gcp->data.data, gcp->data.size);
len += gcp->data.size; len += gcp->data.size;
width += gcp->data.width; width += gcp->data.width;