Show the default option in dialog in parentheses.
authorJán Kupec <jkupec@suse.cz>
Tue, 17 Mar 2009 11:20:45 +0000 (12:20 +0100)
committerJán Kupec <jkupec@suse.cz>
Tue, 17 Mar 2009 11:20:45 +0000 (12:20 +0100)
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
src/utils/prompt.cc

index 84b1fb2..7468ddd 100644 (file)
@@ -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;
 }
index 622e732..961b4ab 100644 (file)
@@ -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();
 }