[prefix] Use garbage-collectable section names
[ipxe.git] / src / hci / mucurses / colour.c
1 #include <curses.h>
2
3 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
4
5 struct colour_pair {
6 short fcol;
7 short bcol;
8 };
9
10 static struct colour_pair cpairs[COLOUR_PAIRS] = {
11 [0] = { COLOUR_WHITE, COLOUR_BLACK },
12 };
13
14 /**
15 * Identify the RGB components of a given colour value
16 *
17 * @v colour colour value
18 * @v *red address to store red component
19 * @v *green address to store green component
20 * @v *blue address to store blue component
21 * @ret rc return status code
22 */
23 int colour_content ( short colour, short *red, short *green, short *blue ) {
24 *red = ( ( colour & COLOUR_RED ) ? 1 : 0 );
25 *green = ( ( colour & COLOUR_GREEN ) ? 1 : 0 );
26 *blue = ( ( colour & COLOUR_BLUE ) ? 1 : 0 );
27 return OK;
28 }
29
30 /**
31 * Initialise colour pair
32 *
33 * @v pair colour pair number
34 * @v fcol foreground colour
35 * @v bcol background colour
36 */
37 int init_pair ( short pair, short fcol, short bcol ) {
38 struct colour_pair *cpair;
39
40 if ( ( pair < 1 ) || ( pair >= COLOUR_PAIRS ) )
41 return ERR;
42
43 cpair = &cpairs[pair];
44 cpair->fcol = fcol;
45 cpair->bcol = bcol;
46 return OK;
47 }
48
49 /**
50 * Get colours of colour pair
51 *
52 * @v pair colour pair number
53 * @ret fcol foreground colour
54 * @ret bcol background colour
55 */
56 int pair_content ( short pair, short *fcol, short *bcol ) {
57 struct colour_pair *cpair;
58
59 if ( ( pair < 0 ) || ( pair >= COLOUR_PAIRS ) )
60 return ERR;
61
62 cpair = &cpairs[pair];
63 *fcol = cpair->fcol;
64 *bcol = cpair->bcol;
65 return OK;
66 }