iPXE
colour.c
Go to the documentation of this file.
00001 #include <curses.h>
00002 
00003 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00004 
00005 struct colour_pair {
00006         short fcol;
00007         short bcol;
00008 };
00009 
00010 static struct colour_pair cpairs[COLOUR_PAIRS] = {
00011         [0] = { COLOUR_WHITE, COLOUR_BLACK },
00012 };
00013 
00014 /**
00015  * Identify the RGB components of a given colour value
00016  *
00017  * @v colour    colour value
00018  * @v *red      address to store red component
00019  * @v *green    address to store green component
00020  * @v *blue     address to store blue component
00021  * @ret rc      return status code
00022  */
00023 int colour_content ( short colour, short *red, short *green, short *blue ) {
00024         *red = ( ( colour & COLOUR_RED ) ? 1 : 0 );
00025         *green = ( ( colour & COLOUR_GREEN ) ? 1 : 0 );
00026         *blue = ( ( colour & COLOUR_BLUE ) ? 1 : 0 );
00027         return OK;
00028 }
00029 
00030 /**
00031  * Initialise colour pair
00032  *
00033  * @v pair      colour pair number
00034  * @v fcol      foreground colour
00035  * @v bcol      background colour
00036  */
00037 int init_pair ( short pair, short fcol, short bcol ) {
00038         struct colour_pair *cpair;
00039 
00040         if ( ( pair < 1 ) || ( pair >= COLOUR_PAIRS ) )
00041                 return ERR;
00042         
00043         cpair = &cpairs[pair];
00044         cpair->fcol = fcol;
00045         cpair->bcol = bcol;
00046         return OK;
00047 }
00048 
00049 /**
00050  * Get colours of colour pair
00051  *
00052  * @v pair      colour pair number
00053  * @ret fcol    foreground colour
00054  * @ret bcol    background colour
00055  */
00056 int pair_content ( short pair, short *fcol, short *bcol ) {
00057         struct colour_pair *cpair;
00058 
00059         if ( ( pair < 0 ) || ( pair >= COLOUR_PAIRS ) )
00060                 return ERR;
00061         
00062         cpair = &cpairs[pair];
00063         *fcol = cpair->fcol;
00064         *bcol = cpair->bcol;
00065         return OK;
00066 }