X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=curs_lib.c;h=6601ce8744856085b8c2ee91e6e270f2bb77ab1f;hp=fcf17b6fbdde4652429e365b5e620cd0575bb3b0;hb=0d83646490348c9730d62ee47ad9c8c0e6461a62;hpb=99e6bcfa05e57212a4d7d010510dc2663bc1eb8c diff --git a/curs_lib.c b/curs_lib.c index fcf17b6..6601ce8 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -284,7 +284,7 @@ void mutt_query_exit (void) curs_set (1); if (Timeout) timeout (-1); /* restore blocking operation */ - if (mutt_yesorno (_("Exit Mutt?"), M_YES) == M_YES) + if (mutt_yesorno (_("Exit Mutt-ng?"), M_YES) == M_YES) { endwin (); exit (1); @@ -594,23 +594,41 @@ void mutt_format_string (char *dest, size_t destlen, int arboreal) { char *p; + wchar_t wc; int w; size_t k, k2; char scratch[MB_LEN_MAX]; + mbstate_t mbstate1, mbstate2; + memset(&mbstate1, 0, sizeof (mbstate1)); + memset(&mbstate2, 0, sizeof (mbstate2)); --destlen; p = dest; - for (; n; s+=1, n-=1) + for (; n && (k = mbrtowc (&wc, s, n, &mbstate1)); s += k, n -= k) { - w = 1; - k2 = 1; - if (w > max_width) + if (k == (size_t)(-1) || k == (size_t)(-2)) + { + k = (k == (size_t)(-1)) ? 1 : n; + wc = replacement_char (); + } + if (arboreal && wc < M_TREE_MAX) + w = 1; /* hack */ + else + { + if (!IsWPrint (wc)) + wc = '?'; + w = wcwidth (wc); + } + if (w >= 0) + { + if (w > max_width || (k2 = wcrtomb (scratch, wc, &mbstate2)) > destlen) break; - min_width -= w; - max_width -= w; - strncpy (p, s, k2); - p += k2; - destlen -= k2; + min_width -= w; + max_width -= w; + strncpy (p, scratch, k2); + p += k2; + destlen -= k2; + } } w = (int)destlen < min_width ? destlen : min_width; if (w <= 0) @@ -709,7 +727,7 @@ void mutt_paddstr (int n, const char *s) { if (w > n) break; - addnstr ((char *)s, 1); + addnstr ((char *)s, k); n -= w; } }