|
4 | 4 |
|
5 | 5 | #include "types/console.h" |
6 | 6 |
|
| 7 | +inline ColorSet::ColorSet(Color color, short foreground, short background) : ColorSet(color, foreground, background, 0) {} |
| 8 | + |
| 9 | +inline ColorSet::ColorSet(Color color, short foreground, short background, chtype style) : |
| 10 | + color(color), |
| 11 | + foreground(foreground), |
| 12 | + background(background), |
| 13 | + style(style), |
| 14 | + value(), |
| 15 | + is_initialized(false) |
| 16 | +{} |
| 17 | + |
| 18 | +inline Color ColorSet::get_color() |
| 19 | +{ |
| 20 | + return color; |
| 21 | +} |
| 22 | + |
| 23 | +inline chtype ColorSet::get_attrs() |
| 24 | +{ |
| 25 | + if (!is_initialized) |
| 26 | + initialize(); |
| 27 | + |
| 28 | + return value; |
| 29 | +} |
| 30 | + |
| 31 | +inline void ColorMap::add(Color color, short foreground, short background, chtype style) |
| 32 | +{ |
| 33 | + add(new ColorSet(color, foreground, background, style)); |
| 34 | +} |
| 35 | + |
| 36 | +inline void ColorMap::add(Color color, short foreground, short background) |
| 37 | +{ |
| 38 | + add(new ColorSet(color, foreground, background)); |
| 39 | +} |
| 40 | + |
| 41 | +inline void ColorMap::add(ColorSet* set) |
| 42 | +{ |
| 43 | + auto element = color_sets.find(set->get_color()); |
| 44 | + if (element == color_sets.end()) |
| 45 | + color_sets.insert(std::make_pair(set->get_color(), set)); |
| 46 | + else |
| 47 | + element->second = set; |
| 48 | +} |
| 49 | + |
| 50 | +inline chtype ColorMap::get_attrs(Color color) |
| 51 | +{ |
| 52 | + auto element = color_sets.find(color); |
| 53 | + if (element == color_sets.end()) |
| 54 | + throw std::out_of_range("color"); |
| 55 | + |
| 56 | + return element->second->get_attrs(); |
| 57 | +} |
| 58 | + |
7 | 59 | inline Window::Window(WINDOW* wnd) : Window(wnd, false, Color::undefined) {} |
8 | 60 |
|
9 | 61 | inline Window::Window(WINDOW* wnd, bool enable_keypad) : Window(wnd, enable_keypad, Color::undefined) {} |
|
0 commit comments