iPXE
winattrs.c
Go to the documentation of this file.
00001 #include <curses.h>
00002 
00003 /** @file
00004  *
00005  * MuCurses window attribute functions
00006  *
00007  */
00008 
00009 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00010 
00011 /**
00012  * Get the background rendition attributes for a window
00013  *
00014  * @v *win      subject window
00015  * @ret ch      chtype rendition representation
00016  */
00017 inline chtype getbkgd ( WINDOW *win ) {
00018         return win->attrs;
00019 }
00020 
00021 /**
00022  * Turn off attributes in a window
00023  *
00024  * @v win       subject window
00025  * @v attrs     attributes to enable
00026  * @ret rc      return status code
00027  */
00028 int wattroff ( WINDOW *win, int attrs ) {
00029         win->attrs &= ~attrs;
00030         return OK;
00031 }
00032 
00033 /**
00034  * Turn on attributes in a window
00035  *
00036  * @v win       subject window
00037  * @v attrs     attributes to enable
00038  * @ret rc      return status code
00039  */
00040 int wattron ( WINDOW *win, int attrs ) {
00041         win->attrs |= attrs;
00042         return OK;
00043 }
00044 
00045 /**
00046  * Set attributes in a window
00047  *
00048  * @v win       subject window
00049  * @v attrs     attributes to enable
00050  * @ret rc      return status code
00051  */
00052 int wattrset ( WINDOW *win, int attrs ) {
00053         win->attrs = ( attrs | ( win->attrs & A_COLOR ) );
00054         return OK;
00055 }
00056 
00057 /**
00058  * Get attributes and colour pair information
00059  *
00060  * @v *win      window to obtain information from
00061  * @v *attrs    address in which to store attributes
00062  * @v *pair     address in which to store colour pair
00063  * @v *opts     undefined (for future implementation)
00064  * @ret rc      return status cude
00065  */
00066 int wattr_get ( WINDOW *win, attr_t *attrs, short *pair, 
00067                 void *opts __unused ) {
00068         *attrs = win->attrs & A_ATTRIBUTES;
00069         *pair = PAIR_NUMBER ( win->attrs );
00070         return OK;
00071 }
00072 
00073 /**
00074  * Turn off attributes in a window
00075  *
00076  * @v *win      subject window
00077  * @v attrs     attributes to toggle
00078  * @v *opts     undefined (for future implementation)
00079  * @ret rc      return status code
00080  */
00081 int wattr_off ( WINDOW *win, attr_t attrs, 
00082                 void *opts __unused ) {
00083         wattroff( win, attrs );
00084         return OK;
00085 }
00086 
00087 /**
00088  * Turn on attributes in a window
00089  *
00090  * @v *win      subject window
00091  * @v attrs     attributes to toggle
00092  * @v *opts     undefined (for future implementation)
00093  * @ret rc      return status code
00094  */
00095 int wattr_on ( WINDOW *win, attr_t attrs, 
00096                void *opts __unused ) {
00097         wattron( win, attrs );
00098         return OK;
00099 }
00100 
00101 /**
00102  * Set attributes and colour pair information in a window
00103  *
00104  * @v *win      subject window
00105  * @v attrs     attributes to set
00106  * @v cpair     colour pair to set
00107  * @v *opts     undefined (for future implementation)
00108  * @ret rc      return status code
00109  */
00110 int wattr_set ( WINDOW *win, attr_t attrs, short cpair, 
00111                 void *opts __unused ) {
00112         wattrset( win, attrs | COLOUR_PAIR ( cpair ) );
00113         return OK;
00114 }
00115 
00116 /**
00117  * Set colour pair for a window
00118  *
00119  * @v *win                      subject window
00120  * @v colour_pair_number        colour pair integer
00121  * @v *opts                     undefined (for future implementation)
00122  * @ret rc                      return status code
00123  */
00124 int wcolour_set ( WINDOW *win, short colour_pair_number, 
00125                   void *opts __unused ) {
00126         if ( ( unsigned short )colour_pair_number > COLOUR_PAIRS )
00127                 return ERR;
00128 
00129         win->attrs = ( ( win->attrs & A_ATTRIBUTES ) |
00130                        COLOUR_PAIR ( colour_pair_number ) );
00131         return OK;
00132 }
00133