From 19f5d93dba74dda1fd1a9211707d98b6dd9b19ba Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 10 Mar 2022 21:03:50 +0100 Subject: feat: add status bar background color --- src/util/color.cpp | 15 +++++++++++++++ src/util/color.hpp | 10 ++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/util/color.cpp create mode 100644 src/util/color.hpp (limited to 'src/util') 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 + +std::string get_foreground_esc_seq(const uint32_t &color) noexcept +{ + return std::string( + fmt::detail::make_foreground_color(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(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 +#include + +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; -- cgit v1.2.3-18-g5258