libzypp 17.37.10

ztui Namespace Reference

## Namespaces
namespace | ansi
namespace | csidetail
namespace | ctcdetail
namespace | env
namespace | mbs
namespace | out
namespace | table
namespace | text
namespace | utf8

## Classes
class | AliveCursor
class | Application
struct | CCString
class | ColorStream
| Colored stream output if do_colors. More...
class | ColorString
| Colored string if do_colors. More...
class | Config
class | Out
| Base class for producing common (for now) zypper output. More...
class | OutNormal
class | PromptOptions
| Example: `PromptOptions popts; popts.setOptions(_("y/n/p"), 0 / * default reply * /); popts.setOptionHelp(0, _("Help for option 'y'")); popts.setOptionHelp(1, _("Help for option 'n'")); ... zypper.out().prompt(PROMPT_YN_INST_REMOVE_CONTINUE, prompt_text, popts); unsigned reply = get_prompt_reply(zypper, PROMPT_YN_INST_REMOVE_CONTINUE, popts);` More...
class | PropertyTable
| Aligned key/value with multiline support Key : value 1 LongKey : value 2 Multiline : line 1 line 2 Next Key : value 3. More...
class | Table
class | TableHeader
class | TableRow
struct | TermLine

## Typedefs
using | SolvableCSI = std::pair<zypp::sat::Solvable, zypp::ui::Selectable::picklist_size_type>
| Custom sort index type for table rows representing solvables (like detailed search results).
using | DEFAULTString = CCString<ColorContext::DEFAULT>
using | MSG_STATUSString = CCString<ColorContext::MSG_STATUS>
using | MSG_ERRORString = CCString<ColorContext::MSG_ERROR>
using | MSG_WARNINGString = CCString<ColorContext::MSG_WARNING>
using | POSITIVEString = CCString<ColorContext::POSITIVE>
using | CHANGEString = CCString<ColorContext::CHANGE>
using | NEGATIVEString = CCString<ColorContext::NEGATIVE>
using | HIGHLIGHTString = CCString<ColorContext::HIGHLIGHT>
using | LOWLIGHTString = CCString<ColorContext::LOWLIGHT>

## Enumerations
enum class | ProgressEnd { done , attention , error }
| ProgressBars default end tags. More...
enum | TableLineStyle { Ascii = 0 , Light , Heavy , Double , Light3 , Heavy3 , LightHeavy , LightDouble , HeavyLight , DoubleLight , Colon , none , TLS_End }
| table drawing style More...
enum class | ColorContext { DEFAULT , RESULT , MSG_STATUS , MSG_ERROR , MSG_WARNING , PROMPT , PROMPT_OPTION , POSITIVE , CHANGE , NEGATIVE , HIGHLIGHT , LOWLIGHT , OSDEBUG }
enum | tags { PARAGRAPH , PRE , BLOCKQUOTE , BOLD , UNDERLINED , ANCHOR , HEADER1 , HEADER2 , HEADER3 , BREAK_LINE , EM , ITALIC , HR , LI , OL , UL , TT , QT , BIG , CODE , CENTER , UNKNOWN }

