Author: jkupec Date: Fri Mar 14 12:50:53 2008 New Revision: 9155 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9155&view=rev Log: - use default answers to prompts on enter Modified: trunk/zypper/src/output/OutNormal.cc trunk/zypper/src/zypper-misc.cc trunk/zypper/src/zypper-prompt.cc Modified: trunk/zypper/src/output/OutNormal.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/output/OutNormal.cc?rev=9155&r1=9154&r2=9155&view=diff ============================================================================== --- trunk/zypper/src/output/OutNormal.cc (original) +++ trunk/zypper/src/output/OutNormal.cc Fri Mar 14 12:50:53 2008 @@ -3,6 +3,7 @@ #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" @@ -202,17 +203,11 @@ 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; } Modified: trunk/zypper/src/zypper-misc.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-misc.cc?rev=9155&r1=9154&r2=9155&view=diff ============================================================================== --- trunk/zypper/src/zypper-misc.cc (original) +++ trunk/zypper/src/zypper-misc.cc Fri Mar 14 12:50:53 2008 @@ -497,6 +497,8 @@ // 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()) { @@ -510,7 +512,7 @@ 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")) Modified: trunk/zypper/src/zypper-prompt.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-prompt.cc?rev=9155&r1=9154&r2=9155&view=diff ============================================================================== --- trunk/zypper/src/zypper-prompt.cc (original) +++ trunk/zypper/src/zypper-prompt.cc Fri Mar 14 12:50:53 2008 @@ -68,6 +68,7 @@ while (cin.good()) { // #269263 char c; cin >> c; + MIL << "answer: " << c << endl; c = tolower (c); MIL << "answer: " << c << endl; if (c == 'a') @@ -76,6 +77,9 @@ 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 << " " @@ -111,9 +115,9 @@ 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) { @@ -126,11 +130,13 @@ 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() -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org