summaryrefslogtreecommitdiffstats
path: root/cmd-find-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 20:17:29 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-03-28 20:17:29 +0000
commitcf7b384c43b4a2c5a1bde8b4f6bfeee20ecad027 (patch)
treef6fbcd72b5cfcd5b3579113c37cfd99efc5a0863 /cmd-find-window.c
parent34dd72f0089537032429c88226ae66d4a5980575 (diff)
Better UTF-8 support, including combined characters. Unicode data is now stored
as UTF-8 in a separate array, the code does a lookup into this every time it gets to a UTF-8 cell. Zero width characters are just appended onto the UTF-8 data for the previous cell. This also means that almost no bytes extra are wasted non-Unicode data (yay). Still some oddities, such as copy mode skips over wide characters in a strange way, and the code could do with some tidying.
Diffstat (limited to 'cmd-find-window.c')
-rw-r--r--cmd-find-window.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 333969c9..8177b8a2 100644
--- a/cmd-find-window.c
+++ b/cmd-find-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-find-window.c,v 1.4 2009-03-28 16:30:05 nicm Exp $ */
+/* $Id: cmd-find-window.c,v 1.5 2009-03-28 20:17:29 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -163,25 +163,29 @@ 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;
- uint64_t text;
- u_int i, j, k;
- u_char data[4];
+ const struct grid_cell *gc;
+ const struct grid_utf8 *gu;
+ char *buf, *s;
+ size_t off;
+ u_int i, j, k;
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++) {
- 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++) {
- if (data[k] == 0xff)
- break;
- buf[off++] = data[k];
+ gc = grid_view_peek_cell(wp->base.grid, i, j);
+ if (gc->flags & GRID_FLAG_UTF8) {
+ gu = grid_view_peek_utf8(wp->base.grid, i, j);
+ buf = xrealloc(buf, 1, off + 8);
+ for (k = 0; k < 8; k++) {
+ if (gu->data[k] == 0xff)
+ break;
+ buf[off++] = gu->data[k];
+ }
+ } else {
+ buf = xrealloc(buf, 1, off + 1);
+ buf[off++] = gc->data;
}
}
while (off > 0 && buf[off - 1] == ' ')