## Functions
| ZYPP_DECLARE_OPERATORS_FOR_FLAGS (TermLine::SplitFlags)
| ZYPP_DECLARE_OPERATORS_FOR_FLAGS (Out::Type)
std::ostream & | PROGRESS_FLUSH (std::ostream &str)
const char * | asYesNo (bool val_r)
template<class Tif_, class Telse_>
auto | ColumnIf (bool condition_r, Tif_ &&if_r, Telse_ &&else_r) -> ctcdetail::ColumnIf< decltype(if_r()), decltype(else_r())>
| Conditional Table column factory.
template<class Tif_>
auto | ColumnIf (bool condition_r, Tif_ &&if_r) -> ctcdetail::ColumnIf< decltype(if_r()), decltype(if_r())>
template<class Tp_>
TableRow && | operator<< (TableRow &&tr, Tp_ &&val)
template<class Tif_, class Telse_>
TableRow & | operator<< (TableRow &tr, const ctcdetail::ColumnIf< Tif_, Telse_ > &val)
template<class Tif_, class Telse_>
TableRow & | operator<< (TableRow &tr, ctcdetail::ColumnIf< Tif_, Telse_ > &val)
template<class Tif_, class Telse_>
TableRow & | operator<< (TableRow &tr, ctcdetail::ColumnIf< Tif_, Telse_ > &&val)
template<class Tif_>
TableRow & | operator<< (TableRow &tr, const ctcdetail::ColumnIf< Tif_, Tif_ > &val)
template<class Tif_>
TableRow & | operator<< (TableRow &tr, ctcdetail::ColumnIf< Tif_, Tif_ > &val)
template<class Tif_>
TableRow & | operator<< (TableRow &tr, ctcdetail::ColumnIf< Tif_, Tif_ > &&val)
template<class Tp_>
TableHeader && | operator<< (TableHeader &&th, Tp_ &&val)
Table & | operator<< (Table &table, TableRow tr)
Table & | operator<< (Table &table, TableHeader tr)
std::ostream & | operator<< (std::ostream &stream, const Table &table)
bool | do_ttyout ()
| True unless output is a dumb tty or file.
bool | do_colors ()
| If output is done in colors (depends on config)
bool | mayUseANSIEscapes ()
| Simple check whether stdout is a (not dumb) tty.
bool | hasANSIColor ()
| Simple check whether stdout can handle colors.
ansi::ColorStream | operator<< (ansi::Color color_r, std::ostream &(*omanip)(std::ostream &))
template<class CCC_, typename = ansi::EnableIfCustomColorCtor<CCC_>>
ansi::ColorStream | operator<< (CCC_ &&color_r, std::ostream &(*omanip)(std::ostream &))
ansi::Color | customColorCtor (ColorContext ctxt_r)
template<ColorContext _ctxt>
ansi::ColorStream & | operator<< (ansi::ColorStream &cstr_r, const CCString< _ctxt > &cstring_r)
std::string | readline_getline ()
| Use readline to get line of input.
unsigned | get_screen_width ()
| Reads COLUMNS environment variable or gets the screen width from readline, in that order.
void | clear_keyboard_buffer ()
| Clear the keyboard buffer.
void | fillTagmap ()
std::string | closeTag (std::vector< tags > &tagStack)
std::string | openTag (std::vector< tags > &tagStack, std::string &tag)
void | fillAmpersmap ()
std::string | getStringFromAmpr (const std::string &str)
std::string | processRichText (const std::string &text)
std::ostream & | printRichText (std::ostream &str, std::string text, unsigned indent_r=0U, unsigned width_r=0U)
| Print [Rich]Text optionally indented.
std::string | printRichText (std::string text, unsigned indent_r=0U, unsigned width_r=0U)
| Return [Rich]Text optionally indented as string.
std::string | mbs_substr_by_width (boost::string_ref text_r, std::string::size_type colpos_r=0, std::string::size_type collen_r=std::string::npos)
| Returns a substring of a multi-byte character string text_r starting at screen column cpos_r and being at most clen_r columns wide.
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.
void | mbs_write_wrapped (std::ostream &out, const zypp::str::Str &text_r, size_t indent_r, size_t wrap_r, int indentFix_r=0)
size_t | mbs_width (boost::string_ref text_r)
| Returns the column width of a multi-byte character string text_r.
template<class Tp_>
TableRow & | operator<< (TableRow &tr, Tp_ &&val)
| Add colummn.
template<class Tp_>
TableHeader & | operator<< (TableHeader &th, Tp_ &&val)
| Add column.

