From d9d5006b8e7ac2fe82830ac509271fac88a7c88f Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 20 Feb 2014 23:46:22 +0100 Subject: [PATCH] Enhance descriptions printed in info commands. --- src/info.cc | 3 +-- src/output/Out.h | 4 ++++ src/utils/richtext.cc | 8 ++++---- src/utils/richtext.h | 8 ++------ zypper.spec.cmake | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/info.cc b/src/info.cc index b850924..647ad56 100644 --- a/src/info.cc +++ b/src/info.cc @@ -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*/ ); } /** diff --git a/src/output/Out.h b/src/output/Out.h index ba529b2..188e191 100644 --- a/src/output/Out.h +++ b/src/output/Out.h @@ -17,6 +17,7 @@ #include #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. * diff --git a/src/utils/richtext.cc b/src/utils/richtext.cc index f4c9f61..45e04bf 100644 --- a/src/utils/richtext.cc +++ b/src/utils/richtext.cc @@ -68,7 +68,7 @@ void fillTagmap() _RTtagmap["center"] = CENTER; _RTtagmap["strong"] = BOLD; // same as necurses _RTtagmap["blockquote"] = BLOCKQUOTE; // same as necurses - + } string closeTag(vector& tagStack) @@ -115,7 +115,7 @@ string openTag(vector& 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 <<" "< #include -/** 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 diff --git a/zypper.spec.cmake b/zypper.spec.cmake index d4a0e8f..d7d7679 100644 --- a/zypper.spec.cmake +++ b/zypper.spec.cmake @@ -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} -- 2.7.4