- 
                Notifications
    You must be signed in to change notification settings 
- Fork 63
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Milestone
Description
I thought that it might be a good idea to simplify and align the different color implementation into one simple to use programming interface. I'd propose this:
// RGB
struct RGB {
	int r, g, b;
	bool empty;
}
// FG
std::string color_fg(bit4(enum))
std::string color_fg(bit8(int))
std::string color_fg(r, g, b)
std::string color_fg(RGB)
std::string color_fg(RGBF)
// BG
std::string color_bg(bit4(enum))
std::string color_bg(bit8(int))
std::string color_bg(r, g, b)
std::string color_bg(RGB)
std::string color_bg(RGBF)
// style
std::string style(style(enum))
// RGBF (full RGB, basically just foreground and back-ground colors to make the auto color functionality simple and easy)
// Also great for when users want to change colors on runtime, think of a theme selection for a TUI application
struct RGBF {
	RGB rgb_fg;
	RGB rgb_bg;
}
// simply prints the given full color struct
std::string colorf(RGBF)
// functions to set the RGBF colors (FG)
RGBF rgbf_fg(bit4)
RGBF rgbf_fg(bit8)
RGBF rgbf_fg(r,g,b)
RGBF rgbf_fg(RGB)
// functions to set the RGBF colors (BG)
RGBF rgbf_bg(bit4)
RGBF rgbf_bg(bit8)
RGBF rgbf_bg(r,g,b)
RGBF rgbf_bg(RGB)
// functions to set the RGBF colors (FG and BG)
RGBF rgbf_fb(bit4, bit4)
RGBF rgbf_fb(bit8, bit8)
RGBF rgbf_fb(r,g,b,r,g,b)
RGBF rgbf_fb(RGB,RGB)
// make an empty RGBF struct (for disabling colors on runtime maybe)
RGBF rgbf_empty()
// Auto color modes (usefull to change the color output on runtime if whished)
enum class Mode {
	none, // will simply disable colors
	bit4, // will convert the RGB color into 4bit ones 
	bit8,  // will convert the RGB color into 8bit ones
	bit24, // will print the raw RGB colors
        auto // will print bit24, but falls-back to bit8 when color support is not present
}
// print the selected color in the selected mode
std::string color_auto(RGBF, color_mode)
// print the selected color using auto mode
std::string color_auto(RGBF)
// other
int row, int height get_size()
bool stdout_connected()
bool stdin_connected()
std::string cursor_off()
std::string cursor_on()
std::string clear_screen()
std::string clear_buffer()
std::string cursor_move()
std::string cursor_up()
std::string cursor_down()
std::string cursor_left()
std::string cursor_right()
int, int cursor_position()
std::string cursor_position_report()
std::string clear_to_eol()
std::string screen_save()
std::string screen_load()
class Terminal
std::string terminal_title()Metadata
Metadata
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or request
Type
Projects
Status
Done