## Variables
static constexpr int | ZTUI_EXIT_OK = 0
static const char * | lines [][3]
std::map< std::string, tags > | _rtTagmap
bool | pre
bool | ordered
unsigned | count_list_items
std::map< std::string, std::string > | ampersmap

## Typedef Documentation

## ◆ SolvableCSI

using ztui::SolvableCSI = std::pair<zypp::sat::Solvable, zypp::ui::Selectable::picklist_size_type>

Custom sort index type for table rows representing solvables (like detailed search results).

> _("Yes") or _("No")

Definition at line 40 of file Table.h.

## ◆ DEFAULTString

using ztui::DEFAULTString = CCString<ColorContext::DEFAULT>

Definition at line 77 of file colors.h.

## ◆ MSG_STATUSString

using ztui::MSG_STATUSString = CCString<ColorContext::MSG_STATUS>

Definition at line 79 of file colors.h.

## ◆ MSG_ERRORString

using ztui::MSG_ERRORString = CCString<ColorContext::MSG_ERROR>

Definition at line 80 of file colors.h.

## ◆ MSG_WARNINGString

using ztui::MSG_WARNINGString = CCString<ColorContext::MSG_WARNING>

Definition at line 81 of file colors.h.

## ◆ POSITIVEString

using ztui::POSITIVEString = CCString<ColorContext::POSITIVE>

Definition at line 83 of file colors.h.

## ◆ CHANGEString

using ztui::CHANGEString = CCString<ColorContext::CHANGE>

Definition at line 84 of file colors.h.

## ◆ NEGATIVEString

using ztui::NEGATIVEString = CCString<ColorContext::NEGATIVE>

Definition at line 85 of file colors.h.

## ◆ HIGHLIGHTString

using ztui::HIGHLIGHTString = CCString<ColorContext::HIGHLIGHT>

Definition at line 87 of file colors.h.

## ◆ LOWLIGHTString

using ztui::LOWLIGHTString = CCString<ColorContext::LOWLIGHT>

Definition at line 88 of file colors.h.

## Enumeration Type Documentation

## ◆ ProgressEnd

enum class ztui::ProgressEnd
| strong

ProgressBars default end tags.

Enumerator
done |
attention |
error |

Definition at line 45 of file Out.h.

## ◆ TableLineStyle

enum ztui::TableLineStyle

table drawing style

Enumerator
Ascii | | - +
Light |
Heavy |
Double |
Light3 |
Heavy3 |
LightHeavy |
LightDouble |
HeavyLight |
DoubleLight |
Colon |
none |
TLS_End | sentinel

Definition at line 80 of file Table.h.

## ◆ ColorContext

enum class ztui::ColorContext
| strong

Enumerator
DEFAULT |
RESULT |
MSG_STATUS |
MSG_ERROR |
MSG_WARNING |
PROMPT |
PROMPT_OPTION |
POSITIVE |
CHANGE |
NEGATIVE |
HIGHLIGHT |
LOWLIGHT |
OSDEBUG |

Definition at line 34 of file colors.h.

## ◆ tags

enum ztui::tags

Enumerator
PARAGRAPH |
PRE |
BLOCKQUOTE |
BOLD |
UNDERLINED |
ANCHOR |
HEADER1 |
HEADER2 |
HEADER3 |
BREAK_LINE |
EM |
ITALIC |
HR |
LI |
OL |
UL |
TT |
QT |
BIG |
CODE |
CENTER |
UNKNOWN |

Definition at line 26 of file richtext.cc.

## Function Documentation

## ◆ ZYPP_DECLARE_OPERATORS_FOR_FLAGS() [1/2]

ztui::ZYPP_DECLARE_OPERATORS_FOR_FLAGS | ( | TermLine::SplitFlags |  | ) |

## ◆ ZYPP_DECLARE_OPERATORS_FOR_FLAGS() [2/2]

ztui::ZYPP_DECLARE_OPERATORS_FOR_FLAGS | ( | Out::Type |  | ) |

