19 #include <zypp-tui/Application> 28 {
return Application::instance().out().termwidth(); }
36 std::string
TermLine::get(
unsigned width_r, SplitFlags flags_r,
char exp_r )
const 44 unsigned llen = l.
size();
45 unsigned rlen = r.size();
46 int diff = width_r - llen - rlen;
53 if ( ! ( flags_r.testFlag(
SF_EXPAND ) && ::isatty(STDOUT_FILENO) ) )
56 if ( percentHint < 0 || percentHint > 100 )
70 return zypp::str::Str() << l << std::string( pc,
'.' ) << std::string( diff-pc,
'=' ) << r;
74 pc = pc > tag.size() ? (diff - tag.size()) *
percentHint / 100 : 0;
75 return zypp::str::Str() << l << std::string( pc,
'.' ) << tag << std::string( diff-pc-tag.size(),
'=' ) << r;
86 else if ( flags_r.testFlag(
SF_SPLIT ) )
93 return out <<
"\n" << ( rlen > width_r ? r.substr( 0, width_r ) : std::string( width_r - rlen,
' ' ) + r );
124 std::cout << table_r;
130 static const std::string
done {
_(
"done") };
146 if ( ! (
_msg.empty() &&
_hint.empty() ) )
150 return app_r.exitCode();
157 msg_r = combine( ex_r );
162 msg_r += combine( ex_r );
164 return std::move(msg_r);
167 {
return Application::instance().out().zyppExceptionReport( ex_r ); }
virtual std::string zyppExceptionReport(const zypp::Exception &e)
Return a Exception as a string suitable for output.
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.
size_type size() const
utf8 size
static constexpr unsigned termwidthUnlimited
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.
Verbosity verbosity() const
Get current verbosity.
const std::ostream & stream() const
CCString< ColorContext::MSG_WARNING > MSG_WARNINGString
string substr(size_type pos_r=0, size_type len_r=npos) const
utf8 substring
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
static constexpr Type TYPE_ALL
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Default output verbosity level.
zypp::DefaultIntegral< int,-1 > percentHint
CCString< ColorContext::MSG_ERROR > MSG_ERRORString
ProgressEnd
ProgressBars default end tags.
std::string get() const
Return plain line made of lhs + rhs.
unsigned defaultTermwidth()
virtual bool progressFilter()
Determine whether to show progress.
static constexpr Type TYPE_NONE
Base class for Exception.
int report(Application &app_r) const
Default way of processing a caught Error exception.
virtual void searchResult(const Table &table_r)
Print out a search result.
static std::string combine(std::string &&msg_r, const zypp::Exception &ex_r)
virtual void error(const std::string &problem_desc, const std::string &hint="")=0
Show an error message and an optional hint.
Class representing an application (appdata.xml)
static constexpr int ZTUI_EXIT_OK
const std::string & str() const