mirror of
https://github.com/tmux/tmux.git
synced 2026-10-12 13:44:44 +00:00
Add additional grid consistency checks for macOS.
This commit is contained in:
49
grid.c
49
grid.c
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -56,6 +59,28 @@ static const struct grid_cell_entry grid_cleared_entry = {
|
|||||||
{ .data = { 0, 8, 8, ' ' } }, GRID_FLAG_CLEARED
|
{ .data = { 0, 8, 8, ' ' } }, GRID_FLAG_CLEARED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
static void
|
||||||
|
grid_check_lines(struct grid *gd)
|
||||||
|
{
|
||||||
|
u_int i, j;
|
||||||
|
|
||||||
|
for (i = 0; i < gd->hsize + gd->sy; i++) {
|
||||||
|
for (j = i + 1; j < gd->hsize + gd->sy; j++) {
|
||||||
|
if (gd->linedata[i].celldata != NULL)
|
||||||
|
assert(gd->linedata[i].celldata != gd->linedata[j].celldata);
|
||||||
|
if (gd->linedata[i].extddata != NULL)
|
||||||
|
assert(gd->linedata[i].extddata != gd->linedata[j].extddata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void
|
||||||
|
grid_check_lines(__unused struct grid *gd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Store cell in entry. */
|
/* Store cell in entry. */
|
||||||
static void
|
static void
|
||||||
grid_store_cell(struct grid_cell_entry *gce, const struct grid_cell *gc,
|
grid_store_cell(struct grid_cell_entry *gce, const struct grid_cell *gc,
|
||||||
@@ -287,9 +312,17 @@ grid_set_tab(struct grid_cell *gc, u_int width)
|
|||||||
static void
|
static void
|
||||||
grid_free_line(struct grid *gd, u_int py)
|
grid_free_line(struct grid *gd, u_int py)
|
||||||
{
|
{
|
||||||
free(gd->linedata[py].celldata);
|
struct grid_line *gl = &gd->linedata[py];
|
||||||
free(gd->linedata[py].extddata);
|
|
||||||
memset(&gd->linedata[py], 0, sizeof gd->linedata[py]);
|
#ifdef __APPLE__
|
||||||
|
assert(gl->cellused <= gl->cellsize);
|
||||||
|
assert(gl->extdsize == 0 || gl->extddata != NULL);
|
||||||
|
assert(gl->cellsize == 0 || gl->celldata != NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
free(gl->celldata);
|
||||||
|
free(gl->extddata);
|
||||||
|
memset(gl, 0, sizeof *gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free several lines. */
|
/* Free several lines. */
|
||||||
@@ -449,6 +482,8 @@ grid_scroll_history(struct grid *gd, u_int bg)
|
|||||||
gd->linedata[gd->hsize].time = current_time;
|
gd->linedata[gd->hsize].time = current_time;
|
||||||
gd->hsize++;
|
gd->hsize++;
|
||||||
gd->scroll_added++;
|
gd->scroll_added++;
|
||||||
|
|
||||||
|
grid_check_lines(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the history. */
|
/* Clear the history. */
|
||||||
@@ -498,6 +533,8 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower, u_int bg)
|
|||||||
gd->hscrolled++;
|
gd->hscrolled++;
|
||||||
gd->hsize++;
|
gd->hsize++;
|
||||||
gd->scroll_added++;
|
gd->scroll_added++;
|
||||||
|
|
||||||
|
grid_check_lines(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Expand line to fit to cell. */
|
/* Expand line to fit to cell. */
|
||||||
@@ -759,6 +796,8 @@ grid_move_lines(struct grid *gd, u_int dy, u_int py, u_int ny, u_int bg)
|
|||||||
}
|
}
|
||||||
if (py != 0 && (py < dy || py >= dy + ny))
|
if (py != 0 && (py < dy || py >= dy + ny))
|
||||||
gd->linedata[py - 1].flags &= ~GRID_LINE_WRAPPED;
|
gd->linedata[py - 1].flags &= ~GRID_LINE_WRAPPED;
|
||||||
|
|
||||||
|
grid_check_lines(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move a group of cells. */
|
/* Move a group of cells. */
|
||||||
@@ -1248,6 +1287,8 @@ grid_duplicate_lines(struct grid *dst, u_int dy, struct grid *src, u_int sy,
|
|||||||
sy++;
|
sy++;
|
||||||
dy++;
|
dy++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grid_check_lines(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark line as dead. */
|
/* Mark line as dead. */
|
||||||
@@ -1544,6 +1585,8 @@ grid_reflow(struct grid *gd, u_int sx)
|
|||||||
gd->linedata = target->linedata;
|
gd->linedata = target->linedata;
|
||||||
free(target);
|
free(target);
|
||||||
gd->scroll_generation++;
|
gd->scroll_generation++;
|
||||||
|
|
||||||
|
grid_check_lines(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to position based on wrapped lines. */
|
/* Convert to position based on wrapped lines. */
|
||||||
|
|||||||
Reference in New Issue
Block a user