blob: f1ff442fac57ecd726957949b9b201b48034e69c (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include <ncurses.h>
#define NCURSES_CPP_FLAGS_MASK_TYPE_AS_PUBLIC
#include <cassert>
#include <ncurses/char_attributes.hpp>
#include <ncurses/colors.hpp>
#include <ncurses/utils/multiflags.hpp>
using namespace ncurses;
template <> struct ncurses::is_applyable<color_pair, attr> : std::true_type {};
using full_attrs = ncurses::multiflags<attr, color_pair>;
int main(int argc, char *argv[]) {
{
full_attrs attr;
assert(attr.value_ == 0);
attr = attr::blink;
assert(attr.value_ == A_BLINK);
attr = color_pair(22);
assert(attr.value_ == COLOR_PAIR(22));
attr = attr::bold | attr::italic | attr::top;
assert(attr.value_ == (A_TOP | A_ITALIC | A_BOLD));
}
{
full_attrs attr = attr::color | color_pair(10);
assert(attr.value_ == (A_COLOR | COLOR_PAIR(10)));
}
{
full_attrs attr = color_pair(10) | attr::color;
assert(attr.value_ == (A_COLOR | COLOR_PAIR(10)));
}
{
full_attrs attr = color_pair(11) | attr::altcharset | attr::dim;
assert(attr.value_ == (A_ALTCHARSET | A_DIM | COLOR_PAIR(11)));
}
{
full_attrs attr = attr::top | color_pair(30);
assert(attr != color_pair(1));
assert(attr != attr::chartext);
assert(attr != (attr::bold | attr::dim));
assert(attr != (attr::bold | attr::dim | color_pair(1)));
assert(attr == (full_attrs(attr::top) | color_pair(30)));
}
{
full_attrs attr;
// attr_flags to full_attrs
attr = attr_flags(attr::top | attr::dim | attr::bold);
// color + attr to full_attrs + attr to full_attrs
attr = color_pair(1) | attr::top | attr::bold;
// color + attr_flags to full_attrs
attr = color_pair(2) | (attr::top & attr::bold);
// attr_flags + color to full_attrs
attr = (attr::top & attr::bold) | color_pair(2);
}
return 0;
}
|