libzypp
17.34.1
|
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'")); ...
More...
#include <zypp-tui/output/promptoptions.h>
Public Types | |
using | StrVector = std::vector< std::string > |
Public Member Functions | |
PromptOptions () | |
Default c-tor. More... | |
PromptOptions (StrVector options_r, unsigned defaultOpt_r) | |
Ctor taking the option values as vector. More... | |
PromptOptions (const std::string &optionstr_r, unsigned defaultOpt_r) | |
Constructor. More... | |
~PromptOptions () | |
D-tor. More... | |
const StrVector & | options () const |
void | setOptions (StrVector options_r, unsigned defaultOpt_r) |
void | setOptions (const std::string &optionstr_r, unsigned defaultOpt_r) |
unsigned | defaultOpt () const |
ColorString | optionString () const |
Option string (may have embedded color codes) More... | |
bool | empty () const |
bool | isYesNoPrompt () const |
const std::string & | optionHelp (unsigned opt) const |
void | setOptionHelp (unsigned opt, const std::string &help_str) |
bool | helpEmpty () const |
bool | isEnabled (unsigned opt) const |
bool | isDisabled (unsigned opt) const |
void | disable (unsigned opt) |
void | enable (unsigned opt) |
void | enableAll () |
unsigned | shownCount () const |
void | setShownCount (unsigned count) |
std::vector< int > | getReplyMatches (const std::string &reply_r) const |
Return the indices of option string matches (lowercase/prefix or #NUM). More... | |
std::string | replyMatchesStr (const std::vector< int > &matches_r) const |
The returned reply matches as '(,)' list. More... | |
Private Attributes | |
StrVector | _options |
option strings More... | |
unsigned | _default = 0 |
index of the default option More... | |
StrVector | _opt_help |
help strings corresponding to options More... | |
std::set< unsigned > | _disabled |
set of options to ignore More... | |
int | _shown_count = -1 |
Number of options to show (the rest will still be available and visible through '?' help). More... | |
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);
Definition at line 38 of file promptoptions.h.
using ztui::PromptOptions::StrVector = std::vector<std::string> |
Definition at line 41 of file promptoptions.h.
|
inline |
Default c-tor.
Definition at line 46 of file promptoptions.h.
ztui::PromptOptions::PromptOptions | ( | StrVector | options_r, |
unsigned | defaultOpt_r | ||
) |
Ctor taking the option values as vector.
Definition at line 20 of file promptoptions.cc.
ztui::PromptOptions::PromptOptions | ( | const std::string & | optionstr_r, |
unsigned | defaultOpt_r | ||
) |
Constructor.
optionstr_r | translated option string containing one or more options separated by slash '/' character e.g. "yes/no/?" or "1/s/r/c" |
defaultOpt_r | index of the default answer within the option_str |
Definition at line 23 of file promptoptions.cc.
ztui::PromptOptions::~PromptOptions | ( | ) |
D-tor.
Definition at line 28 of file promptoptions.cc.
|
inline |
Definition at line 64 of file promptoptions.h.
void ztui::PromptOptions::setOptions | ( | StrVector | options_r, |
unsigned | defaultOpt_r | ||
) |
Definition at line 33 of file promptoptions.cc.
void ztui::PromptOptions::setOptions | ( | const std::string & | optionstr_r, |
unsigned | defaultOpt_r | ||
) |
Definition at line 45 of file promptoptions.cc.
|
inline |
Definition at line 68 of file promptoptions.h.
ColorString ztui::PromptOptions::optionString | ( | ) | const |
Option string (may have embedded color codes)
Definition at line 52 of file promptoptions.cc.
|
inline |
Definition at line 71 of file promptoptions.h.
bool ztui::PromptOptions::isYesNoPrompt | ( | ) | const |
Definition at line 193 of file promptoptions.cc.
|
inline |
Definition at line 74 of file promptoptions.h.
void ztui::PromptOptions::setOptionHelp | ( | unsigned | opt, |
const std::string & | help_str | ||
) |
Definition at line 97 of file promptoptions.cc.
|
inline |
Definition at line 78 of file promptoptions.h.
|
inline |
Definition at line 80 of file promptoptions.h.
|
inline |
Definition at line 82 of file promptoptions.h.
|
inline |
Definition at line 84 of file promptoptions.h.
|
inline |
Definition at line 86 of file promptoptions.h.
|
inline |
Definition at line 88 of file promptoptions.h.
|
inline |
Definition at line 91 of file promptoptions.h.
|
inline |
Definition at line 93 of file promptoptions.h.
std::vector< int > ztui::PromptOptions::getReplyMatches | ( | const std::string & | reply_r | ) | const |
Return the indices of option string matches (lowercase/prefix or #NUM).
Definition at line 117 of file promptoptions.cc.
std::string ztui::PromptOptions::replyMatchesStr | ( | const std::vector< int > & | matches_r | ) | const |
The returned reply matches as '(,)' list.
Definition at line 181 of file promptoptions.cc.
|
private |
option strings
Definition at line 103 of file promptoptions.h.
|
private |
index of the default option
Definition at line 105 of file promptoptions.h.
|
private |
help strings corresponding to options
Definition at line 107 of file promptoptions.h.
|
private |
set of options to ignore
Definition at line 109 of file promptoptions.h.
|
private |
Number of options to show (the rest will still be available and visible through '?' help).
If negative, all options will be shown. Zero is allowed.
Definition at line 114 of file promptoptions.h.