summaryrefslogtreecommitdiff
path: root/ycurses/src/curses/color.cpp
blob: 190d343a830051f8e2519228e401cf90a545e50b (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
#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