Change AnsiEscapeCodes to static const, should compile on MSVC.
This commit is contained in:
@@ -73,11 +73,8 @@ namespace mcolor
|
|||||||
#pragma region Cursor Controls
|
#pragma region Cursor Controls
|
||||||
/// Moves cursor to home position {0, 0}.
|
/// Moves cursor to home position {0, 0}.
|
||||||
static const std::string CursorHome = AnsiEscapePrefix + "H";
|
static const std::string CursorHome = AnsiEscapePrefix + "H";
|
||||||
|
|
||||||
|
|
||||||
/// Moves cursor to line Y, column X.
|
/// Moves cursor to line Y, column X.
|
||||||
static std::string CursorTo(int line, int column);
|
static std::string CursorTo(int line, int column);
|
||||||
|
|
||||||
/// Moves the cursor up # lines.
|
/// Moves the cursor up # lines.
|
||||||
static std::string CursorUp(int lines);
|
static std::string CursorUp(int lines);
|
||||||
|
|
||||||
|
@@ -141,6 +141,9 @@ public:
|
|||||||
bool operator==(const Color4& rhs) const;
|
bool operator==(const Color4& rhs) const;
|
||||||
|
|
||||||
bool operator!=(const Color4& rhs) const;
|
bool operator!=(const Color4& rhs) const;
|
||||||
|
|
||||||
|
|
||||||
|
std::string ToEscapeCode(bool bg = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator << (std::ostream& os, const Color4& c) {
|
inline std::ostream& operator << (std::ostream& os, const Color4& c) {
|
||||||
|
@@ -355,6 +355,13 @@ bool Color4::operator!=(const Color4& rhs) const
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Color4::ToEscapeCode(bool bg) {
|
||||||
|
if (bg)
|
||||||
|
return std::format("\033[48;2;{};{};{}m", r, g, b);
|
||||||
|
|
||||||
|
return std::format("\033[38;2;{};{};{}m", r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
static std::string decimal_to_hex(int dec)
|
static std::string decimal_to_hex(int dec)
|
||||||
{
|
{
|
||||||
if (dec < 1) return "00";
|
if (dec < 1) return "00";
|
||||||
|
Reference in New Issue
Block a user