aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/util/LogColor.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 11:26:12 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-14 11:26:12 +0100
commit01c09a196c3f3e5cefaa4119a95a1cdeb7b9c263 (patch)
tree5667369a85bd06b683c67de42bf0311c2647912b /src/crepe/util/LogColor.h
parent6e13510f3c6d4155707f748d237bb1fa05243450 (diff)
parent8600b8a29351aae26ec7b22f84aeeef92d8cb421 (diff)
merge `loek/cleanup` into `loek/audio`
Diffstat (limited to 'src/crepe/util/LogColor.h')
-rw-r--r--src/crepe/util/LogColor.h29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/crepe/util/LogColor.h b/src/crepe/util/LogColor.h
index c1170cb..4b65127 100644
--- a/src/crepe/util/LogColor.h
+++ b/src/crepe/util/LogColor.h
@@ -4,20 +4,19 @@
namespace crepe {
+/**
+ * \brief Utility class for coloring text using ANSI escape codes
+ *
+ * \note Most methods in this class return a reference to \c this, which may be
+ * used to chain multiple display attributes.
+ */
class LogColor {
public:
- LogColor() = default;
+ //! Get color code as stl string (or color content string)
+ const std::string str(const std::string & content = "") const;
public:
- //! get color code as c-style string (or color content string)
- const char * c_str(const char * content = NULL);
- //! color printf-style format string
- const char * fmt(const char * fmt, ...);
- //! get color code as stl string (or color content string)
- const std::string str(const std::string & content = "");
-
-public:
- //! reset color to default foreground and background color
+ //! Reset color to default foreground and background color
LogColor & reset();
public:
@@ -41,11 +40,19 @@ public:
LogColor & bg_white(bool bright = false);
private:
+ /**
+ * \brief Append SGR escape sequence to \c this->code
+ *
+ * \param code SGR attribute number
+ *
+ * See <https://en.wikipedia.org/wiki/ANSI_escape_code> for magic number
+ * reference.
+ */
LogColor & add_code(unsigned int code);
private:
+ //! Color escape sequence
std::string code = "";
- std::string final = "";
};
} // namespace crepe