ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/dclient/src/backend/ncxx/color.cpp
Revision: 1.6
Committed: Wed Oct 20 05:09:28 2010 UTC (16 years, 1 month ago) by sf-pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
State: FILE REMOVED
Log Message:
unused

File Contents

# Content
1 /* color.cc
2 * This file is part of ncursesxx library
3 * Copyright (c) 2003,2004 by Stanislav Ievlev
4 *
5 * This file is covered by the GNU Library General Public License,
6 * which should be included with libncursesxx as the file COPYING.
7 */
8 #include <ncurses/color.hh>
9
10 #include <ncurses/support.hh>
11
12 #include <algorithm>
13 #include <map>
14
15 using ncurses::color;
16
17 static std::map<std::pair<short, short>, short> color_pairs;
18
19 static short
20 make_pair (short fg, short bg)
21 {
22 auto pair = std::make_pair (fg, bg);
23 auto found = color_pairs.find (pair);
24 if (found != color_pairs.end ())
25 return found->second;
26
27 static short color_counter;
28 color_pairs.insert ({ pair, ++color_counter });
29 return color_counter;
30 }
31
32 color::color ()
33 : attr_ (WA_NORMAL)
34 , num_ (-1)
35 {
36 }
37
38 color::color (short f, short b, attr_t attr)
39 : attr_ (attr)
40 , num_ (make_pair (f, b))
41 {
42 if (has_colors ())
43 return_unless (init_pair (num_, f, b) == OK);
44 }
45
46 color::~color ()
47 {
48 }
49
50 attr_t
51 color::attr () const
52 {
53 return attr_;
54 }
55
56 short
57 color::num () const
58 {
59 return num_;
60 }