Example #1
0
void GPG::Key::getDescription(std::vector<std::string> &descrArray,
			      size_t width)
{
	std::string keyDescr=longname;

	do
	{
		std::vector<unicode_char> unicode_buf;

		size_t p=keyDescr.find('\n');

		if (p == std::string::npos)
		{
			unicode::iconvert::convert(keyDescr,
						unicode_default_chset(),
						unicode_buf);
			keyDescr="";
		}
		else
		{
			unicode::iconvert::convert(keyDescr.substr(0, p),
						unicode_default_chset(),
						unicode_buf);
			keyDescr=keyDescr.substr(p+1);
		}

		std::vector< std::vector<unicode_char> > wrapped_text;

		std::back_insert_iterator<std::vector< std::vector
						       <unicode_char> > >
			insert_iter(wrapped_text);

		unicodewordwrap(unicode_buf.begin(),
				unicode_buf.end(),
				unicoderewrapnone(),
				insert_iter,
				width,
				true);

		for (std::vector< std::vector<unicode_char> >::const_iterator
			     b(wrapped_text.begin()),
			     e(wrapped_text.end()); b != e; ++b)
		{
			descrArray.push_back(unicode::iconvert
					     ::convert(*b,
						       unicode_default_chset())
					     );
		}
	} while (keyDescr.size() > 0);
}
Example #2
0
void CursesMultilineLabel::init()
{
	int w=getWidth();

	if (w < 10)
		w=10;

	lines.clear();

	std::back_insert_iterator< std::vector< std::vector<unicode_char> > >
		insert_iter(lines);

	unicodewordwrap(text.begin(), text.end(),
			unicoderewrapnone(), insert_iter, w, true);
}