* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "mutt.h"
#include "mutt_menu.h"
#include "mutt_curses.h"
return (ret);
}
-int _mutt_get_field_att (/* const */ char *field, char *buf, size_t buflen, int complete, int multiple, char ***files, int *numfiles)
-{
- int ret;
- int x, y;
-
- ENTER_STATE *es = mutt_new_enter_state();
-
- do
- {
- CLEARLINE (LINES-1);
- addstr (field);
- mutt_refresh ();
- getyx (stdscr, y, x);
- ret = _mutt_enter_string_att (buf, buflen, y, x, complete, multiple, files, numfiles, es);
- }
- while (ret == 1);
- CLEARLINE (LINES-1);
- mutt_free_enter_state (&es);
-
- return (ret);
-}
-
-
int mutt_get_password (char *msg, char *buf, size_t buflen)
{
int rc;
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);
void mutt_curses_error (const char *fmt, ...)
{
+ char TmpErrorbuf[STRING];
va_list ap;
va_start (ap, fmt);
va_end (ap);
dprint (1, (debugfile, "%s\n", Errorbuf));
- mutt_format_string (Errorbuf, sizeof (Errorbuf),
+ mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */
if (!option (OPTKEEPQUIET))
{
void mutt_curses_message (const char *fmt, ...)
{
+ char TmpErrorbuf[STRING];
va_list ap;
va_start (ap, fmt);
vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap);
va_end (ap);
- mutt_format_string (Errorbuf, sizeof (Errorbuf),
+ mutt_format_string (TmpErrorbuf, sizeof (TmpErrorbuf),
0, COLS-2, 0, 0, Errorbuf, sizeof (Errorbuf), 0);
+ snprintf(Errorbuf,sizeof(Errorbuf),"%s",TmpErrorbuf); /* overkill */
if (!option (OPTKEEPQUIET))
{
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)
void mutt_paddstr (int n, const char *s)
{
+ wchar_t wc;
+ int w;
+ size_t k;
size_t len = mutt_strlen (s);
+ mbstate_t mbstate;
- for (; len && *s; s += 1, len -= 1)
+ memset (&mbstate, 0, sizeof (mbstate));
+ for (; len && (k = mbrtowc (&wc, s, len, &mbstate)); s += k, len -= k)
{
- if (1 > n)
- break;
- addnstr ((char *)s, 1);
- n -= 1;
+ if (k == (size_t)(-1) || k == (size_t)(-2))
+ {
+ k = (k == (size_t)(-1)) ? 1 : len;
+ wc = replacement_char ();
+ }
+ if (!IsWPrint (wc))
+ wc = '?';
+ w = wcwidth (wc);
+ if (w >= 0)
+ {
+ if (w > n)
+ break;
+ addnstr ((char *)s, k);
+ n -= w;
+ }
}
while (n-- > 0)
addch (' ');
/*
* mutt_strwidth is like mutt_strlen except that it returns the width
* refering to the number of characters cells.
- * AK: since we remove all that multibyte-character-stuff, it is equal to mutt_strlen
*/
int mutt_strwidth (const char *s)
{
- return mutt_strlen(s);
+ wchar_t wc;
+ int w;
+ size_t k, n;
+ mbstate_t mbstate;
+
+ if (!s) return 0;
+
+ n = mutt_strlen (s);
+
+ memset (&mbstate, 0, sizeof (mbstate));
+ for (w=0; n && (k = mbrtowc (&wc, s, n, &mbstate)); s += k, n -= k)
+ {
+ if (k == (size_t)(-1) || k == (size_t)(-2))
+ {
+ k = (k == (size_t)(-1)) ? 1 : n;
+ wc = replacement_char ();
+ }
+ if (!IsWPrint (wc))
+ wc = '?';
+ w += wcwidth (wc);
+ }
+ return w;
}