aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-10 21:03:50 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:55 +0200
commit19f5d93dba74dda1fd1a9211707d98b6dd9b19ba (patch)
treeed2576cbcd54655d0b006991cc8834d2c95c64f0 /src/util
parentc988905add09cf8baf46dc61279528f6f39f7a1a (diff)
feat: add status bar background color
Diffstat (limited to 'src/util')
-rw-r--r--src/util/color.cpp15
-rw-r--r--src/util/color.hpp10
2 files changed, 25 insertions, 0 deletions
diff --git a/src/util/color.cpp b/src/util/color.cpp
new file mode 100644
index 0000000..17665de
--- /dev/null
+++ b/src/util/color.cpp
@@ -0,0 +1,15 @@
+#include "color.hpp"
+
+#include <fmt/color.h>
+
+std::string get_foreground_esc_seq(const uint32_t &color) noexcept
+{
+ return std::string(
+ fmt::detail::make_foreground_color<char>(fmt::detail::color_type(color)).begin());
+}
+
+std::string get_background_esc_seq(const uint32_t &color) noexcept
+{
+ return std::string(
+ fmt::detail::make_background_color<char>(fmt::detail::color_type(color)).begin());
+}
diff --git a/src/util/color.hpp b/src/util/color.hpp
new file mode 100644
index 0000000..5511893
--- /dev/null
+++ b/src/util/color.hpp
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <fmt/core.h>
+#include <string>
+
+constexpr fmt::string_view RESET_ALL_MODES = "{esc}[0m";
+
+std::string get_foreground_esc_seq(const uint32_t &color) noexcept;
+
+std::string get_background_esc_seq(const uint32_t &color) noexcept;