Enhance descriptions printed in info commands.
authorMichael Andres <ma@suse.de>
Thu, 20 Feb 2014 22:46:22 +0000 (23:46 +0100)
committerMichael Andres <ma@suse.de>
Thu, 20 Feb 2014 22:46:22 +0000 (23:46 +0100)
src/info.cc
src/output/Out.h
src/utils/richtext.cc
src/utils/richtext.h
zypper.spec.cmake

index b850924..647ad56 100644 (file)
@@ -22,7 +22,6 @@
 #include "main.h"
 //#include "misc.h"
 #include "Table.h"
-#include "utils/richtext.h"
 #include "utils/misc.h" // for kind_to_string_localized and string_patch_status
 #include "utils/text.h"
 #include "search.h"
@@ -84,7 +83,7 @@ void printSummaryDesc(const ResObject::constPtr & res)
 {
   cout << _("Summary: ") << res->summary() << endl;
   cout << _("Description: ") << endl;
-  printRichText( cout, res->description(), 2/*indented*/ );
+  Zypper::instance()->out().printRichText( res->description(), 2/*indented*/ );
 }
 
 /**
index ba529b2..188e191 100644 (file)
@@ -17,6 +17,7 @@
 #include <zypp/ProgressData.h>
 
 #include "utils/prompt.h"
+#include "utils/richtext.h"
 #include "output/prompt.h"
 
 using namespace zypp;
@@ -425,6 +426,9 @@ public:
   /** NORMAL: An empty line */
   void gap() { if ( type() == TYPE_NORMAL ) std::cout << std::endl; }
 
+  void printRichText( std::string text, unsigned indent_r = 0U )
+  { ::printRichText( std::cout, text, indent_r, termwidth() ); }
+
   /**
    * Show an info message.
    *
index f4c9f61..45e04bf 100644 (file)
@@ -68,7 +68,7 @@ void fillTagmap()
   _RTtagmap["center"] = CENTER;
   _RTtagmap["strong"] = BOLD; // same as necurses
   _RTtagmap["blockquote"] = BLOCKQUOTE; // same as necurses
-  
+
 }
 
 string closeTag(vector<tags>& tagStack)
@@ -115,7 +115,7 @@ string openTag(vector<tags>& tagStack, string& tag)
     case HR:
       tagStack.pop_back(); //hr haven't closing tag
       return "--------------------";
-    
+
     case PARAGRAPH:
       return "";
     case BREAK_LINE:
@@ -182,7 +182,7 @@ string getStringFromAmpr(const string& str)
       return "";
     }
   }
-  
+
   DBG << end <<" "<<str.substr(0,end) << endl;
   return ampersmap[str.substr(0,end)];
 
@@ -233,7 +233,7 @@ std::string processRichText(const std::string& text)
           if(tagEndPos==text.npos)
           {
             WAR << "ended with non-closed tag " << endl;
-            return res; 
+            return res;
           }
           string tagname = text.substr(pos+1,tagEndPos-pos-1);
           pos = tagEndPos;
index 7784e0d..622289d 100644 (file)
@@ -4,11 +4,8 @@
 #include <iosfwd>
 #include <zypp/base/String.h>
 
-/** Convert . */
-//std::string processRichText( const std::string& text );
-
 /** Print [Rich]Text optionally indented. */
-inline std::ostream & printRichText( std::ostream & str, std::string text, unsigned indent_r = 0U )
+inline std::ostream & printRichText( std::ostream & str, std::string text, unsigned indent_r = 0U, unsigned width_r = 0U )
 {
   std::string processRichText( const std::string& text );
 
@@ -18,9 +15,8 @@ inline std::ostream & printRichText( std::ostream & str, std::string text, unsig
   if ( text.find("DT:Rich") != std::string::npos )
     text = processRichText( text );
 
-  return str::printIndented( str, text, indent_r );    // even unindented as it also asaerts a trailing '/n'
+  return zypp::str::printIndented( str, text, indent_r, width_r );     // even unindented as it also asserts a trailing '/n'
 }
 
-
 #endif
 
index d4a0e8f..d7d7679 100644 (file)
@@ -22,7 +22,7 @@ BuildRequires:  boost-devel >= 1.33.1
 BuildRequires:  cmake >= 2.4.6
 BuildRequires:  gcc-c++ >= 4.7
 BuildRequires:  gettext-devel >= 0.15
-BuildRequires:  libzypp-devel >= 14.14.0
+BuildRequires:  libzypp-devel >= 14.15.0
 BuildRequires:  readline-devel >= 5.1
 Requires:       procps
 %if 0%{?suse_version}