Lots of implementation for sbf-cpp.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* Licensed under the MIT license see the LICENSE file for details.
|
||||
***************************************************************************************/
|
||||
#include <cstdint>
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
/** \addtogroup Abilities
|
||||
@@ -16,27 +17,27 @@
|
||||
*/
|
||||
namespace SBF {
|
||||
const uint8_t kColorDarkBlack = 0;
|
||||
const uint8_t kColorDarkBlue = 1;
|
||||
const uint8_t kColorDarkRed = 1;
|
||||
const uint8_t kColorDarkGreen = 2;
|
||||
const uint8_t kColorDarkCyan = 3;
|
||||
const uint8_t kColorDarkRed = 4;
|
||||
const uint8_t kColorDarkYellow = 3;
|
||||
const uint8_t kColorDarkBlue = 4;
|
||||
const uint8_t kColorDarkMagenta = 5;
|
||||
const uint8_t kColorDarkOrange = 6;
|
||||
const uint8_t kColorDarkYellow = 6;
|
||||
const uint8_t kColorDarkCyan = 6;
|
||||
const uint8_t kColorDarkWhite = 7;
|
||||
const uint8_t kColorBrightBlack = 8;
|
||||
const uint8_t kColorBrightBlue = 9;
|
||||
const uint8_t kColorBrightRed = 9;
|
||||
const uint8_t kColorBrightGreen = 10;
|
||||
const uint8_t kColorBrightCyan = 11;
|
||||
const uint8_t kColorBrightRed = 12;
|
||||
const uint8_t kColorBrightYellow = 11;
|
||||
const uint8_t kColorBrightBlue = 12;
|
||||
const uint8_t kColorBrightMagenta = 13;
|
||||
const uint8_t kColorBrightOrange = 14;
|
||||
const uint8_t kColorBrightYellow = 14;
|
||||
const uint8_t kColorBrightCyan = 14;
|
||||
const uint8_t kColorBrightWhite = 15;
|
||||
const uint8_t kColorDefaultForeground = kColorBrightWhite;
|
||||
const uint8_t kColorDefaultBackground = kColorDarkBlack;
|
||||
|
||||
/// @brief Sets the stored foreground color.
|
||||
/// @param color The new foreground color.
|
||||
void SetForegroundColor(uint8_t color);
|
||||
uint8_t SetForegroundColor(uint8_t color);
|
||||
|
||||
/// @brief Gets the stored foreground color.
|
||||
/// @return The foreground color.
|
||||
@@ -44,7 +45,7 @@ uint8_t GetForegroundColor();
|
||||
|
||||
/// @brief Sets the stored background color.
|
||||
/// @param color The new background color.
|
||||
void SetBackgroundColor(uint8_t color);
|
||||
uint8_t SetBackgroundColor(uint8_t color);
|
||||
|
||||
/// @brief Gets the stored background color.
|
||||
/// @return The background color.
|
||||
@@ -53,6 +54,38 @@ uint8_t GetBackgroundColor();
|
||||
/// @brief Fills the provided vector with all of the possible color values. It will be cleared before filling.
|
||||
/// @param colors The vector to fill.
|
||||
void FillColors(std::vector<uint8_t>& colors);
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& Reset(std::basic_ostream<TChar, TTraits>& os) {
|
||||
return os << "\033[m";
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& ForegroundColor(std::basic_ostream<TChar, TTraits>& os) {
|
||||
return os << "\033[38;5;" + std::to_string(GetForegroundColor()) + "m";
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& BackgroundColor(std::basic_ostream<TChar, TTraits>& os) {
|
||||
return os << "\033[48;5;" + std::to_string(GetBackgroundColor()) + "m";
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& Colors(std::basic_ostream<TChar, TTraits>& os) {
|
||||
return os << ForegroundColor << BackgroundColor;
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& TrueColorForeground(std::basic_ostream<TChar, TTraits>& os, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
return os << "\033[38;2;" << std::to_string(red) << ";" << std::to_string(green) << ";" << std::to_string(blue)
|
||||
<< "m";
|
||||
}
|
||||
|
||||
template <typename TChar, typename TTraits>
|
||||
auto& TrueColorBackground(std::basic_ostream<TChar, TTraits>& os, uint8_t red, uint8_t green, uint8_t blue) {
|
||||
return os << "\033[48;2;" << std::to_string(red) << ";" << std::to_string(green) << ";" << std::to_string(blue)
|
||||
<< "m";
|
||||
}
|
||||
} // End namespace SBF
|
||||
|
||||
/** @}*/
|
||||
|
||||
Reference in New Issue
Block a user