4 changed files with 77 additions and 0 deletions
@ -0,0 +1,67 @@
|
||||
#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)) {} |
||||
}; |
@ -0,0 +1,4 @@
|
||||
#define MICHLIB_NOSOURCE |
||||
#include "conscolors.h" |
||||
|
||||
bool C::tty = false; |
Loading…
Reference in new issue