some ansi codes
parent
bbb48a6b8f
commit
7fa4fd0af2
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/color.cmake)
|
||||
set(BLT_VERSION 2.0.4)
|
||||
set(BLT_VERSION 2.0.5)
|
||||
|
||||
set(BLT_TARGET BLT)
|
||||
|
||||
|
|
|
@ -18,6 +18,149 @@
|
|||
namespace blt::logging
|
||||
{
|
||||
|
||||
namespace ansi
|
||||
{
|
||||
inline auto ESC(std::string_view str)
|
||||
{
|
||||
return std::string("\033") += str;
|
||||
}
|
||||
|
||||
inline const auto CUR_HOME = ESC("[H");
|
||||
|
||||
inline auto CUR_MOVE(blt::size_t line, blt::size_t column)
|
||||
{
|
||||
return ESC("[{" + std::to_string(line) + "};{" + std::to_string(column) + "}H");
|
||||
}
|
||||
|
||||
inline auto CUR_UP(blt::size_t lines)
|
||||
{
|
||||
return ESC("[" + std::to_string(lines) + "A");
|
||||
}
|
||||
|
||||
inline auto CUR_DOWN(blt::size_t lines)
|
||||
{
|
||||
return ESC("[" + std::to_string(lines) + "B");
|
||||
}
|
||||
|
||||
inline auto CUR_RIGHT(blt::size_t columns)
|
||||
{
|
||||
return ESC("[" + std::to_string(columns) + "C");
|
||||
}
|
||||
|
||||
inline auto CUR_LEFT(blt::size_t columns)
|
||||
{
|
||||
return ESC("[" + std::to_string(columns) + "D");
|
||||
}
|
||||
|
||||
inline auto CUR_BEGIN_NEXT(blt::size_t lines_down)
|
||||
{
|
||||
return ESC("[" + std::to_string(lines_down) + "E");
|
||||
}
|
||||
|
||||
inline auto CUR_BEGIN_PREV(blt::size_t lines_up)
|
||||
{
|
||||
return ESC("[" + std::to_string(lines_up) + "F");
|
||||
}
|
||||
|
||||
inline auto CUR_COLUMN(blt::size_t column)
|
||||
{
|
||||
return ESC("[" + std::to_string(column) + "G");
|
||||
}
|
||||
|
||||
inline auto CUR_POS()
|
||||
{
|
||||
return ESC("[6n");
|
||||
}
|
||||
|
||||
inline auto CUR_SCROLL_UP()
|
||||
{
|
||||
return ESC(" M");
|
||||
}
|
||||
|
||||
inline auto CUR_SAVE_DEC()
|
||||
{
|
||||
return ESC(" 7");
|
||||
}
|
||||
|
||||
inline auto CUR_LOAD_DEC()
|
||||
{
|
||||
return ESC(" 8");
|
||||
}
|
||||
|
||||
inline auto CUR_SAVE_SCO()
|
||||
{
|
||||
return ESC("[s");
|
||||
}
|
||||
|
||||
inline auto CUR_LOAD_SCO()
|
||||
{
|
||||
return ESC("[u");
|
||||
}
|
||||
|
||||
inline auto RESET = ESC("[0m");
|
||||
inline auto BOLD = "1";
|
||||
inline auto RESET_BOLD = "22";
|
||||
inline auto DIM = "2";
|
||||
inline auto RESET_DIM = "22";
|
||||
inline auto ITALIC = "3";
|
||||
inline auto RESET_ITALIC = "23";
|
||||
inline auto UNDERLINE = "4";
|
||||
inline auto RESET_UNDERLINE = "24";
|
||||
inline auto BLINKING = "5";
|
||||
inline auto RESET_BLINKING = "25";
|
||||
inline auto INVERSE = "7";
|
||||
inline auto RESET_INVERSE = "27";
|
||||
inline auto HIDDEN = "8";
|
||||
inline auto RESET_HIDDEN = "28";
|
||||
inline auto STRIKETHROUGH = "9";
|
||||
inline auto RESET_STRIKETHROUGH = "29";
|
||||
|
||||
inline auto COLOR_DEFAULT = "39";
|
||||
inline auto BACKGROUND_DEFAULT = "49";
|
||||
|
||||
inline auto BLACK = "30";
|
||||
inline auto RED = "31";
|
||||
inline auto GREEN = "32";
|
||||
inline auto YELLOW = "33";
|
||||
inline auto BLUE = "34";
|
||||
inline auto MAGENTA = "35";
|
||||
inline auto CYAN = "36";
|
||||
inline auto WHITE = "37";
|
||||
inline auto BLACK_BACKGROUND = "40";
|
||||
inline auto RED_BACKGROUND = "41";
|
||||
inline auto GREEN_BACKGROUND = "42";
|
||||
inline auto YELLOW_BACKGROUND = "43";
|
||||
inline auto BLUE_BACKGROUND = "44";
|
||||
inline auto MAGENTA_BACKGROUND = "45";
|
||||
inline auto CYAN_BACKGROUND = "46";
|
||||
inline auto WHITE_BACKGROUND = "47";
|
||||
|
||||
inline auto BRIGHT_BLACK = "90";
|
||||
inline auto BRIGHT_RED = "91";
|
||||
inline auto BRIGHT_GREEN = "92";
|
||||
inline auto BRIGHT_YELLOW = "93";
|
||||
inline auto BRIGHT_BLUE = "94";
|
||||
inline auto BRIGHT_MAGENTA = "95";
|
||||
inline auto BRIGHT_CYAN = "96";
|
||||
inline auto BRIGHT_WHITE = "97";
|
||||
inline auto BRIGHT_BLACK_BACKGROUND = "100";
|
||||
inline auto BRIGHT_RED_BACKGROUND = "101";
|
||||
inline auto BRIGHT_GREEN_BACKGROUND = "102";
|
||||
inline auto BRIGHT_YELLOW_BACKGROUND = "103";
|
||||
inline auto BRIGHT_BLUE_BACKGROUND = "104";
|
||||
inline auto BRIGHT_MAGENTA_BACKGROUND = "105";
|
||||
inline auto BRIGHT_CYAN_BACKGROUND = "106";
|
||||
inline auto BRIGHT_WHITE_BACKGROUND = "107";
|
||||
|
||||
template<typename... Args>
|
||||
inline auto MAKE_COLOR(Args... colors)
|
||||
{
|
||||
std::string mode;
|
||||
((mode + std::string(colors) + ";"), ...);
|
||||
return ESC("[" + mode.substr(0, mode.size() - 1) + "m");
|
||||
}
|
||||
}
|
||||
|
||||
enum class log_level
|
||||
{
|
||||
// default
|
||||
|
@ -146,7 +289,8 @@ namespace blt::logging
|
|||
} else if constexpr (std::is_same_v<T, std::string>)
|
||||
{
|
||||
log_internal(t, level, file, line, args);
|
||||
} else if constexpr (std::is_same_v<T, const char*>){
|
||||
} else if constexpr (std::is_same_v<T, const char*>)
|
||||
{
|
||||
log_internal(std::string(t), level, file, line, args);
|
||||
} else
|
||||
{
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 93201da2ba5a6aba0a6e57ada64973555629b3e3
|
||||
Subproject commit 63acc3336f941c6f324c88eb9ee4ce623a460cd5
|
Loading…
Reference in New Issue