19#include <zypp-tui/Application>
47std::string
TermLine::get(
unsigned width_r, SplitFlags flags_r,
char exp_r )
const
55 unsigned llen = l.
size();
56 unsigned rlen = r.
size();
57 int diff = width_r - llen - rlen;
64 if ( ! ( flags_r.testFlag(
SF_EXPAND ) && ::isatty(STDOUT_FILENO) ) )
81 return zypp::str::Str() << l << std::string( pc,
'.' ) << std::string( diff-pc,
'=' ) << r;
85 pc = pc > tag.size() ? (diff - tag.size()) *
percentHint / 100 : 0;
86 return zypp::str::Str() << l << std::string( pc,
'.' ) << tag << std::string( diff-pc-tag.size(),
'=' ) << r;
97 else if ( flags_r.testFlag(
SF_SPLIT ) )
100 if ( llen > width_r )
104 return out <<
"\n" << ( rlen > width_r ? r.
substr( 0, width_r ) : std::string( width_r - rlen,
' ' ) + r );
135 std::cout << table_r;
141 static const std::string
done {
_(
"done") };
157 if ( ! (
_msg.empty() &&
_hint.empty() ) )
161 return app_r.exitCode();
175 return std::move(msg_r);
static Application & instance()
Verbosity verbosity() const
Get current verbosity.
static constexpr Type TYPE_ALL
@ NORMAL
Default output verbosity level.
static constexpr Type TYPE_NONE
virtual bool progressFilter()
Determine whether to show progress.
virtual void error(const std::string &problem_desc, const std::string &hint="")=0
Show an error message and an optional hint.
virtual void searchResult(const Table &table_r)
Print out a search result.
virtual std::string zyppExceptionReport(const zypp::Exception &e)
Return a Exception as a string suitable for output.
virtual void progressEnd(const std::string &id, const std::string &label, const std::string &donetag, bool error=false)=0
End of an operation with reported progress.
Colored string if do_colors.
std::string str() const
Return the colored string if do_colors.
string substr(size_type pos_r=0, size_type len_r=npos) const
utf8 substring
const std::string & str() const
size_type size() const
utf8 size
Class representing an application (appdata.xml)
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
static constexpr unsigned termwidthUnlimited
unsigned defaultTermwidth()
ColorString tagWarning()
translated "Warning:" warning color
ColorString tagNote()
translated "Note:" highlighted
const char * qContinue()
translated "Continue?"
ColorString tagError()
translated "Error:" error color
CCString< ColorContext::MSG_ERROR > MSG_ERRORString
CCString< ColorContext::MSG_WARNING > MSG_WARNINGString
CCString< ColorContext::HIGHLIGHT > HIGHLIGHTString
static constexpr int ZTUI_EXIT_OK
void mbs_write_wrapped(std::ostream &out, boost::string_ref text_r, size_t indent_r, size_t wrap_r, int indentFix_r=0)
Wrap and indent given text and write it to the output stream out.
ProgressEnd
ProgressBars default end tags.
static std::string combine(std::string &&msg_r, const zypp::Exception &ex_r)
int report(Application &app_r) const
Default way of processing a caught Error exception.
zypp::DefaultIntegral< int,-1 > percentHint
std::string get() const
Return plain line made of lhs + rhs.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...