diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
| commit | b891420946d5269cc326d67555c6aab3db41a01a (patch) | |
| tree | f6c5e7d6dbf18ec8c0ea9ec0b037251df46b4cbb /ycurses/src/curses/color.cpp | |
| parent | a537e8323d932125232c305f9573daef89aef0df (diff) | |
added yhttpd and ycurses trunk versions
Diffstat (limited to 'ycurses/src/curses/color.cpp')
| -rw-r--r-- | ycurses/src/curses/color.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ycurses/src/curses/color.cpp b/ycurses/src/curses/color.cpp new file mode 100644 index 0000000..190d343 --- /dev/null +++ b/ycurses/src/curses/color.cpp @@ -0,0 +1,54 @@ +#ifndef COLOR_CPP +#define COLOR_CPP + +#include "color.h" + +bool color::b_activated = false; +int color::i_pair_count = 0; + +color::color(short i, short j) + : i_foreground(i), i_background(j) +{ + init(); + + i_pair = ++i_pair_count; + + /* + * Simple color assignment. color pair 0 cannot + * be redefined. + */ + init_pair(i_pair, i_foreground, i_background); +} + +color::~color() +{ +} + +void +color::init() +{ + if ( !b_activated ) + { + if (has_colors()) + { + start_color(); + b_activated = true; + } + } +} + +void +color::enable() +{ + attron(COLOR_PAIR(i_pair)); +} + +void +color::disable() +{ + attroff(COLOR_PAIR(i_pair)); +} + + +#endif + |
