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.
This commit is contained in:
Nicholas Marriott
2009-03-28 16:30:05 +00:00
parent 5872633aef
commit 6c0728fe07
10 changed files with 167 additions and 89 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-find-window.c,v 1.3 2009-01-19 18:23:40 nicm Exp $ */
/* $Id: cmd-find-window.c,v 1.4 2009-03-28 16:30:05 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -163,19 +163,19 @@ cmd_find_window_callback(void *data, int idx)
char *
cmd_find_window_search(struct window_pane *wp, const char *searchstr)
{
char *buf, *s;
size_t off;
const struct grid_cell *gc;
u_int i, j, k;
u_char data[4];
char *buf, *s;
size_t off;
uint64_t text;
u_int i, j, k;
u_char data[4];
buf = xmalloc(1);
for (j = 0; j < screen_size_y(&wp->base); j++) {
off = 0;
for (i = 0; i < screen_size_x(&wp->base); i++) {
gc = grid_view_peek_cell(wp->base.grid, i, j);
utf8_split(gc->data, data);
text = grid_view_peek_text(wp->base.grid, i, j);
utf8_split(text, data);
buf = xrealloc(buf, 1, off + 4);
for (k = 0; k < sizeof data; k++) {