## ◆ PROGRESS_FLUSH()

std::ostream & ztui::PROGRESS_FLUSH | ( | std::ostream & | str | ) |
| inline

Definition at line 122 of file OutNormal.cc.

## ◆ asYesNo()

const char * ztui::asYesNo | ( | bool | val_r | ) |

Definition at line 32 of file Table.cc.

## ◆ ColumnIf() [1/2]

template<class Tif_, class Telse_>

auto ztui::ColumnIf | ( | bool | condition_r,
|  | Tif_ && | if_r,
|  | Telse_ && | else_r ) -> ctcdetail::ColumnIf<decltype(if_r()),decltype(else_r())>

Conditional Table column factory.

Creates an conditional TableRow or TableHeader entry, depending on the value of condition_r. The columns content, if needed, is determined calling the function object matching the condition.

An empty function object will cause the column to be hidden and no content will be retrieved (see overloaded operator<<(TableRow &,..)).

TableRow()
<< "first"
<< ColumnIf( condition, [](){ return "second"; }, [](){ return "one but last"; } )
<< "last";
ztui::TableRow
Definition Table.h:167
ztui::ColumnIf
auto ColumnIf(bool condition_r, Tif_ &&if_r, Telse_ &&else_r) -> ctcdetail::ColumnIf< decltype(if_r()), decltype(else_r())>
Conditional Table column factory.
Definition Table.h:141

Definition at line 141 of file Table.h.

## ◆ ColumnIf() [2/2]

template<class Tif_>

auto ztui::ColumnIf | ( | bool | condition_r,
|  | Tif_ && | if_r ) -> ctcdetail::ColumnIf<decltype(if_r()),decltype(if_r())>

Definition at line 145 of file Table.h.

## ◆ operator<<() [1/16]

template<class Tp_>

TableRow && ztui::operator<< | ( | TableRow && | tr,
|  | Tp_ && | val )

Definition at line 257 of file Table.h.

## ◆ operator<<() [2/16]

template<class Tif_, class Telse_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | const ctcdetail::ColumnIf< Tif_, Telse_ > & | val )

Definition at line 261 of file Table.h.

## ◆ operator<<() [3/16]

template<class Tif_, class Telse_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | ctcdetail::ColumnIf< Tif_, Telse_ > & | val )

Definition at line 264 of file Table.h.

## ◆ operator<<() [4/16]

template<class Tif_, class Telse_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | ctcdetail::ColumnIf< Tif_, Telse_ > && | val )

Definition at line 267 of file Table.h.

## ◆ operator<<() [5/16]

template<class Tif_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | const ctcdetail::ColumnIf< Tif_, Tif_ > & | val )

Definition at line 271 of file Table.h.

## ◆ operator<<() [6/16]

template<class Tif_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | ctcdetail::ColumnIf< Tif_, Tif_ > & | val )

Definition at line 274 of file Table.h.

## ◆ operator<<() [7/16]

template<class Tif_>

TableRow & ztui::operator<< | ( | TableRow & | tr,
|  | ctcdetail::ColumnIf< Tif_, Tif_ > && | val )

Definition at line 277 of file Table.h.

## ◆ operator<<() [8/16]

template<class Tp_>

TableHeader && ztui::operator<< | ( | TableHeader && | th,
|  | Tp_ && | val )

Definition at line 318 of file Table.h.

## ◆ operator<<() [9/16]

Table & ztui::operator<< | ( | Table & | table,
|  | TableRow | tr )
| inline

Definition at line 511 of file Table.h.

## ◆ operator<<() [10/16]

Table & ztui::operator<< | ( | Table & | table,
|  | TableHeader | tr )
| inline

Definition at line 514 of file Table.h.

## ◆ operator<<() [11/16]

std::ostream & ztui::operator<< | ( | std::ostream & | stream,
|  | const Table & | table )
| inline

Definition at line 518 of file Table.h.

