123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- #ifndef ANSICOLOR_H
- #define ANSICOLOR_H
- #include <cstdint>
- #include <string>
- #define CSI "\x1b["
- enum class COLOR : std::int8_t {
-
- BLACK,
-
- RED,
-
- GREEN,
-
- BROWN,
-
- YELLOW = 3,
-
- BLUE,
-
- MAGENTA,
-
- CYAN,
-
- WHITE
- };
- enum class ATTR : std::int8_t {
-
- RESET,
-
- BOLD,
-
- BRIGHT = 1,
-
- BLINK = 5,
-
- INVERSE = 7
- };
- class ANSIColor {
-
- COLOR fg;
-
- COLOR bg;
-
-
- unsigned int reset : 1;
-
- unsigned int bold : 1;
-
- unsigned int blink : 1;
-
- unsigned int inverse : 1;
- public:
- ANSIColor();
- ANSIColor(ATTR a);
- ANSIColor(COLOR f);
- ANSIColor(COLOR f, ATTR a);
- ANSIColor(COLOR f, ATTR a1, ATTR a2);
- ANSIColor(COLOR f, COLOR b);
- ANSIColor(COLOR f, COLOR b, ATTR a);
- ANSIColor(COLOR f, COLOR b, ATTR a1, ATTR a2);
- ANSIColor(std::initializer_list<int> il);
-
- ANSIColor &Attr(ATTR a);
- bool operator==(const ANSIColor &c) const;
- bool operator!=(const ANSIColor &c) const;
- void setFg(COLOR f);
- void setFg(COLOR f, ATTR a);
- void setBg(COLOR b);
-
- COLOR getFg() { return fg; };
-
- COLOR getBg() { return bg; };
- void attr(ATTR a);
- std::string output(void) const;
- std::string operator()(void) const;
- };
- extern ANSIColor reset;
- #endif
|