#include "zypp/Pathname.h"
#include "zypp/ByteCount.h" // for download progress reporting
+#include "zypp/base/String.h" // for toUpper()
#include "../zypper-main.h"
#include "AliveCursor.h"
PromptOptions::OptionList::const_iterator it;
if ((it = poptions.options().begin()) != poptions.options().end())
{
- //if (is_default) // TODO
- option_str += *it;
+ option_str += (poptions.defaultOpt() == 0 ? zypp::str::toUpper(*it) : *it);
++it;
}
- for (;
- it != poptions.options().end(); ++it)
- {
- string option = *it;
- //if (is_default) // TODO
- option_str += "/" + option;
- }
+ for (unsigned int i = 1; it != poptions.options().end(); ++it, i++)
+ option_str += "/" + (poptions.defaultOpt() == i ? zypp::str::toUpper(*it) : *it);
cout << CLEARLN << prompt << " [" << option_str << "]: " << std::flush;
}
// The answers should be lower case letters.
PromptOptions popts(_("#/s/r/c"), 3);
zypper.out().prompt(PROMPT_DEP_RESOLVE, stm.str(), popts);
+ //string reply = get_prompt_reply(promptstr, popts); \TODO
+
string reply_s = str::getline (cin, zypp::str::TRIM);
if (! cin.good()) {
if (reply_s == _("r"))
return true;
// translators: corresponds to (c)ancel
- else if (reply_s == _("c"))
+ else if (reply_s == _("c") || reply_s.empty())
return false;
// translators: corresponds to (s)kip
else if (reply_s == _("s"))
while (cin.good()) { // #269263
char c;
cin >> c;
+ MIL << "answer: " << c << endl;
c = tolower (c);
MIL << "answer: " << c << endl;
if (c == 'a')
return 1;
else if (c == 'i')
return 2;
+ else if (c == 0)
+ return default_action;
+
// translators: don't translate the letters
ostringstream s;
s << format(_("Invalid answer '%s'.")) % c << " "
istream & stm = cin;
- string c = "";
+ string c;
bool been_here_before = false;
- while (stm.good() && rpmatch(c.c_str()) == -1)
+ while (stm.good())
{
if (been_here_before)
{
out.prompt(pid, s.str(), popts); //! \todo remove this, handle invalid answers within the first prompt()
}
c = zypp::str::getline (stm, zypp::str::TRIM);
+ if (rpmatch(c.c_str()) >= 0 || c.empty())
+ break;
been_here_before = true;
}
MIL << "answer: " << c << endl;
- int answer = rpmatch(c.c_str());
+ int answer = c.empty() ? default_answer : rpmatch(c.c_str());
if (answer >= 0)
return answer;
else // in case of !stm.good()