aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/colorizer/output.h
blob: b33e5f49f0cb35f86d6302b3b83b8c8f1f9b8a02 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once 
 
#include "colors.h" 
 
// Note: this is an old interface for printing colors to stream.
// Consider printing elements of `EAnsiCode` directly.

namespace NColorizer { 
    typedef TStringBuf (TColors::*TColorFunc)() const; 
 
    struct TColorHandle { 
        const TColors* C; 
        TColorFunc F; 
 
        inline TColorHandle(const TColors* c, TColorFunc f) noexcept
            : C(c) 
            , F(f) 
        { 
        } 
    }; 
 
#define DEF(X)                                              \ 
    static inline TColorHandle X() noexcept {               \ 
        return TColorHandle(&StdErr(), &TColors::X##Color); \ 
    } 
 
    DEF(Old) 
    DEF(Black)
    DEF(Green) 
    DEF(Cyan)
    DEF(Red) 
    DEF(Purple)
    DEF(Brown)
    DEF(LightGray)
    DEF(DarkGray)
    DEF(LightBlue)
    DEF(LightGreen)
    DEF(LightCyan)
    DEF(LightRed)
    DEF(LightPurple)
    DEF(Yellow) 
    DEF(White) 
 
#undef DEF 
}