iPXE
colour.c
Go to the documentation of this file.
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 }
MuCurses header file.
#define COLOUR_RED
Definition: curses.h:185
#define COLOUR_PAIRS
Definition: curses.h:155
#define COLOUR_WHITE
Definition: curses.h:191
#define COLOUR_BLACK
Definition: curses.h:184
Definition: sis900.h:208
#define ERR
Definition: curses.h:18
#define COLOUR_GREEN
Definition: curses.h:186
#define colour
Colour for debug messages.
Definition: acpi.c:39
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int colour_content(short colour, short *red, short *green, short *blue)
Identify the RGB components of a given colour value.
Definition: colour.c:23
short bcol
Definition: colour.c:7
int init_pair(short pair, short fcol, short bcol)
Initialise colour pair.
Definition: colour.c:37
short fcol
Definition: colour.c:6
static struct colour_pair cpairs[COLOUR_PAIRS]
Definition: colour.c:10
#define COLOUR_BLUE
Definition: curses.h:188
int pair_content(short pair, short *fcol, short *bcol)
Get colours of colour pair.
Definition: colour.c:56