1 #ifndef __COLORSCHEMER_H__
2 #define __COLORSCHEMER_H__
8 #include "conscommon.h"
15 void parsecolordef(const string sdef
, int pair
, colordef
&d
);
20 map
<T
, colordef
> colors
;
27 void push(T elem
, const string
&def
) {
28 parsecolordef(def
, (int) elem
, colors
[elem
]);
31 void load(const string
&fname
) {
32 ifstream
f(fname
.c_str());
39 void save(const string
&fname
) const {
40 ofstream
f(fname
.c_str());
47 void save(ofstream
&f
) const {
48 typename map
<T
, colordef
>::const_iterator ic
;
50 for(ic
= colors
.begin(); ic
!= colors
.end(); ic
++) {
51 f
<< ic
->second
.name
<< "\t" << ic
->second
.def
<< endl
;
55 void load(ifstream
&f
) {
58 typename map
<T
, colordef
>::iterator ic
;
63 if((pos
= buf
.find_first_of(" \t")) != -1) {
64 p
= buf
.substr(0, pos
);
66 for(ic
= colors
.begin(); ic
!= colors
.end(); ic
++) {
67 if(ic
->second
.name
== p
) {
76 int operator[] (T elem
) const {
77 typename map
<T
, colordef
>::const_iterator ic
= colors
.find(elem
);
78 return (ic
!= colors
.end()) ? ic
->second
.code
: normalcolor(0);
81 friend std::ostream
& operator<< (std::ostream
&o
, const colorschemer
&s
) {