ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/frontend/client/render_glyph.cpp
Revision: 1.1
Committed: Sun Oct 17 08:15:12 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Log Message:
initial import

File Contents

# User Rev Content
1 sf-pippijn 1.1 #include "dclient/render_glyph.h"
2    
3     #include <ncurses/color.hh>
4     #include <ncurses/pen.hh>
5    
6     static ncurses::color const &
7     colors (int fg, int bg)
8     {
9     static ncurses::color const colors[] = {
10     { COLOR_WHITE, COLOR_BLACK, WA_NORMAL }, // reset
11     { COLOR_WHITE, COLOR_BLACK, WA_NORMAL }, // black => 0,
12     { COLOR_WHITE, COLOR_BLACK, WA_BOLD }, // white => 1,
13     { COLOR_BLUE, COLOR_BLACK, WA_NORMAL }, // navy => 2,
14     { COLOR_RED, COLOR_BLACK, WA_NORMAL }, // red => 3,
15     { COLOR_RED, COLOR_BLACK, WA_BOLD }, // orange => 4,
16     { COLOR_BLUE, COLOR_BLACK, WA_BOLD }, // blue => 5,
17     { COLOR_RED, COLOR_BLACK, WA_NORMAL }, // darkorange => 6,
18     { COLOR_GREEN, COLOR_BLACK, WA_NORMAL }, // green => 7,
19     { COLOR_GREEN, COLOR_BLACK, WA_BOLD }, // lightgreen => 8,
20     { COLOR_BLACK, COLOR_BLACK, WA_BOLD }, // grey => 9,
21     { COLOR_YELLOW, COLOR_BLACK, WA_NORMAL }, // brown => 10,
22     { COLOR_YELLOW, COLOR_BLACK, WA_BOLD }, // gold => 11,
23     { COLOR_CYAN, COLOR_BLACK, WA_NORMAL }, // tan => 12,
24     };
25    
26     return colors[fg + 1];
27     }
28    
29     void
30     write (ncurses::pen &pen, data::glyph const &glyph, u16 darkness)
31     {
32     pen.set_color (darkness < 50 ? colors (9, 0) : colors (glyph.fg, glyph.bg));
33     pen.write (glyph.text);
34     pen.set_color (colors (-1, -1)); // reset
35     }