ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/deliantra/dclient/src/backend/ncxx/color.cpp
Revision: 1.4
Committed: Mon Oct 18 15:34:22 2010 UTC (16 years, 1 month ago) by sf-pippijn
Branch: MAIN
Changes since 1.3: +0 -14 lines
Log Message:
first attempt to support maximising windows

File Contents

# User Rev Content
1 sf-pippijn 1.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/assert.hh>
11     #include <ncurses/support.hh>
12    
13     #include <algorithm>
14 sf-pippijn 1.2 #include <map>
15 sf-pippijn 1.1
16     using ncurses::color;
17    
18 sf-pippijn 1.2 static std::map<std::pair<short, short>, short> color_pairs;
19    
20     static short
21     make_pair (short fg, short bg)
22     {
23     auto pair = std::make_pair (fg, bg);
24     auto found = color_pairs.find (pair);
25     if (found != color_pairs.end ())
26     return found->second;
27    
28     static short color_counter;
29     color_pairs.insert ({ pair, ++color_counter });
30     return color_counter;
31     }
32 sf-pippijn 1.1
33     color::color ()
34     : attr_ (WA_NORMAL)
35     , num_ (-1)
36     {
37     }
38    
39     color::color (short f, short b, attr_t attr)
40     : attr_ (attr)
41 sf-pippijn 1.2 , num_ (make_pair (f, b))
42 sf-pippijn 1.1 {
43     if (has_colors ())
44 sf-pippijn 1.3 return_unless (init_pair (num_, f, b) == OK);
45 sf-pippijn 1.1 }
46    
47     color::~color ()
48     {
49     }
50    
51     attr_t
52     color::attr () const
53     {
54     return attr_;
55     }
56    
57     short
58     color::num () const
59     {
60     return num_;
61     }