[Aptitude-devel] r3210 - in branches/aptitude-0.3/aptitude: . src/cmdline

Daniel Burrows dburrows@costa.debian.org
Sat, 30 Apr 2005 20:47:13 +0000


Author: dburrows
Date: Sat Apr 30 20:47:05 2005
New Revision: 3210

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/cmdline/cmdline_prompt.cc
Log:
Use fragments to format the help text for the main prompt too.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Apr 30 20:47:05 2005
@@ -1,5 +1,10 @@
 2005-04-30  Daniel Burrows  <dburrows@debian.org>
 
+	* src/cmdline/cmdline_prompt.cc:
+
+	  Display the prompt help using fragments, so it gets properly
+	  flowed.
+
 	* src/cmdline/cmdline_resolver.cc:
 
 	  Remove an unneeded flowbox, make indentation work correctly

Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_prompt.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_prompt.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_prompt.cc	Sat Apr 30 20:47:05 2005
@@ -16,6 +16,7 @@
 #include <generic/apt.h>
 #include <generic/infer_reason.h>
 
+#include <vscreen/fragment.h>
 #include <vscreen/vscreen.h>
 
 #include <apt-pkg/algorithms.h>
@@ -549,6 +550,76 @@
   prompt_string(_("Press Return to continue"));
 }
 
+static inline fragment *flowindentbox(int i1, int irest, fragment *f)
+{
+  return indentbox(i1, irest, flowbox(f));
+}
+
+static void prompt_help(ostream &out)
+{
+  fragment *f=indentbox(2, 2,
+			fragf(_("y: %F"
+				"n: %F"
+				"i: %F"
+				"c: %F"
+				"d: %F"
+				"s: %F"
+				"v: %F"
+				"e: %F"
+				"%n"
+				"%F"
+				"%n"
+				"%F"
+				"%F"
+				"%F"
+				"%F"
+				"%F"
+				"%F"
+				"%F"
+				"%F"),
+			      flowindentbox(0, 3,
+					    fragf(_("continue with the installation"))),
+			      flowindentbox(0, 3,
+					    fragf(_("abort and quit"))),
+			      flowindentbox(0, 3,
+					    fragf(_("show information about one or more packages; the package names should follow the 'i'"))),
+			      flowindentbox(0, 3,
+					    fragf(_("show the Debian changelogs of one or more packages; the package names should follow the 'c'"))),
+			      flowindentbox(0, 3,
+					    fragf(_("toggle the display of dependency information"))),
+			      flowindentbox(0, 3,
+					    fragf(_("toggle the display of changes in package sizes"))),
+			      flowindentbox(0, 3,
+					    fragf(_("toggle the display of version numbers"))),
+			      flowindentbox(0, 3,
+					    fragf(_("enter the full visual interface"))),
+			      flowbox(fragf(_("You may also specify modifaction to the actions which will be taken.  To do so, type an action character followed by one or more package names (or patterns).  The action will be applied to all the packages that you list.  The following actions are available:"))),
+			      // FIXME: copied from
+			      // cmdline_resolver.cc, maybe this
+			      // should be placed in a common file?
+			      flowindentbox(0, 4,
+					    fragf(_("'+' to install packages"))),
+			      flowindentbox(0, 5,
+					    fragf(_("'+M' to install packages and immediately flag them as automatically installed"))),
+			      flowindentbox(0, 4,
+					    fragf(_("'-' to remove packages"))),
+			      flowindentbox(0, 4,
+					    fragf(_("'_' to purge packages"))),
+			      flowindentbox(0, 4,
+					    fragf(_("'=' to place packages on hold"))),
+			      flowindentbox(0, 4,
+					    fragf(_("':' to keep packages in their current state without placing them on hold"))),
+			      flowindentbox(0, 4,
+					    fragf(_("'&M' to mark packages as automatically installed"))),
+			      flowindentbox(0, 4,
+					    fragf(_("'&m' to mark packages as manually installed")))));
+
+  out << _("Commands:") << endl;
+  update_screen_width();
+  out << f->layout(screen_width, screen_width);
+  delete f;
+}
+
 bool cmdline_do_prompt(bool as_upgrade,
 		       pkgset &to_install,
 		       pkgset &to_hold,
@@ -657,33 +728,7 @@
 		  ui_preview();
 		case '?':
 		  valid_response=false;
-		  // TODO: use fragments instead.
-		  printf(_("Commands:\n"
-			   "  y: continue with the installation\n"
-			   "  n: abort and quit\n"
-			   "  i: show information about one or more packages;\n"
-			   "     the package names should follow 'i'\n"
-			   "  c: show the Debian changelogs of one or more packages;\n"
-			   "     the package names should follow 'c'\n"
-			   "  d: toggle display of dependency information\n"
-			   "  s: toggle display of changes in package sizes\n"
-			   "  v: toggle display of versions\n"
-			   "  e: enter the full visual interface\n"
-			   "\n"
-			   "  You may also specify modifications to the set of package actions.\n"
-			   "  To do so, type an action character followed by one or more package names\n"
-			   "or patterns.  The action will be applied to all packages. (you may specify\n"
-			   "additional actions; each will be applied to all packages that follow it)\n"
-			   "\n"
-			   "Actions:\n"
-			   "  '+'  : Install\n"
-			   "  '+M' : Install + mark Auto \n"
-			   "  '-'  : Remove\n"
-			   "  '_'  : Purge\n"
-			   "  '='  : Hold\n"
-			   "  ':'  : Keep\n"
-			   "  '&M  : Mark Auto\n"
-			   "  '&m  : Un-mark Auto\n"));
+		  prompt_help(cout);
 		  break;
 		default:
 		  printf(_("Invalid response.  Please enter a valid command or '?' for help.\n"));