1 fix-utf8-status-padding-bug
3 Ensure that multibyte UTF8 characters are counted correctly when
4 calculating and displaying the caption and hardstatus lines.
6 Based on an earlier version by Kees Cook <address@hidden>
8 Signed-off-by: Dustin Kirkland <address@hidden>
10 === modified file 'src/display.c'
11 Index: screen/display.c
12 ===================================================================
13 --- screen.orig/display.c 2012-03-20 22:15:02.000000000 +0100
14 +++ screen/display.c 2012-03-20 22:41:28.000000000 +0100
17 int chars = strlen_onscreen((unsigned char *)(s + start), (unsigned char *)(s + max));
19 - PutWinMsg(s, start, max);
20 + PutWinMsg(s, start, max + ((max - start) - chars)); /* Multibyte count */
22 D_x -= (max - chars); /* Yak! But this is necessary to count for
23 the fact that not every byte represents a
24 @@ -2249,11 +2249,15 @@
30 + int extrabytes = strlen(hstatusstring) - strlen_onscreen(hstatusstring, NULL);
35 if (D_status == STATUS_ON_HS)
37 - buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP, &D_hstatusev, 0);
38 + buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP + extrabytes, &D_hstatusev, 0);
42 @@ -2348,8 +2352,13 @@
44 if (y == cv->c_ye + 1 && from >= cv->c_xs && from <= cv->c_xe)
47 + int extrabytes = strlen(captionstring) - strlen_onscreen(captionstring, NULL);
51 p = Layer2Window(cv->c_layer);
52 - buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP), &cv->c_captev, 0);
53 + buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP) + extrabytes, &cv->c_captev, 0);
54 if (cv->c_captev.timeout.tv_sec)
56 xx = to > cv->c_xe ? cv->c_xe : to;
58 SetRendition(&mchar_so);
59 if (l > xx - cv->c_xs + 1)
60 l = xx - cv->c_xs + 1;
61 - l = PrePutWinMsg(buf, from - cv->c_xs, l);
62 + l = PrePutWinMsg(buf, from - cv->c_xs, l + extrabytes);
64 for (; from <= xx; from++)