ref: refs/heads/master
commit 0704255d5fa3f1e51be6492284bef29d8afc9fae
Author: Ján Kupec
Date: Tue Mar 17 12:20:45 2009 +0100
Show the default option in dialog in parentheses.
Instead of capitalization (which is a problem for most languages),
or colorization, the default option (used on enter or in
non-interactive mode) will be shown in parentheses after the list
of options).
---
src/output/OutNormal.cc | 4 +-
src/utils/prompt.cc | 53 ++++++++++++++--------------------------------
2 files changed, 18 insertions(+), 39 deletions(-)
diff --git a/src/output/OutNormal.cc b/src/output/OutNormal.cc
index 84b1fb2..7468ddd 100644
--- a/src/output/OutNormal.cc
+++ b/src/output/OutNormal.cc
@@ -291,7 +291,7 @@ void OutNormal::prompt(PromptId id,
cout << startdesc << endl;
cout << prompt;
if (!poptions.empty())
- cout << " [" << (_use_colors ? poptions.optionStringColored() : poptions.optionString()) << "]";
+ cout << " " << poptions.optionString();
cout << ": " << std::flush;
}
@@ -318,5 +318,5 @@ void OutNormal::promptHelp(const PromptOptions & poptions)
}
}
- cout << endl << "[" << (_use_colors ? poptions.optionStringColored() : poptions.optionString()) << "]: " << std::flush;
+ cout << endl << poptions.optionString() << ": " << std::flush;
}
diff --git a/src/utils/prompt.cc b/src/utils/prompt.cc
index 622e732..961b4ab 100644
--- a/src/utils/prompt.cc
+++ b/src/utils/prompt.cc
@@ -63,56 +63,35 @@ const string PromptOptions::optionString() const
StrVector::const_iterator it;
unsigned int shown_count = _shown_count < 0 ? options().size() : _shown_count;
- if ((it = options().begin()) != options().end() && shown_count > 0)
+ if ((it = options().begin()) != options().end() && shown_count)
{
- if (defaultOpt() == 0)
- option_str << "_" << *it << "_";
- else
- option_str << *it;
+ option_str << "[";
+ fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_OPTION);
+ // fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_SHORTHAND);
++it;
}
for (unsigned int i = 1; it != options().end() && i < shown_count; ++it, ++i)
if (isEnabled(i))
{
option_str << "/";
- if (defaultOpt() == i)
- option_str << "_" << *it << "_";
- else
- option_str << *it;
+ fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_OPTION);
+ //fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_SHORTHAND);
}
if (!_opt_help.empty())
- option_str << (shown_count > 0 ? "/" : "") << "?";
-
- return option_str.str();
-}
-
-const string PromptOptions::optionStringColored() const
-{
- ostringstream option_str;
- StrVector::const_iterator it;
- unsigned int shown_count = _shown_count < 0 ? options().size() : _shown_count;
-
- if ((it = options().begin()) != options().end() && shown_count > 0)
{
- if (defaultOpt() == 0)
- fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_SHORTHAND);
- else
- fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_OPTION);
- ++it;
+ if (shown_count)
+ option_str << "/";
+ fprint_color(option_str, "?", COLOR_CONTEXT_PROMPT_OPTION);
}
- for (unsigned int i = 1; it != options().end() && i < shown_count; ++it, ++i)
- if (isEnabled(i))
- {
- fprint_color(option_str, "/", COLOR_CONTEXT_PROMPT_OPTION);
- if (defaultOpt() == i)
- fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_SHORTHAND);
- else
- fprint_color(option_str, *it, COLOR_CONTEXT_PROMPT_OPTION);
- }
- if (!_opt_help.empty())
- fprint_color(option_str, shown_count > 0 ? "/?" : "?", COLOR_CONTEXT_PROMPT_OPTION);
+ if (!_options.empty() && shown_count)
+ option_str << "]";
+
+ // default option
+ option_str << " (";
+ fprint_color(option_str, _options[_default], COLOR_CONTEXT_PROMPT_OPTION);
+ option_str << ")";
return option_str.str();
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org