107 lines
3.3 KiB
C++
107 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <cstdint>
|
|
#include <format>
|
|
|
|
#define ESC "\033["
|
|
|
|
namespace jlog::ansi_escape_codes
|
|
{
|
|
static const std::string CURSOR_HOME = "\033[H";
|
|
|
|
static const std::string ERASE_SCREEN_AFTER_CURSOR = "\033[0J";
|
|
static const std::string ERASE_SCREEN_BEFORE_CURSOR = "\033[1J";
|
|
static const std::string ERASE_SCREEN_ALL = "\033[2J";
|
|
static const std::string ERASE_LINE_AFTER_CURSOR = "\033[0K";
|
|
static const std::string ERASE_LINE_BEFORE_CURSOR = "\033[1K";
|
|
static const std::string ERASE_LINE_ALL = "\033[2K";
|
|
|
|
static const std::string RESET = "\033[0m";
|
|
static const std::string BOLD = "\033[1m";
|
|
static const std::string DIM = "\033[2m";
|
|
|
|
/// These are some examples of private modes, which are not defined by the spec, but are implemented in most terminals.
|
|
/// @see xterm control sequences for a more in-depth list.
|
|
/// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
|
|
/// @note While these modes may be supported by most terminals, some may not work in multiplexers like tmux.
|
|
|
|
static const std::string CURSOR_INVISIBLE = "\033[?25l";
|
|
static const std::string CURSOR_VISIBLE = "\033[?25h";
|
|
static const std::string RESTORE_SCREEN = "\033[?47l";
|
|
static const std::string SAVE_SCREEN = "\033[?47h";
|
|
|
|
|
|
static const std::string FG_BLACK = "\033[30m";
|
|
static const std::string FG_RED = "\033[31m";
|
|
static const std::string FG_GREEN = "\033[32m";
|
|
static const std::string FG_YELLOW = "\033[33m";
|
|
static const std::string FG_BLUE = "\033[34m";
|
|
static const std::string FG_MAGENTA = "\033[35m";
|
|
static const std::string FG_CYAN = "\033[36m";
|
|
static const std::string FG_WHITE = "\033[37m";
|
|
static const std::string FG_DEFAULT = "\033[39m";
|
|
|
|
|
|
static const std::string FG_BRIGHT_BLACK = "90";
|
|
static const std::string FG_BRIGHT_RED = "91";
|
|
static const std::string FG_BRIGHT_GREEN = "92";
|
|
static const std::string FG_BRIGHT_YELLOW = "93";
|
|
static const std::string FG_BRIGHT_BLUE = "94";
|
|
static const std::string FG_BRIGHT_MAGENTA = "95";
|
|
static const std::string FG_BRIGHT_CYAN = "96";
|
|
static const std::string FG_BRIGHT_WHITE = "97";
|
|
|
|
|
|
static const std::string BG_BLACK = "40";
|
|
static const std::string BG_RED = "41";
|
|
static const std::string BG_GREEN = "42";
|
|
static const std::string BG_YELLOW = "43";
|
|
static const std::string BG_BLUE = "44";
|
|
static const std::string BG_MAGENTA = "45";
|
|
static const std::string BG_CYAN = "46";
|
|
static const std::string BG_WHITE = "47";
|
|
static const std::string BG_DEFAULT = "49";
|
|
|
|
static const std::string BG_BRIGHT_BLACK = "100";
|
|
static const std::string BG_BRIGHT_RED = "101";
|
|
static const std::string BG_BRIGHT_GREEN = "102";
|
|
static const std::string BG_BRIGHT_YELLOW = "103";
|
|
static const std::string BG_BRIGHT_BLUE = "104";
|
|
|
|
std::string true_color(uint8_t r, uint8_t g, uint8_t b)
|
|
{
|
|
return std::format("\033[38;2;{};{};{}m", r, g, b);
|
|
}
|
|
|
|
std::string cursor_to(int line, int col)
|
|
{
|
|
|
|
}
|
|
|
|
std::string cursor_up(int lines)
|
|
{
|
|
|
|
}
|
|
|
|
std::string cursor_down(int lines)
|
|
{
|
|
|
|
}
|
|
|
|
std::string cursor_left(int cols)
|
|
{
|
|
|
|
}
|
|
|
|
std::string cursor_right(int cols)
|
|
{
|
|
|
|
}
|
|
|
|
std::string cursor_to_col(int col)
|
|
{
|
|
|
|
}
|
|
}
|