summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-04-01 22:04:17 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:19:29 +0200
commitc979f335387a597702ce6e0af33a59bc86dbee2c (patch)
tree9fa828215cdfa4f347494a1713a7c36d38d8389b /src
parent8449b32aee3a784622a4a2c1ace47b330da058c0 (diff)
Add function for controlling the background color to Terminal class
Diffstat (limited to 'src')
-rw-r--r--src/core/frontend/Terminal.cpp11
-rw-r--r--src/core/frontend/Terminal.hpp8
2 files changed, 19 insertions, 0 deletions
diff --git a/src/core/frontend/Terminal.cpp b/src/core/frontend/Terminal.cpp
index 5664564..c0b5250 100644
--- a/src/core/frontend/Terminal.cpp
+++ b/src/core/frontend/Terminal.cpp
@@ -36,6 +36,17 @@ std::string Terminal::color(int color, bool bright) const
return ss.str();
}
+std::string Terminal::background(int color) const
+{
+ if (!useColor) {
+ return std::string{};
+ }
+ std::stringstream ss;
+ ss << "\x1b[";
+ ss << (color + 10) << "m";
+ return ss.str();
+}
+
std::string Terminal::bright() const
{
if (!useColor) {
diff --git a/src/core/frontend/Terminal.hpp b/src/core/frontend/Terminal.hpp
index 90a2e6f..708a1d7 100644
--- a/src/core/frontend/Terminal.hpp
+++ b/src/core/frontend/Terminal.hpp
@@ -105,6 +105,14 @@ public:
std::string color(int color, bool bright = true) const;
/**
+ * Returns a control string for switching the background to the given color.
+ *
+ * @param color is the background color the terminal should switch to.
+ * @return a control string to be included in the output stream.
+ */
+ std::string background(int color) const;
+
+ /**
* Returns a control string for switching to the bright mode.
*
* @return a control string to be included in the output stream.