Initialize curses colors to colors used by NetHack */
| 329 | |
| 330 | /* Initialize curses colors to colors used by NetHack */ |
| 331 | void |
| 332 | curses_init_nhcolors(void) |
| 333 | { |
| 334 | /* COLOR_foo + 8 means COLOR | A_BOLD when COLORS < 16 */ |
| 335 | /* otherwise assume the terminal has least 16 different colors */ |
| 336 | /* these map to the NetHack CLR_ defines */ |
| 337 | static const int fg_clr[16] = { |
| 338 | COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, |
| 339 | COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE, |
| 340 | -1, COLOR_RED + 8, COLOR_GREEN + 8, COLOR_YELLOW + 8, |
| 341 | COLOR_BLUE + 8, COLOR_MAGENTA + 8, COLOR_CYAN + 8, COLOR_WHITE + 8 |
| 342 | }; |
| 343 | static const int bg_clr[8] = { |
| 344 | -1, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, |
| 345 | COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE |
| 346 | }; |
| 347 | int bg, nhclr; |
| 348 | int maxc = (COLORS >= 16) ? 16 : 8; |
| 349 | |
| 350 | if (!has_colors()) |
| 351 | return; |
| 352 | |
| 353 | use_default_colors(); |
| 354 | |
| 355 | for (nhclr = CLR_BLACK; nhclr < maxc; nhclr++) { |
| 356 | for (bg = 0; bg < 8; bg++) { |
| 357 | init_pair((maxc * bg) + nhclr + 1, fg_clr[nhclr], bg_clr[bg]); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | #ifdef USE_DARKGRAY |
| 362 | if (COLORS >= 16) { |
| 363 | if (iflags.wc2_darkgray) { |
| 364 | init_pair(CLR_BLACK + 1, COLOR_BLACK + 8, -1); |
| 365 | } |
| 366 | } |
| 367 | #endif |
| 368 | colors_used = maxc; |
| 369 | pairs_used = (maxc * 8) + 16 + 1; |
| 370 | } |
| 371 | |
| 372 | #if 0 /* curses_choose_character + curses_character_dialog no longer used */ |
| 373 |
no outgoing calls
no test coverage detected