From: Kevin McCarthy Date: Tue, 27 Dec 2016 23:23:37 +0000 (-0800) Subject: Make to_chars and status_chars accept mulitibyte characters. (closes #3024) X-Git-Tag: neomutt-20170113~15^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8c86bb5305fe83ef4690fb85b71e6ae0516c5a43;p=neomutt Make to_chars and status_chars accept mulitibyte characters. (closes #3024) Change Tochars and StChars to use the mbchars_table type introduced in the last commit. --- diff --git a/globals.h b/globals.h index 6423e98be..d796dab02 100644 --- a/globals.h +++ b/globals.h @@ -159,10 +159,10 @@ WHERE short SslDHPrimeBits; WHERE char *SslCACertFile INITVAL (NULL); #endif #endif -WHERE char *StChars; +WHERE mbchar_table *StChars; WHERE char *Status; WHERE char *Tempdir; -WHERE char *Tochars; +WHERE mbchar_table *Tochars; WHERE char *TrashPath; WHERE char *TSStatusFormat; WHERE char *TSIconFormat; diff --git a/hdrline.c b/hdrline.c index 2e3ece7c5..b78e50d79 100644 --- a/hdrline.c +++ b/hdrline.c @@ -949,7 +949,7 @@ hdr_format_str (char *dest, case 'T': snprintf (fmt, sizeof (fmt), "%%%ss", prefix); snprintf (dest, destlen, fmt, - get_nth_wchar (Tochars, mutt_user_is_recipient (hdr))); + (Tochars && ((i = mutt_user_is_recipient (hdr))) < Tochars->len) ? Tochars->chars[i] : " "); break; case 'u': @@ -1017,7 +1017,7 @@ hdr_format_str (char *dest, hdr->deleted ? 'D' : (hdr->attach_del ? 'd' : ch), hdr->tagged ? "*" : (hdr->flagged ? "!" : - get_nth_wchar (Tochars, mutt_user_is_recipient (hdr)))); + (Tochars && ((i = mutt_user_is_recipient (hdr)) < Tochars->len) ? Tochars->chars[i] : " "))); colorlen = add_index_color (dest, destlen, flags, MT_COLOR_INDEX_FLAGS); mutt_format_s (dest + colorlen, destlen - colorlen, prefix, buf2); add_index_color (dest + colorlen, destlen - colorlen, flags, MT_COLOR_INDEX); diff --git a/init.h b/init.h index 6c39ac800..4f502418d 100644 --- a/init.h +++ b/init.h @@ -3794,7 +3794,7 @@ struct option_t MuttVars[] = { ** required.) */ #endif /* defined(USE_SSL) */ - { "status_chars", DT_STR, R_BOTH, UL &StChars, UL "-*%A" }, + { "status_chars", DT_MBCHARTBL, R_BOTH, UL &StChars, UL "-*%A" }, /* ** .pp ** Controls the characters used by the ``%r'' indicator in @@ -3978,7 +3978,7 @@ struct option_t MuttVars[] = { ** this variable is not set, the environment variable \fC$$$TMPDIR\fP is ** used. If \fC$$$TMPDIR\fP is not set then ``\fC/tmp\fP'' is used. */ - { "to_chars", DT_STR, R_BOTH, UL &Tochars, UL " +TCFL" }, + { "to_chars", DT_MBCHARTBL, R_BOTH, UL &Tochars, UL " +TCFL" }, /* ** .pp ** Controls the character used to indicate mail addressed to you. diff --git a/status.c b/status.c index 4d1533dc0..ab852b7e1 100644 --- a/status.c +++ b/status.c @@ -241,14 +241,12 @@ status_format_str (char *buf, size_t buflen, size_t col, int cols, char op, cons Context->deleted)) ? 1 : 0); } - if (!StChars) + if (!StChars || !StChars->len) buf[0] = 0; - else if (i >= mutt_strlen(StChars)) - buf[0] = StChars[0]; + else if (i >= StChars->len) + snprintf (buf, buflen, "%s", StChars->chars[0]); else - buf[0] = StChars[i]; - - buf[1] = 0; + snprintf (buf, buflen, "%s", StChars->chars[i]); break; }