summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-04-15 17:51:26 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-04-19 20:49:05 +0200
commitae1ff72fbee8b3f5d063e8baa86a64e3da11aeb2 (patch)
treeca9a0f28ae4063ddeb7b50552769be3b68f2de48 /apt-private
parent3f5e368ba800f823b36931ced783d450ec621264 (diff)
show: Highlight field names and colorize package name
We should pass this properly to the TagSection.write()
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-output.cc2
-rw-r--r--apt-private/private-show.cc10
2 files changed, 9 insertions, 3 deletions
diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc
index d5720f41a..5d83a04f4 100644
--- a/apt-private/private-output.cc
+++ b/apt-private/private-output.cc
@@ -112,6 +112,8 @@ bool InitOutput(std::basic_streambuf<char> * const out) /*{{{*/
_config->CndSet("APT::Color::Action::Install-Dependencies", "green");
_config->CndSet("APT::Color::Action::Downgrade", "yellow");
_config->CndSet("APT::Color::Action::Remove", "red");
+ _config->CndSet("APT::Color::Show::Field", "\x1B[1m");
+ _config->CndSet("APT::Color::Show::Package", "\x1B[32m");
}
return true;
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc
index cefbd9b67..4ae043071 100644
--- a/apt-private/private-show.cc
+++ b/apt-private/private-show.cc
@@ -1,6 +1,7 @@
// Includes /*{{{*/
#include <config.h>
+#include <apt-pkg/aptconfiguration.h>
#include <apt-pkg/cachefile.h>
#include <apt-pkg/cacheset.h>
#include <apt-pkg/cmndline.h>
@@ -33,6 +34,8 @@
#include <apti18n.h>
/*}}}*/
+using APT::Configuration::color;
+
pkgRecords::Parser &LookupParser(pkgRecords &Recs, pkgCache::VerIterator const &V, pkgCache::VerFileIterator &Vf) /*{{{*/
{
Vf = V.FileList();
@@ -271,7 +274,8 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
RW.push_back(pkgTagSection::Tag::Remove("Description"));
RW.push_back(pkgTagSection::Tag::Remove("Description-md5"));
// improve
- RW.push_back(pkgTagSection::Tag::Rewrite("Package", V.ParentPkg().FullName(true)));
+ RW.push_back(pkgTagSection::Tag::Rewrite("Package", color("Show::Package", V.ParentPkg().FullName(true))));
+
RW.push_back(pkgTagSection::Tag::Rewrite("Installed-Size", installed_size));
RW.push_back(pkgTagSection::Tag::Remove("Size"));
RW.push_back(pkgTagSection::Tag::Rewrite("Download-Size", package_size));
@@ -282,7 +286,7 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
FileFd stdoutfd;
if (stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false) == false ||
- Tags.Write(stdoutfd, TFRewritePackageOrder, RW) == false || stdoutfd.Close() == false)
+ Tags.Write(stdoutfd, pkgTagSection::WRITE_HUMAN, TFRewritePackageOrder, RW) == false || stdoutfd.Close() == false)
return _error->Error("Internal Error, Unable to parse a package record");
// write the description
@@ -291,7 +295,7 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/
if (Desc.end() == false)
{
pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
- out << "Description: " << P.LongDesc();
+ out << color("Show::Field", "Description: ") << P.LongDesc();
}
// write a final newline (after the description)