summaryrefslogtreecommitdiffstats
path: root/apt-private/private-output.h
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-output.h')
-rw-r--r--apt-private/private-output.h46
1 files changed, 34 insertions, 12 deletions
diff --git a/apt-private/private-output.h b/apt-private/private-output.h
index c3e73d5..4cc7c01 100644
--- a/apt-private/private-output.h
+++ b/apt-private/private-output.h
@@ -10,6 +10,7 @@
#include <functional>
#include <iostream>
#include <string>
+#include <vector>
// forward declaration
class pkgCacheFile;
@@ -35,16 +36,24 @@ void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,
APT_PUBLIC void ShowBroken(std::ostream &out, CacheFile &Cache, bool const Now);
APT_PUBLIC void ShowBroken(std::ostream &out, pkgCacheFile &Cache, bool const Now);
+APT_PUBLIC void ShowWithColumns(std::ostream &out, const std::vector<std::string> &List, size_t Indent, size_t ScreenWidth);
+
template<class Container, class PredicateC, class DisplayP, class DisplayV> bool ShowList(std::ostream &out, std::string const &Title,
Container const &cont,
PredicateC Predicate,
DisplayP PkgDisplay,
- DisplayV VerboseDisplay)
+ DisplayV VerboseDisplay,
+ std::string colorName = "APT::Color::Neutral")
{
size_t const ScreenWidth = (::ScreenWidth > 3) ? ::ScreenWidth - 3 : 0;
int ScreenUsed = 0;
bool const ShowVersions = _config->FindB("APT::Get::Show-Versions", false);
+ bool const ListColumns = _config->FindB("APT::Get::List-Columns", _config->FindI("APT::Output-Version") >= 30);
bool printedTitle = false;
+ std::vector<std::string> PackageList;
+
+ auto setColor = _config->FindI("APT::Output-Version") >= 30 ? _config->Find(colorName) : "";
+ auto resetColor = _config->FindI("APT::Output-Version") >= 30 ? _config->Find("APT::Color::Neutral") : "";
for (auto const &Pkg: cont)
{
@@ -59,7 +68,7 @@ template<class Container, class PredicateC, class DisplayP, class DisplayV> bool
if (ShowVersions == true)
{
- out << std::endl << " " << PkgDisplay(Pkg);
+ out << std::endl << " " << setColor << PkgDisplay(Pkg) << resetColor;
std::string const verbose = VerboseDisplay(Pkg);
if (verbose.empty() == false)
out << " (" << verbose << ")";
@@ -67,24 +76,37 @@ template<class Container, class PredicateC, class DisplayP, class DisplayV> bool
else
{
std::string const PkgName = PkgDisplay(Pkg);
- if (ScreenUsed == 0 || (ScreenUsed + PkgName.length()) >= ScreenWidth)
+ if (ListColumns)
+ PackageList.push_back(PkgName);
+ else
{
- out << std::endl << " ";
- ScreenUsed = 0;
+ if (ScreenUsed == 0 || (ScreenUsed + PkgName.length()) >= ScreenWidth)
+ {
+ out << std::endl
+ << " ";
+ ScreenUsed = 0;
+ }
+ else if (ScreenUsed != 0)
+ {
+ out << " ";
+ ++ScreenUsed;
+ }
+ out << setColor << PkgName << resetColor;
+ ScreenUsed += PkgName.length();
}
- else if (ScreenUsed != 0)
- {
- out << " ";
- ++ScreenUsed;
- }
- out << PkgName;
- ScreenUsed += PkgName.length();
}
}
if (printedTitle == true)
{
out << std::endl;
+ if (ListColumns && not PackageList.empty()) {
+ out << setColor;
+ ShowWithColumns(out, PackageList, 2, ScreenWidth);
+ out << resetColor;
+ }
+ if (_config->FindI("APT::Output-Version") >= 30)
+ out << std::endl;
return false;
}
return true;