You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1003 B
67 lines
1003 B
#pragma once |
|
#include "merrors.h" |
|
|
|
using michlib::int_cast; |
|
using michlib::MString; |
|
using michlib::uint2; |
|
|
|
class C |
|
{ |
|
protected: |
|
static bool tty; |
|
MString command; |
|
|
|
template<class... T> static MString Create(uint2 c, T... args) { return MString(c) + ";" + Create(args...); } |
|
|
|
static MString Create(uint2 c) { return MString(c); } |
|
|
|
template<class... T> C(T... args): command("\033[" + Create(args...) + "m") {} |
|
|
|
public: |
|
static void Init() { tty = isatty(michlib_internal::fd_std) == 1; } |
|
static void Init(bool c) { tty = c; } |
|
|
|
enum |
|
{ |
|
BLACK = 30, |
|
RED, |
|
GREEN, |
|
YELLOW, |
|
BLUE, |
|
MAGENTA, |
|
CYAN, |
|
WHITE, |
|
BBLACK = 90, |
|
BRED, |
|
BGREEN, |
|
BYELLOW, |
|
BBLUE, |
|
BMAGENTA, |
|
BCYAN, |
|
BWHITE |
|
}; |
|
|
|
C(): C(0) {} |
|
|
|
operator MString() |
|
{ |
|
if(tty) |
|
return command; |
|
else |
|
return ""; |
|
} |
|
}; |
|
|
|
class B: public C |
|
{ |
|
public: |
|
B(): C(49) {} |
|
B(decltype(C::RED) c): C(int_cast<uint2>(c) + 10) {} |
|
}; |
|
|
|
class F: public C |
|
{ |
|
public: |
|
F(): C(39) {} |
|
F(decltype(C::RED) c): C(int_cast<uint2>(c)) {} |
|
};
|
|
|