ui.hpp revision 4a53e3c2b83c476a93148eaee0272649beb221ca
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// Automated Testing Framework (atf)
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// Copyright (c) 2007 The NetBSD Foundation, Inc.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// All rights reserved.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// Redistribution and use in source and binary forms, with or without
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// modification, are permitted provided that the following conditions
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// are met:
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// 1. Redistributions of source code must retain the above copyright
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// notice, this list of conditions and the following disclaimer.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// 2. Redistributions in binary form must reproduce the above copyright
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// notice, this list of conditions and the following disclaimer in the
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// documentation and/or other materials provided with the distribution.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt#if !defined(TOOLS_UI_HPP)
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt#define TOOLS_UI_HPP
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt#include <string>
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Huntnamespace tools {
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Huntnamespace ui {
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! \brief Formats an error message to fit on screen.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! Given the program's name and an error message, properly formats it to
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! fit on screen.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! The program's name is not stored globally to prevent the usage of this
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! function from inside the library. Making it a explicit parameter
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! restricts its usage to the frontend.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Huntstd::string format_error(const std::string&, const std::string&);
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//! \brief Formats an informational message to fit on screen.
b66b333f59cf51ef87f973084a5023acd9317fb2Evan Hunt//!
//! Given the program's name and an informational message, properly formats
//! it to fit on screen.
//!
//! The program's name is not stored globally to prevent the usage of this
//! function from inside the library. Making it a explicit parameter
//! restricts its usage to the frontend.
//!
std::string format_info(const std::string&, const std::string&);
//!
//! \brief Formats a block of text to fit nicely on screen.
//!
//! Given a text, which is composed of multiple paragraphs separated by
//! a single '\n' character, reformats it to fill on the current screen's
//! width with proper line wrapping.
//!
//! This is just a special case of format_text_with_tag, provided for
//! simplicity.
//!
std::string format_text(const std::string&);
//!
//! \brief Formats a block of text to fit nicely on screen, prepending a
//! tag to it.
//!
//! Given a text, which is composed of multiple paragraphs separated by
//! a single '\n' character, reformats it to fill on the current screen's
//! width with proper line wrapping. The text is prepended with a tag;
//! i.e. a word that is printed at the beginning of the first paragraph and
//! optionally repeated at the beginning of each word. The last parameter
//! specifies the column on which the text should start, and that position
//! must be greater than the tag's length or 0, in which case it
//! automatically takes the correct value.
//!
std::string format_text_with_tag(const std::string&, const std::string&,
bool, size_t = 0);
//!
//! \brief Formats a warning message to fit on screen.
//!
//! Given the program's name and a warning message, properly formats it to
//! fit on screen.
//!
//! The program's name is not stored globally to prevent the usage of this
//! function from inside the library. Making it a explicit parameter
//! restricts its usage to the frontend.
//!
std::string format_warning(const std::string&, const std::string&);
} // namespace ui
} // namespace tools
#endif // !defined(TOOLS_UI_HPP)