+++ /dev/null
-#include <curses.h>
-
-#include "block.h"
-
-typedef enum {
- _black = 0,
- _blue,
- _green,
- _cyan,
- _red,
- _magenta,
- _yellow,
- _white
-} _color_t;
-
-static int _color_num (int fg, int bg)
-{
- return (1 << 6) | ((7 & bg) << 3) | (7 & fg);
-}
-static int _color_trans (_color_t c)
-{
- int color;
- switch (7 & c) {
- case _black:
- color = COLOR_BLACK;
- break;
- case _blue:
- color = COLOR_BLUE;
- break;
- case _green:
- color = COLOR_GREEN;
- break;
- case _cyan:
- color = COLOR_CYAN;
- break;
- case _red:
- color = COLOR_RED;
- break;
- case _magenta:
- color = COLOR_MAGENTA;
- break;
- case _yellow:
- color = COLOR_YELLOW;
- break;
- case _white:
- color = COLOR_WHITE;
- break;
- }
- return color;
-}
-
-static void _init_color_pairs () {
- int fg, bg;
- for (bg = 0; bg < 8; bg++) {
- for (fg = 0; fg < 8; fg ++) {
- init_pair (_color_num (fg, bg), _color_trans (fg), _color_trans (bg));
- }
- }
-}
-
-void mvaddcb (int y, int x, cblock_t color)
-{
- int init = 1;
- if (init) {
- _init_color_pairs ();
- init = 0;
- }
-
- int symb = ACS_CKBOARD;
- switch (color) {
- case black:
- case gray:
- case blue:
- case green:
- case cyan:
- case red:
- case magenta:
- case brown:
- symb = ' ';
- break;
- default:
- symb = ACS_CKBOARD;
- }
-
- int num;
- switch (color) {
- case black:
- case darkgray:
- num = _color_num (_white, _black);
- break;
- case gray:
- case white:
- num = _color_num (_white, _white);
- break;
- case darkerblue:
- case darkblue:
- num = _color_num (_blue, _black);
- break;
- case darkergreen:
- case darkgreen:
- num = _color_num (_green, _black);
- break;
- case darkercyan:
- case darkcyan:
- num = _color_num (_cyan, _black);
- break;
- case darkerred:
- case darkred:
- num = _color_num (_red, _black);
- break;
- case darkermagenta:
- case darkmagenta:
- num = _color_num (_magenta, _black);
- break;
- case darkbrown:
- case darkeryellow:
- num = _color_num (_yellow, _black);
- break;
- case blue:
- case lightblue:
- case lighterblue:
- num = _color_num (_blue, _white);
- break;
- case green:
- case lightgreen:
- case lightergreen:
- num = _color_num (_green, _white);
- break;
- case cyan:
- case lightcyan:
- case lightercyan:
- num = _color_num (_cyan, _white);
- break;
- case red:
- case lightred:
- case lighterred:
- num = _color_num (_red, _white);
- break;
- case magenta:
- case lightmagenta:
- case lightermagenta:
- num = _color_num (_magenta, _white);
- break;
- case brown:
- case darkyellow:
- case yellow:
- num = _color_num (_yellow, _white);
- break;
- //default:
- // num = _color_num (_white, _black);
- }
-
- int state;
- switch (color) {
- case blue:
- case green:
- case cyan:
- case red:
- case magenta:
- case brown:
- state = A_REVERSE;
- break;
- case white:
- case darkblue:
- case darkgreen:
- case darkcyan:
- case darkred:
- case darkmagenta:
- case darkeryellow:
- case lighterblue:
- case lightergreen:
- case lightercyan:
- case lighterred:
- case lightermagenta:
- case yellow:
- state = A_BOLD;
- break;
- default:
- state = A_NORMAL;
- }
-
- attron (COLOR_PAIR (num) | state);
- mvaddch (y, x, symb);
- attroff (COLOR_PAIR (num) | state);
-}
-
-/* vim: set ts=4 sw=4 et: */