/*
* Copyright (C) 1996-2000 Michael R. Elkins <me@cs.hmc.edu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
#include "mutt.h"
#include "mutt_curses.h"
#include "mutt_menu.h"
#include "mbyte.h"
#ifdef USE_IMAP
#include "imap.h"
#endif
#include <string.h>
#include <stdlib.h>
extern int Charset_is_utf8; /* FIXME: bad modularisation */
static void print_enriched_string (int attr, unsigned char *s, int do_color)
{
wchar_t wc;
size_t k;
size_t n = mutt_strlen ((char *)s);
mbstate_t mbstate;
memset (&mbstate, 0, sizeof (mbstate));
while (*s)
{
if (*s < M_TREE_MAX)
{
if (do_color)
SETCOLOR (MT_COLOR_TREE);
while (*s && *s < M_TREE_MAX)
{
switch (*s)
{
case M_TREE_LLCORNER:
if (option (OPTASCIICHARS))
addch ('`');
else if (Charset_is_utf8)
addstr ("\342\224\224"); /* WACS_LLCORNER */
else
addch (ACS_LLCORNER);
break;
case M_TREE_ULCORNER:
if (option (OPTASCIICHARS))
addch (',');
else if (Charset_is_utf8)
addstr ("\342\224\214"); /* WACS_ULCORNER */
else
addch (ACS_ULCORNER);
break;
case M_TREE_LTEE:
if (option (OPTASCIICHARS))
addch ('|');
else if (Charset_is_utf8)
addstr ("\342\224\234"); /* WACS_LTEE */
else
addch (ACS_LTEE);
break;
case M_TREE_HLINE:
if (option (OPTASCIICHARS))
addch ('-');
else if (Charset_is_utf8)
addstr ("\342\224\200"); /* WACS_HLINE */
else
addch (ACS_HLINE);
break;
case M_TREE_VLINE:
if (option (OPTASCIICHARS))
addch ('|');
else if (Charset_is_utf8)
addstr ("\342\224\202"); /* WACS_VLINE */
else
addch (ACS_VLINE);
break;
case M_TREE_TTEE:
if (option (OPTASCIICHARS))
addch ('-');
else if (Charset_is_utf8)
addstr ("\342\224\254"); /* WACS_TTEE */
else
addch (ACS_TTEE);
break;
case M_TREE_BTEE:
if (option (OPTASCIICHARS))
addch ('-');
else if (Charset_is_utf8)
addstr ("\342\224\264"); /* WACS_BTEE */
else
addch (ACS_BTEE);
break;
case M_TREE_SPACE:
addch (' ');
break;
case M_TREE_RARROW:
addch ('>');
break;
case M_TREE_STAR:
addch ('*'); /* fake thread indicator */
break;
case M_TREE_HIDDEN:
addch ('&');
break;
case M_TREE_EQUALS:
addch ('=');
break;
case M_TREE_MISSING:
addch ('?');
break;
}
s++, n--;
}
if (do_color) attrset(attr);
}
else if ((k = mbrtowc (&wc, (char *)s, n, &mbstate)) > 0)
{
addnstr ((char *)s, k);
s += k, n-= k;
}
else
break;
}
}
static void menu_make_entry (char *s, int l, MUTTMENU *menu, int i)
{
if (menu->dialog)
{
strncpy (s, menu->