[Aptitude-svn-commit] r3888 - in branches/aptitude-0.3/aptitude: . src

Daniel Burrows dburrows at costa.debian.org
Wed Aug 17 16:45:54 UTC 2005


Author: dburrows
Date: Wed Aug 17 16:45:51 2005
New Revision: 3888

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/solution_screen.cc
Log:
Use bolding to highlight package names in a story tree.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Wed Aug 17 16:45:51 2005
@@ -1,5 +1,9 @@
 2005-08-17  Daniel Burrows  <dburrows at debian.org>
 
+	* src/solution_screen.cc:
+
+	  Use the fragment subsystem to add text attributes to the story.
+
 	* src/defaults.cc, src/solution_screen.cc:
 
 	  Add support for switching between a 'solution' viewing mode and

Modified: branches/aptitude-0.3/aptitude/src/solution_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_screen.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/solution_screen.cc	Wed Aug 17 16:45:51 2005
@@ -27,6 +27,7 @@
 #include <generic/problemresolver/solution.h>
 #include <generic/util.h>
 
+ #include <vscreen/fragment.h>
 #include <vscreen/transcode.h>
 #include <vscreen/vs_multiplex.h>
 #include <vscreen/vs_staticitem.h>
@@ -388,60 +389,78 @@
 	++x;
       }
 
-    wstring s;
+    fragment *f = NULL;
 
     pkgCache::PkgIterator pkg = ver.get_package().get_pkg();
 
     switch(analyze_action(ver))
       {
       case action_remove:
-	s = swsprintf(transcode(_("Remove %s [%s (%s)]")).c_str(),
-		      pkg.Name(),
-		      pkg.CurrentVer().VerStr(),
-		      archives(pkg.CurrentVer()).c_str());
+	f = fragf(_("Remove %F [%s (%s)]"),
+		  text_fragment(pkg.Name(), style_attrs_on(A_BOLD)),
+		  pkg.CurrentVer().VerStr(),
+		  archives(pkg.CurrentVer()).c_str());
 	break;
 
       case action_install:
-	s = swsprintf(transcode(_("Install %s [%s (%s)]")).c_str(),
-		      pkg.Name(),
-		      ver.get_ver().VerStr(),
-		      archives(ver.get_ver()).c_str());
+	f = fragf(_("Install %F [%s (%s)]"),
+		  text_fragment(pkg.Name(), style_attrs_on(A_BOLD)),
+		  ver.get_ver().VerStr(),
+		  archives(ver.get_ver()).c_str());
 	break;
 
       case action_keep:
 	if(ver.get_ver().end())
-	  s = swsprintf(transcode(_("Cancel the installation of %s")).c_str(),
-			pkg.Name());
+	  f = fragf(_("Cancel the installation of %F"),
+		    text_fragment(pkg.Name(), style_attrs_on(A_BOLD)));
 	else
-	  s = swsprintf(transcode(_("Keep %s at version %s (%s)")).c_str(),
-			pkg.Name(), ver.get_ver().VerStr(),
-			archives(ver.get_ver()).c_str());
+	  f = fragf(_("Keep %F at version %s (%s)"),
+		    text_fragment(pkg.Name(), style_attrs_on(A_BOLD)),
+		    ver.get_ver().VerStr(),
+		    archives(ver.get_ver()).c_str());
 
 	break;
 
       case action_upgrade:
-	s = swsprintf(transcode(_("Upgrade %s [%s (%s) -> %s (%s)]")).c_str(),
-		      pkg.CurrentVer().VerStr(),
-		      archives(pkg.CurrentVer()).c_str(),
-		      ver.get_ver().VerStr(), archives(ver.get_ver()).c_str());
+	f = fragf(_("Upgrade %F [%s (%s) -> %s (%s)]"),
+		  text_fragment(pkg.Name(), style_attrs_on(A_BOLD)),
+		  pkg.CurrentVer().VerStr(),
+		  archives(pkg.CurrentVer()).c_str(),
+		  ver.get_ver().VerStr(), archives(ver.get_ver()).c_str());
 	break;
 
 
       case action_downgrade:
-	s = swsprintf(transcode(_("Downgrade %s [%s (%s) -> %s (%s)]")).c_str(),
-		      pkg.CurrentVer().VerStr(), archives(pkg.CurrentVer()).c_str(),
-		      ver.get_ver().VerStr(), archives(ver.get_ver()).c_str());
+	f = fragf(_("Downgrade %F [%s (%s) -> %s (%s)]"),
+		  text_fragment(pkg.Name(), style_attrs_on(A_BOLD)),
+		  pkg.CurrentVer().VerStr(), archives(pkg.CurrentVer()).c_str(),
+		  ver.get_ver().VerStr(), archives(ver.get_ver()).c_str());
 	break;
       }
 
-    wstring::const_iterator loc = s.begin();
-    while(loc != s.end() && x < width)
+    assert(f != NULL);
+
+    f = clipbox(f);
+    fragment_contents c = f->layout(width-x, width-x, st);
+    delete f;
+
+    assert(c.size() < 2);
+    if(c.size() > 0)
       {
-	win->add_wch(*loc);
-	x += wcwidth(*loc);
-	++loc;
+	const fragment_line &l = c.front();
+
+	fragment_line::const_iterator loc = l.begin();
+	while(loc != l.end() && x < width)
+	  {
+	    win->attrset(loc->attrs);
+	    win->add_wch(loc->ch);
+	    x += wcwidth(loc->ch);
+	    ++loc;
+	  }
       }
 
+    win->apply_style(st);
+
     while(x < width)
       {
 	win->addch(' ');



More information about the Aptitude-svn-commit mailing list