1 /* vim:tw=78:ts=8:sw=4:set ft=c: */
3 Copyright (C) 2002-2024 Ben Kibbey <bjk@luxsci.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 * Looks for a matching color pair or creates a new color pair if not found.
35 find_cp (short fg
, short bg
, attr_t attrs
)
40 for (i
= 1; i
< next_cp
; i
++)
42 pair_content (i
, &xfg
, &xbg
);
44 if (xfg
== fg
&& xbg
== bg
)
45 return COLOR_PAIR (i
) | attrs
;
48 init_pair (next_cp
, fg
, bg
);
49 return COLOR_PAIR (next_cp
++) | attrs
;
53 * Mixes two color pairs' fg and bg colors determined by 'which'.
56 mix_cp (chtype a
, chtype b
, attr_t attrs
, int which
)
61 pair_content (PAIR_NUMBER (a
), &afg
, &abg
);
62 pair_content (PAIR_NUMBER (b
), &bfg
, &bbg
);
67 return find_cp (afg
, bbg
, attrs
);
69 return find_cp (afg
, bfg
, attrs
);
71 return find_cp (abg
, bbg
, attrs
);
73 return find_cp (bfg
, abg
, attrs
);
75 return find_cp (bbg
, bfg
, attrs
);
77 return find_cp (abg
, afg
, attrs
);
79 return find_cp (bbg
, afg
, attrs
);
90 init_pair (next_cp
++, config
.color
[CONF_BCOORDS
].fg
,
91 config
.color
[CONF_BCOORDS
].bg
);
92 init_pair (next_cp
++, config
.color
[CONF_BGRAPHICS
].fg
,
93 config
.color
[CONF_BGRAPHICS
].bg
);
94 init_pair (next_cp
++, config
.color
[CONF_BWHITE
].fg
,
95 config
.color
[CONF_BWHITE
].bg
);
96 init_pair (next_cp
++, config
.color
[CONF_BBLACK
].fg
,
97 config
.color
[CONF_BBLACK
].bg
);
98 init_pair (next_cp
++, config
.color
[CONF_BSELECTED
].fg
,
99 config
.color
[CONF_BSELECTED
].bg
);
100 init_pair (next_cp
++, config
.color
[CONF_BCURSOR
].fg
,
101 config
.color
[CONF_BCURSOR
].bg
);
102 init_pair (next_cp
++, config
.color
[CONF_SWINDOW
].fg
,
103 config
.color
[CONF_SWINDOW
].bg
);
104 init_pair (next_cp
++, config
.color
[CONF_SBORDER
].fg
,
105 config
.color
[CONF_SBORDER
].bg
);
106 init_pair (next_cp
++, config
.color
[CONF_STITLE
].fg
,
107 config
.color
[CONF_STITLE
].bg
);
108 init_pair (next_cp
++, config
.color
[CONF_SENGINE
].fg
,
109 config
.color
[CONF_SENGINE
].bg
);
110 init_pair (next_cp
++, config
.color
[CONF_SNOTIFY
].fg
,
111 config
.color
[CONF_SNOTIFY
].bg
);
112 init_pair (next_cp
++, config
.color
[CONF_TWINDOW
].fg
,
113 config
.color
[CONF_TWINDOW
].bg
);
114 init_pair (next_cp
++, config
.color
[CONF_TBORDER
].fg
,
115 config
.color
[CONF_TBORDER
].bg
);
116 init_pair (next_cp
++, config
.color
[CONF_TTITLE
].fg
,
117 config
.color
[CONF_TTITLE
].bg
);
118 init_pair (next_cp
++, config
.color
[CONF_HWINDOW
].fg
,
119 config
.color
[CONF_HWINDOW
].bg
);
120 init_pair (next_cp
++, config
.color
[CONF_HBORDER
].fg
,
121 config
.color
[CONF_HBORDER
].bg
);
122 init_pair (next_cp
++, config
.color
[CONF_HTITLE
].fg
,
123 config
.color
[CONF_HTITLE
].bg
);
124 init_pair (next_cp
++, config
.color
[CONF_MWINDOW
].fg
,
125 config
.color
[CONF_MWINDOW
].bg
);
126 init_pair (next_cp
++, config
.color
[CONF_MBORDER
].fg
,
127 config
.color
[CONF_MBORDER
].bg
);
128 init_pair (next_cp
++, config
.color
[CONF_MTITLE
].fg
,
129 config
.color
[CONF_MTITLE
].bg
);
130 init_pair (next_cp
++, config
.color
[CONF_MPROMPT
].fg
,
131 config
.color
[CONF_MPROMPT
].bg
);
132 init_pair (next_cp
++, config
.color
[CONF_IWINDOW
].fg
,
133 config
.color
[CONF_IWINDOW
].bg
);
134 init_pair (next_cp
++, config
.color
[CONF_IBORDER
].fg
,
135 config
.color
[CONF_IBORDER
].bg
);
136 init_pair (next_cp
++, config
.color
[CONF_ITITLE
].fg
,
137 config
.color
[CONF_ITITLE
].bg
);
138 init_pair (next_cp
++, config
.color
[CONF_IPROMPT
].fg
,
139 config
.color
[CONF_IPROMPT
].bg
);
140 init_pair (next_cp
++, config
.color
[CONF_BMOVESW
].fg
,
141 config
.color
[CONF_BMOVESW
].bg
);
142 init_pair (next_cp
++, config
.color
[CONF_BMOVESB
].fg
,
143 config
.color
[CONF_BMOVESB
].bg
);
144 init_pair (next_cp
++, config
.color
[CONF_BCOUNT
].fg
,
145 config
.color
[CONF_BCOUNT
].bg
);
146 init_pair (next_cp
++, config
.color
[CONF_BDWINDOW
].fg
,
147 config
.color
[CONF_BDWINDOW
].bg
);
148 init_pair (next_cp
++, config
.color
[CONF_MENU
].fg
,
149 config
.color
[CONF_MENU
].bg
);
150 init_pair (next_cp
++, config
.color
[CONF_MENUS
].fg
,
151 config
.color
[CONF_MENUS
].bg
);
152 init_pair (next_cp
++, config
.color
[CONF_MENUH
].fg
,
153 config
.color
[CONF_MENUH
].bg
);
154 init_pair (next_cp
++, config
.color
[CONF_HISTORY_MENU_LG
].fg
,
155 config
.color
[CONF_HISTORY_MENU_LG
].bg
);
158 * These are not configurable. They are the color pairs that are mixed
159 * with the background of the current square and foreground of the current
160 * piece. See draw_board() for details.
162 init_pair (next_cp
++, config
.color
[CONF_BWHITE
].fg
,
163 config
.color
[CONF_BWHITE
].bg
);
164 init_pair (next_cp
++, config
.color
[CONF_BBLACK
].fg
,
165 config
.color
[CONF_BWHITE
].bg
);
166 init_pair (next_cp
++, config
.color
[CONF_BBLACK
].fg
,
167 config
.color
[CONF_BBLACK
].bg
);
168 init_pair (next_cp
++, config
.color
[CONF_BWHITE
].fg
,
169 config
.color
[CONF_BBLACK
].bg
);
171 init_pair (next_cp
++, config
.color
[CONF_BCASTLING
].fg
,
172 config
.color
[CONF_BCASTLING
].bg
);
173 init_pair (next_cp
++, config
.color
[CONF_BENPASSANT
].fg
,
174 config
.color
[CONF_BENPASSANT
].bg
);
175 init_pair (next_cp
++, config
.color
[CONF_BATTACK
].fg
,
176 config
.color
[CONF_BATTACK
].bg
);
177 init_pair (next_cp
++, config
.color
[CONF_BPREVMOVE
].fg
,
178 config
.color
[CONF_BPREVMOVE
].bg
);
182 set_default_colors ()
184 config
.color
[CONF_BDWINDOW
].fg
= COLOR_WHITE
;
185 config
.color
[CONF_BDWINDOW
].bg
= COLOR_BLACK
;
186 config
.color
[CONF_BCOORDS
].fg
= COLOR_YELLOW
;
187 config
.color
[CONF_BCOORDS
].bg
= COLOR_BLACK
;
188 config
.color
[CONF_BMOVESW
].fg
= COLOR_WHITE
;
189 config
.color
[CONF_BMOVESW
].bg
= COLOR_WHITE
;
190 config
.color
[CONF_BMOVESW
].nattrs
= A_REVERSE
;
191 config
.color
[CONF_BMOVESB
].fg
= COLOR_WHITE
;
192 config
.color
[CONF_BMOVESB
].bg
= COLOR_BLUE
;
193 config
.color
[CONF_BMOVESB
].nattrs
= A_REVERSE
;
194 config
.color
[CONF_BCOUNT
].fg
= COLOR_MAGENTA
;
195 config
.color
[CONF_BCOUNT
].bg
= COLOR_CYAN
;
196 config
.color
[CONF_BCOUNT
].attrs
= A_BOLD
;
197 config
.color
[CONF_BCOUNT
].nattrs
= A_REVERSE
;
198 config
.color
[CONF_BGRAPHICS
].fg
= COLOR_WHITE
;
199 config
.color
[CONF_BGRAPHICS
].bg
= COLOR_BLACK
;
200 config
.color
[CONF_BWHITE
].fg
= COLOR_WHITE
;
201 config
.color
[CONF_BWHITE
].bg
= COLOR_RED
;
202 config
.color
[CONF_BWHITE
].nattrs
= A_REVERSE
;
203 config
.color
[CONF_BBLACK
].fg
= COLOR_CYAN
;
204 config
.color
[CONF_BBLACK
].bg
= COLOR_BLACK
;
205 config
.color
[CONF_BSELECTED
].fg
= COLOR_WHITE
;
206 config
.color
[CONF_BSELECTED
].bg
= COLOR_YELLOW
;
207 config
.color
[CONF_BSELECTED
].nattrs
= A_BOLD
| A_REVERSE
;
208 config
.color
[CONF_BCURSOR
].fg
= COLOR_WHITE
;
209 config
.color
[CONF_BCURSOR
].bg
= COLOR_GREEN
;
210 config
.color
[CONF_BCURSOR
].nattrs
= A_BOLD
| A_REVERSE
;
211 config
.color
[CONF_SWINDOW
].fg
= COLOR_WHITE
;
212 config
.color
[CONF_SWINDOW
].bg
= COLOR_BLACK
;
213 config
.color
[CONF_SBORDER
].fg
= COLOR_CYAN
;
214 config
.color
[CONF_SBORDER
].bg
= COLOR_BLACK
;
215 config
.color
[CONF_STITLE
].fg
= COLOR_WHITE
;
216 config
.color
[CONF_STITLE
].bg
= COLOR_BLUE
;
217 config
.color
[CONF_STITLE
].nattrs
= A_REVERSE
;
218 config
.color
[CONF_SENGINE
].fg
= COLOR_YELLOW
;
219 config
.color
[CONF_SENGINE
].bg
= COLOR_BLACK
;
220 config
.color
[CONF_SENGINE
].nattrs
= A_BOLD
;
221 config
.color
[CONF_SNOTIFY
].fg
= COLOR_GREEN
;
222 config
.color
[CONF_SNOTIFY
].bg
= COLOR_BLACK
;
223 config
.color
[CONF_SNOTIFY
].nattrs
= A_BOLD
;
224 config
.color
[CONF_TWINDOW
].fg
= COLOR_WHITE
;
225 config
.color
[CONF_TWINDOW
].bg
= COLOR_BLACK
;
226 config
.color
[CONF_TBORDER
].fg
= COLOR_CYAN
;
227 config
.color
[CONF_TBORDER
].bg
= COLOR_BLACK
;
228 config
.color
[CONF_TTITLE
].fg
= COLOR_WHITE
;
229 config
.color
[CONF_TTITLE
].bg
= COLOR_BLUE
;
230 config
.color
[CONF_TTITLE
].nattrs
= A_REVERSE
;
231 config
.color
[CONF_HWINDOW
].fg
= COLOR_WHITE
;
232 config
.color
[CONF_HWINDOW
].bg
= COLOR_BLACK
;
233 config
.color
[CONF_HBORDER
].fg
= COLOR_CYAN
;
234 config
.color
[CONF_HBORDER
].bg
= COLOR_BLACK
;
235 config
.color
[CONF_HTITLE
].fg
= COLOR_WHITE
;
236 config
.color
[CONF_HTITLE
].bg
= COLOR_BLUE
;
237 config
.color
[CONF_HTITLE
].nattrs
= A_REVERSE
;
238 config
.color
[CONF_MWINDOW
].fg
= COLOR_WHITE
;
239 config
.color
[CONF_MWINDOW
].bg
= COLOR_BLACK
;
240 config
.color
[CONF_MBORDER
].fg
= COLOR_CYAN
;
241 config
.color
[CONF_MBORDER
].bg
= COLOR_BLACK
;
242 config
.color
[CONF_MTITLE
].fg
= COLOR_WHITE
;
243 config
.color
[CONF_MTITLE
].bg
= COLOR_MAGENTA
;
244 config
.color
[CONF_MTITLE
].nattrs
= A_REVERSE
;
245 config
.color
[CONF_MPROMPT
].fg
= COLOR_WHITE
;
246 config
.color
[CONF_MPROMPT
].bg
= COLOR_MAGENTA
;
247 config
.color
[CONF_MPROMPT
].nattrs
= A_BOLD
;
248 config
.color
[CONF_IWINDOW
].fg
= COLOR_WHITE
;
249 config
.color
[CONF_IWINDOW
].bg
= COLOR_BLACK
;
250 config
.color
[CONF_IBORDER
].fg
= COLOR_CYAN
;
251 config
.color
[CONF_IBORDER
].bg
= COLOR_BLACK
;
252 config
.color
[CONF_ITITLE
].fg
= COLOR_WHITE
;
253 config
.color
[CONF_ITITLE
].bg
= COLOR_MAGENTA
;
254 config
.color
[CONF_ITITLE
].nattrs
= A_REVERSE
;
255 config
.color
[CONF_IPROMPT
].fg
= COLOR_WHITE
;
256 config
.color
[CONF_IPROMPT
].bg
= COLOR_MAGENTA
;
257 config
.color
[CONF_IPROMPT
].nattrs
= A_BOLD
;
258 config
.color
[CONF_MENU
].fg
= COLOR_WHITE
;
259 config
.color
[CONF_MENU
].bg
= COLOR_BLACK
;
260 config
.color
[CONF_MENUS
].fg
= COLOR_WHITE
;
261 config
.color
[CONF_MENUS
].bg
= COLOR_RED
;
262 config
.color
[CONF_MENUS
].nattrs
= A_BOLD
;
263 config
.color
[CONF_MENUH
].fg
= COLOR_BLUE
;
264 config
.color
[CONF_MENUH
].bg
= COLOR_YELLOW
;
265 config
.color
[CONF_MENUH
].nattrs
= A_BOLD
;
266 config
.color
[CONF_HISTORY_MENU_LG
].fg
= COLOR_GREEN
;
267 config
.color
[CONF_HISTORY_MENU_LG
].bg
= COLOR_BLACK
;
268 config
.color
[CONF_BCASTLING
].fg
= COLOR_YELLOW
;
269 config
.color
[CONF_BCASTLING
].bg
= COLOR_BLACK
;
270 config
.color
[CONF_BCASTLING
].attrs
= A_BOLD
;
271 config
.color
[CONF_BCASTLING
].nattrs
= A_BOLD
;
272 config
.color
[CONF_BENPASSANT
].fg
= COLOR_MAGENTA
;
273 config
.color
[CONF_BENPASSANT
].bg
= COLOR_BLACK
;
274 config
.color
[CONF_BENPASSANT
].attrs
= A_BOLD
;
275 config
.color
[CONF_BENPASSANT
].nattrs
= A_BOLD
;
276 config
.color
[CONF_BATTACK
].fg
= COLOR_BLUE
;
277 config
.color
[CONF_BATTACK
].bg
= COLOR_BLACK
;
278 config
.color
[CONF_BATTACK
].attrs
= A_BOLD
| A_BLINK
;
279 config
.color
[CONF_BATTACK
].nattrs
= A_REVERSE
;
280 config
.color
[CONF_BPREVMOVE
].fg
= COLOR_WHITE
;
281 config
.color
[CONF_BPREVMOVE
].bg
= COLOR_MAGENTA
;
282 config
.color
[CONF_BPREVMOVE
].nattrs
= A_BOLD
| A_REVERSE
;