## ◆ do_ttyout()

bool ztui::do_ttyout | ( |  | ) |

True unless output is a dumb tty or file.

In this case we should not use any ANSI Escape sequences moving the cursor.

Definition at line 27 of file colors.cc.

## ◆ do_colors()

bool ztui::do_colors | ( |  | ) |

If output is done in colors (depends on config)

Definition at line 32 of file colors.cc.

## ◆ mayUseANSIEscapes()

bool ztui::mayUseANSIEscapes | ( |  | ) |

Simple check whether stdout is a (not dumb) tty.

Definition at line 37 of file colors.cc.

## ◆ hasANSIColor()

bool ztui::hasANSIColor | ( |  | ) |

Simple check whether stdout can handle colors.

Definition at line 53 of file colors.cc.

## ◆ operator<<() [12/16]

ansi::ColorStream ztui::operator<< | ( | ansi::Color | color_r,
|  | std::ostream &(* | omanip )(std::ostream &) )
| inline

Definition at line 839 of file ansi.h.

## ◆ operator<<() [13/16]

template<class CCC_, typename = ansi::EnableIfCustomColorCtor<CCC_>>

ansi::ColorStream ztui::operator<< | ( | CCC_ && | color_r,
|  | std::ostream &(* | omanip )(std::ostream &) )
| inline

Definition at line 848 of file ansi.h.

## ◆ customColorCtor()

ansi::Color ztui::customColorCtor | ( | ColorContext | ctxt_r | ) |

Definition at line 125 of file colors.cc.

## ◆ operator<<() [14/16]

template<ColorContext _ctxt>

ansi::ColorStream & ztui::operator<< | ( | ansi::ColorStream & | cstr_r,
|  | const CCString< _ctxt > & | cstring_r )
| inline

Definition at line 74 of file colors.h.

## ◆ readline_getline()

std::string ztui::readline_getline | ( |  | ) |

Use readline to get line of input.

Definition at line 26 of file console.cc.

## ◆ get_screen_width()

unsigned ztui::get_screen_width | ( |  | ) |

Reads COLUMNS environment variable or gets the screen width from readline, in that order.

Falls back to 80 if all that fails.

\NOTE In case stdout is not connected to a terminal max. unsigned is returned. This should prevent clipping when output is redirected.

Definition at line 48 of file console.cc.

## ◆ clear_keyboard_buffer()

void ztui::clear_keyboard_buffer | ( |  | ) |

Clear the keyboard buffer.

