summaryrefslogtreecommitdiffstats
path: root/apt-pkg/aptconfiguration.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-23 04:10:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-23 04:10:50 +0000
commitfaf78e24948280b25ccad71e5fe027809f8c6279 (patch)
treeeac8c502171ec9b3295e1ed84791d63a2f567666 /apt-pkg/aptconfiguration.cc
parentAdding upstream version 2.9.1. (diff)
downloadapt-faf78e24948280b25ccad71e5fe027809f8c6279.tar.xz
apt-faf78e24948280b25ccad71e5fe027809f8c6279.zip
Adding upstream version 2.9.2.upstream/2.9.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'apt-pkg/aptconfiguration.cc')
-rw-r--r--apt-pkg/aptconfiguration.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc
index 982e68b..f462b6e 100644
--- a/apt-pkg/aptconfiguration.cc
+++ b/apt-pkg/aptconfiguration.cc
@@ -563,4 +563,39 @@ bool Configuration::checkUsrMerged()
return true;
}
/*}}}*/
+// isUsrMerged - whether usr is merged t /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+std::string Configuration::color(std::string const &colorName, std::string const &content)
+{
+ if (not _config->FindB("APT::Color"))
+ return content;
+
+ auto colors = ::Configuration(_config->Tree("APT::Color"));
+ auto color = colors.Find(colorName);
+
+ // Resolve the color recursively. A color string has the following format
+ // <color> := \x1B<word> ; fully resolved color
+ // | \\x1B<word> ; color escaped.
+ // | <word> ; a simple color name
+ // | <color> <color> ; a sequence of colors
+ if (color.find(" ") != color.npos)
+ {
+ std::string res;
+ for (auto &&colorPart : VectorizeString(color, ' '))
+ res += Configuration::color(colorPart);
+ color = res;
+ }
+ else if (not color.empty() && color[0] != '\x1B')
+ {
+ if (APT::String::Startswith(color, "\\x1B"))
+ color = "\x1B" + color.substr(4);
+ else
+ color = Configuration::color(color);
+ }
+ if (content.empty())
+ return color;
+ return color + content + Configuration::color("Neutral");
+}
+ /*}}}*/
}