Sadrul Habib Chowdhury <ima...@gmail.com> wrote: > I would make some change screen.c:pad_expand, for example:
Actually, upon further consideration and testing, the changes to screen.c and externalizing of the function are unnecessary. I think all of the multibyte counting can be fixed in display.c alone... > This fixes the amount of padding for me. However, it's still buggy, > because I lose the last two digits (the minute part) of the last %c. > Perhaps you guys would be willing to take a look at that? :-) If not, > I hope I will get to it ... apologies for the delay in reviewing the > patch and general lack of activity, but new job/location etc. eat up a > lot of time :-( .. Things should improve in a couple of weeks, I > think, though! Aha! I think I found and solved the remaining issues. Okay, how about the attached patch? This is working for my previous test case described at the top of this thread, as well as all of the other tests I could throw at it. Does it work for you too? What do you think? Cheers, -- :-Dustin
fix-utf8-status-padding-bug Ensure that multibyte UTF8 characters are counted correctly when calculating and displaying the caption and hardstatus lines. Based on an earlier version by Kees Cook <k...@ubuntu.com> Signed-off-by: Dustin Kirkland <kirkl...@ubuntu.com> === modified file 'src/display.c' --- src/display.c 2010-05-11 02:52:51 +0000 +++ src/display.c 2011-01-20 21:00:56 +0000 @@ -2157,7 +2157,7 @@ { int chars = strlen_onscreen(s + start, s + max); D_encoding = 0; - PutWinMsg(s, start, max); + PutWinMsg(s, start, max + ((max - start) - chars)); /* Multibyte count */ D_encoding = UTF8; D_x -= (max - chars); /* Yak! But this is necessary to count for the fact that not every byte represents a @@ -2251,11 +2251,15 @@ RefreshHStatus() { char *buf; - +#ifdef UTF8 + int extrabytes = strlen(hstatusstring) - strlen_onscreen(hstatusstring, NULL); +#else + int extrabytes = 0; +#endif evdeq(&D_hstatusev); if (D_status == STATUS_ON_HS) return; - buf = MakeWinMsgEv(hstatusstring, D_fore, '%', (D_HS && D_has_hstatus == HSTATUS_HS && D_WS > 0) ? D_WS : D_width - !D_CLP, &D_hstatusev, 0); + 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); if (buf && *buf) { ShowHStatus(buf); @@ -2350,8 +2354,13 @@ { if (y == cv->c_ye + 1 && from >= cv->c_xs && from <= cv->c_xe) { +#ifdef UTF8 + int extrabytes = strlen(captionstring) - strlen_onscreen(captionstring, NULL); +#else + int extrabytes = 0; +#endif p = Layer2Window(cv->c_layer); - buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP), &cv->c_captev, 0); + buf = MakeWinMsgEv(captionstring, p, '%', cv->c_xe - cv->c_xs + (cv->c_xe + 1 < D_width || D_CLP) + extrabytes, &cv->c_captev, 0); if (cv->c_captev.timeout.tv_sec) evenq(&cv->c_captev); xx = to > cv->c_xe ? cv->c_xe : to; @@ -2360,7 +2369,7 @@ SetRendition(&mchar_so); if (l > xx - cv->c_xs + 1) l = xx - cv->c_xs + 1; - l = PrePutWinMsg(buf, from - cv->c_xs, l); + l = PrePutWinMsg(buf, from - cv->c_xs, l + extrabytes); from = cv->c_xs + l; for (; from <= xx; from++) PUTCHARLP(' ');