From 23326e40cfe260bf7a30a99a653d8ec1ca5a625f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 24 Jun 2009 23:00:31 +0000 Subject: Now that a UTF-8-capable puts function exists, use it for printing strings in choice/more modes - lines with UTF-8 now display properly in find-window results. --- window-choose.c | 7 ++++--- window-more.c | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/window-choose.c b/window-choose.c index 5470a7e8..f199b847 100644 --- a/window-choose.c +++ b/window-choose.c @@ -285,10 +285,12 @@ window_choose_write_line( struct window_choose_mode_item *item; struct screen *s = &data->screen; struct grid_cell gc; + int utf8flag; if (data->callback == NULL) fatalx("called before callback assigned"); + utf8flag = options_get_number(&wp->window->options, "utf8"); memcpy(&gc, &grid_default_cell, sizeof gc); if (data->selected == data->top + py) { gc.fg = options_get_number(&wp->window->options, "mode-bg"); @@ -299,12 +301,11 @@ window_choose_write_line( screen_write_cursormove(ctx, 0, py); if (data->top + py < ARRAY_LENGTH(&data->list)) { item = &ARRAY_ITEM(&data->list, data->top + py); - screen_write_puts( - ctx, &gc, "%.*s", (int) screen_size_x(s), item->name); + screen_write_nputs( + ctx, screen_size_x(s) - 1, &gc, utf8flag, "%s", item->name); } while (s->cx < screen_size_x(s)) screen_write_putc(ctx, &gc, ' '); - } void diff --git a/window-more.c b/window-more.c index b09cc23c..721dac3d 100644 --- a/window-more.c +++ b/window-more.c @@ -175,7 +175,9 @@ window_more_write_line( struct grid_cell gc; char *msg, hdr[32]; size_t size; + int utf8flag; + utf8flag = options_get_number(&wp->window->options, "utf8"); memcpy(&gc, &grid_default_cell, sizeof gc); if (py == 0) { @@ -193,8 +195,8 @@ window_more_write_line( screen_write_cursormove(ctx, 0, py); if (data->top + py < ARRAY_LENGTH(&data->list)) { msg = ARRAY_ITEM(&data->list, data->top + py); - screen_write_puts( - ctx, &gc, "%.*s", (int) (screen_size_x(s) - size), msg); + screen_write_nputs( + ctx, screen_size_x(s) - 1 - size, &gc, utf8flag, "%s", msg); } while (s->cx < screen_size_x(s) - size) screen_write_putc(ctx, &gc, ' '); -- cgit