version 1.17, 2009/12/03 22:50:10 |
version 1.18, 2010/04/06 21:35:44 |
|
|
gc, sizeof gd->linedata[py].utf8data[px]); \ |
gc, sizeof gd->linedata[py].utf8data[px]); \ |
} while (0) |
} while (0) |
|
|
int grid_check_x(struct grid *, u_int); |
|
int grid_check_y(struct grid *, u_int); |
int grid_check_y(struct grid *, u_int); |
|
|
#ifdef DEBUG |
#ifdef DEBUG |
int |
int |
grid_check_x(struct grid *gd, u_int px) |
|
{ |
|
if ((px) >= (gd)->sx) |
|
log_fatalx("x out of range: %u", px); |
|
return (0); |
|
} |
|
|
|
int |
|
grid_check_y(struct grid *gd, u_int py) |
grid_check_y(struct grid *gd, u_int py) |
{ |
{ |
if ((py) >= (gd)->hsize + (gd)->sy) |
if ((py) >= (gd)->hsize + (gd)->sy) |
|
|
} |
} |
#else |
#else |
int |
int |
grid_check_x(struct grid *gd, u_int px) |
|
{ |
|
if ((px) >= (gd)->sx) { |
|
log_debug("x out of range: %u", px); |
|
return (-1); |
|
} |
|
return (0); |
|
} |
|
|
|
int |
|
grid_check_y(struct grid *gd, u_int py) |
grid_check_y(struct grid *gd, u_int py) |
{ |
{ |
if ((py) >= (gd)->hsize + (gd)->sy) { |
if ((py) >= (gd)->hsize + (gd)->sy) { |
|
|
const struct grid_cell * |
const struct grid_cell * |
grid_peek_cell(struct grid *gd, u_int px, u_int py) |
grid_peek_cell(struct grid *gd, u_int px, u_int py) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return (&grid_default_cell); |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return (&grid_default_cell); |
return (&grid_default_cell); |
|
|
|
|
struct grid_cell * |
struct grid_cell * |
grid_get_cell(struct grid *gd, u_int px, u_int py) |
grid_get_cell(struct grid *gd, u_int px, u_int py) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return (NULL); |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return (NULL); |
return (NULL); |
|
|
|
|
grid_set_cell( |
grid_set_cell( |
struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) |
struct grid *gd, u_int px, u_int py, const struct grid_cell *gc) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return; |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return; |
return; |
|
|
|
|
const struct grid_utf8 * |
const struct grid_utf8 * |
grid_peek_utf8(struct grid *gd, u_int px, u_int py) |
grid_peek_utf8(struct grid *gd, u_int px, u_int py) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return (NULL); |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return (NULL); |
return (NULL); |
|
|
|
|
struct grid_utf8 * |
struct grid_utf8 * |
grid_get_utf8(struct grid *gd, u_int px, u_int py) |
grid_get_utf8(struct grid *gd, u_int px, u_int py) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return (NULL); |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return (NULL); |
return (NULL); |
|
|
|
|
grid_set_utf8( |
grid_set_utf8( |
struct grid *gd, u_int px, u_int py, const struct grid_utf8 *gc) |
struct grid *gd, u_int px, u_int py, const struct grid_utf8 *gc) |
{ |
{ |
if (grid_check_x(gd, px) != 0) |
|
return; |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return; |
return; |
|
|
|
|
return; |
return; |
} |
} |
|
|
if (grid_check_x(gd, px) != 0) |
|
return; |
|
if (grid_check_x(gd, px + nx - 1) != 0) |
|
return; |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return; |
return; |
if (grid_check_y(gd, py + ny - 1) != 0) |
if (grid_check_y(gd, py + ny - 1) != 0) |
|
|
if (nx == 0 || px == dx) |
if (nx == 0 || px == dx) |
return; |
return; |
|
|
if (grid_check_x(gd, px) != 0) |
|
return; |
|
if (grid_check_x(gd, px + nx - 1) != 0) |
|
return; |
|
if (grid_check_x(gd, dx + nx - 1) != 0) |
|
return; |
|
if (grid_check_y(gd, py) != 0) |
if (grid_check_y(gd, py) != 0) |
return; |
return; |
gl = &gd->linedata[py]; |
gl = &gd->linedata[py]; |