summaryrefslogtreecommitdiffstats
path: root/screen.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 16:30:05 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 16:30:05 +0000
commit6c0728fe0710c3a73ff0efbaf4e8e8281d99ecdf (patch)
treeb918fc36a5daafdd3e5223aca3a4d5227d994d3e /screen.c
parent5872633aeff2ae60735458e3904cfe00087dc30d (diff)
Step 2 of the Grand Plan To Make UTF-8 Better.
Split grid into two arrays, one containing grid attributes/flags/colours (keeps the name grid_cell for now) and a separate with the character data (called text). The text is stored as a u_short but is treated as a uint64_t elsewhere; eventually the grid will have two arrays. I'm not happy with the naming so that might change. Still need to decide where to go from here. I'm not sure whether to combine the peek/set functions together, and also whether to continue to treat the text as a uint64_t (and convert to/from Unicode) or make it a char array (of size one when UTF-8 disabled, eight when enabled) and keep everything as UTF-8. Also since UTF-8 will eventually become an attribute of the grid itself it might be nice to move all the padding crap into grid.c.
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/screen.c b/screen.c
index 7050ed70..bdbe5068 100644
--- a/screen.c
+++ b/screen.c
@@ -1,4 +1,4 @@
-/* $Id: screen.c,v 1.79 2009-03-28 15:43:41 nicm Exp $ */
+/* $Id: screen.c,v 1.80 2009-03-28 16:30:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -89,6 +89,7 @@ screen_resize_x(struct screen *s, u_int sx)
{
struct grid *gd = s->grid;
const struct grid_cell *gc;
+ uint64_t text;
u_int xx, yy;
if (sx == 0)
@@ -106,14 +107,15 @@ screen_resize_x(struct screen *s, u_int sx)
* If the character after the last is wide or padding, remove
* it and any leading padding.
*/
- gc = &grid_default_cell;
+ text = ' ';
for (xx = sx; xx > 0; xx--) {
gc = grid_peek_cell(gd, xx - 1, yy);
+ text = grid_peek_text(gd, xx - 1, yy);
if (!(gc->flags & GRID_FLAG_PADDING))
break;
grid_set_cell(gd, xx - 1, yy, &grid_default_cell);
}
- if (xx > 0 && xx != sx && utf8_width(gc->data) != 1)
+ if (xx > 0 && xx != sx && utf8_width(text) != 1)
grid_set_cell(gd, xx - 1, yy, &grid_default_cell);
/* Reduce the line size. */
@@ -165,6 +167,7 @@ screen_resize_y(struct screen *s, u_int sy)
/* Resize line arrays. */
gd->size = xrealloc(gd->size, gd->hsize + sy, sizeof *gd->size);
gd->data = xrealloc(gd->data, gd->hsize + sy, sizeof *gd->data);
+ gd->text = xrealloc(gd->text, gd->hsize + sy, sizeof *gd->text);
/* Size increasing. */
if (sy > screen_size_y(s)) {
@@ -172,6 +175,7 @@ screen_resize_y(struct screen *s, u_int sy)
for (yy = gd->hsize + oy; yy < gd->hsize + sy; yy++) {
gd->size[yy] = 0;
gd->data[yy] = NULL;
+ gd->text[yy] = NULL;
}
}