Useful before showing the user prompt message to catch any unwanted <enter> key hits (bnc #649248).

\NOTE This will not clear characters typed after the last

Definition at line 74 of file console.cc.

## ◆ fillTagmap()

void ztui::fillTagmap | ( |  | ) |

Definition at line 58 of file richtext.cc.

## ◆ closeTag()

std::string ztui::closeTag | ( | std::vector< tags > & | tagStack | ) |

Definition at line 89 of file richtext.cc.

## ◆ openTag()

std::string ztui::openTag | ( | std::vector< tags > & | tagStack,
|  | std::string & | tag )

Definition at line 111 of file richtext.cc.

## ◆ fillAmpersmap()

void ztui::fillAmpersmap | ( |  | ) |

Definition at line 166 of file richtext.cc.

## ◆ getStringFromAmpr()

std::string ztui::getStringFromAmpr | ( | const std::string & | str | ) |

Definition at line 176 of file richtext.cc.

## ◆ processRichText()

std::string ztui::processRichText | ( | const std::string & | text | ) |

Definition at line 205 of file richtext.cc.

## ◆ printRichText() [1/2]

std::ostream & ztui::printRichText | ( | std::ostream & | str,
|  | std::string | text,
|  | unsigned | indent_r = 0U,
|  | unsigned | width_r = 0U )
| inline

Print [Rich]Text optionally indented.

Richtext is introduced by a '' or '

'(bsc#935885) tag.

Definition at line 26 of file richtext.h.

## ◆ printRichText() [2/2]

std::string ztui::printRichText | ( | std::string | text,
|  | unsigned | indent_r = 0U,
|  | unsigned | width_r = 0U )
| inline

Return [Rich]Text optionally indented as string.

Definition at line 41 of file richtext.h.

## ◆ mbs_substr_by_width()

std::string ztui::mbs_substr_by_width | ( | boost::string_ref | text_r,
|  | std::string::size_type | colpos_r = 0,
|  | std::string::size_type | collen_r = std::string::npos )

Returns a substring of a multi-byte character string text_r starting at screen column cpos_r and being at most clen_r columns wide.

The string is ' ' padded if multicolumn characters are clipped at start or end.

Definition at line 16 of file text.cc.

## ◆ mbs_write_wrapped() [1/2]

void ztui::mbs_write_wrapped | ( | std::ostream & | out,
|  | boost::string_ref | text_r,
|  | size_t | indent_r,
|  | size_t | wrap_r,
|  | int | indentFix_r = 0 )
| inline

Wrap and indent given text and write it to the output stream out.

TODO

- delete whitespace at the end of lines
- keep one-letter words with the next

Parameters

  out | output stream to write to
  test | text to wrap
  indent | number of columns by which to indent the whole text
  wrap | number of columns the text should be wrapped into
  indentFix | additional indent/outdent for the first line (default: `0`)

Definition at line 631 of file text.h.

## ◆ mbs_write_wrapped() [2/2]

void ztui::mbs_write_wrapped | ( | std::ostream & | out,
|  | const zypp::str::Str & | text_r,
|  | size_t | indent_r,
|  | size_t | wrap_r,
|  | int | indentFix_r = 0 )
| inline

Definition at line 637 of file text.h.

## ◆ mbs_width()

size_t ztui::mbs_width | ( | boost::string_ref | text_r | ) |
| inline

Returns the column width of a multi-byte character string text_r.

Definition at line 641 of file text.h.

## Variable Documentation

## ◆ ZTUI_EXIT_OK

int ztui::ZTUI_EXIT_OK = 0
| static constexpr

Definition at line 24 of file application.h.

## ◆ lines

const char* ztui::lines[][3]
| static

Initial value:
= {
{ "|", "-", "+"},
{ "\xE2\x94\x82", "\xE2\x94\x80", "\xE2\x94\xBC" },
{ "\xE2\x94\x83", "\xE2\x94\x81", "\xE2\x95\x8B" },
{ "\xE2\x95\x91", "\xE2\x95\x90", "\xE2\x95\xAC" },
{ "\xE2\x94\x86", "\xE2\x94\x84", "\xE2\x94\xBC" },
{ "\xE2\x94\x87", "\xE2\x94\x85", "\xE2\x94\x8B" },
{ "\xE2\x94\x82", "\xE2\x94\x81", "\xE2\x94\xBF" },
{ "\xE2\x94\x82", "\xE2\x95\x90", "\xE2\x95\xAA" },
{ "\xE2\x94\x83", "\xE2\x94\x80", "\xE2\x95\x82" },
{ "\xE2\x95\x91", "\xE2\x94\x80", "\xE2\x95\xAB" },
{ ":", "-", "+" },
}

Definition at line 36 of file Table.cc.

## ◆ _rtTagmap

std::map<std::string,tags> ztui::_rtTagmap

Definition at line 52 of file richtext.cc.

## ◆ pre

bool ztui::pre

Definition at line 54 of file richtext.cc.

## ◆ ordered

bool ztui::ordered

Definition at line 55 of file richtext.cc.

## ◆ count_list_items

unsigned ztui::count_list_items

Definition at line 56 of file richtext.cc.

## ◆ ampersmap

std::map<std::string,std::string> ztui::ampersmap

Definition at line 164 of file richtext.cc.