19 #include <zypp-tui/Application> 39 {
return Application::instance().out().termwidth(); }
47 std::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) ) )
67 if ( percentHint < 0 || percentHint > 100 )
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();
168 msg_r = combine( ex_r );
173 msg_r += combine( ex_r );
175 return std::move(msg_r);
178 {
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.
Colored string if do_colors.
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
ColorString tagError()
translated "Error:" error color
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.
const char * qContinue()
translated "Continue?"
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
ColorString tagNote()
translated "Note:" highlighted
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)
CCString< ColorContext::HIGHLIGHT > HIGHLIGHTString
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
ColorString tagWarning()
translated "Warning:" warning color
const std::string & str() const