5 * MuCurses window attribute functions
9 FILE_LICENCE ( GPL2_OR_LATER );
12 * Get the background rendition attributes for a window
14 * @v *win subject window
15 * @ret ch chtype rendition representation
17 inline chtype getbkgd ( WINDOW *win ) {
22 * Turn off attributes in a window
24 * @v win subject window
25 * @v attrs attributes to enable
26 * @ret rc return status code
28 int wattroff ( WINDOW *win, int attrs ) {
34 * Turn on attributes in a window
36 * @v win subject window
37 * @v attrs attributes to enable
38 * @ret rc return status code
40 int wattron ( WINDOW *win, int attrs ) {
46 * Set attributes in a window
48 * @v win subject window
49 * @v attrs attributes to enable
50 * @ret rc return status code
52 int wattrset ( WINDOW *win, int attrs ) {
53 win->attrs = ( attrs | ( win->attrs & A_COLOR ) );
58 * Get attributes and colour pair information
60 * @v *win window to obtain information from
61 * @v *attrs address in which to store attributes
62 * @v *pair address in which to store colour pair
63 * @v *opts undefined (for future implementation)
64 * @ret rc return status cude
66 int wattr_get ( WINDOW *win, attr_t *attrs, short *pair,
67 void *opts __unused ) {
68 *attrs = win->attrs & A_ATTRIBUTES;
69 *pair = PAIR_NUMBER ( win->attrs );
74 * Turn off attributes in a window
76 * @v *win subject window
77 * @v attrs attributes to toggle
78 * @v *opts undefined (for future implementation)
79 * @ret rc return status code
81 int wattr_off ( WINDOW *win, attr_t attrs,
82 void *opts __unused ) {
83 wattroff( win, attrs );
88 * Turn on attributes in a window
90 * @v *win subject window
91 * @v attrs attributes to toggle
92 * @v *opts undefined (for future implementation)
93 * @ret rc return status code
95 int wattr_on ( WINDOW *win, attr_t attrs,
96 void *opts __unused ) {
97 wattron( win, attrs );
102 * Set attributes and colour pair information in a window
104 * @v *win subject window
105 * @v attrs attributes to set
106 * @v cpair colour pair to set
107 * @v *opts undefined (for future implementation)
108 * @ret rc return status code
110 int wattr_set ( WINDOW *win, attr_t attrs, short cpair,
111 void *opts __unused ) {
112 wattrset( win, attrs | COLOUR_PAIR ( cpair ) );
117 * Set colour pair for a window
119 * @v *win subject window
120 * @v colour_pair_number colour pair integer
121 * @v *opts undefined (for future implementation)
122 * @ret rc return status code
124 int wcolour_set ( WINDOW *win, short colour_pair_number,
125 void *opts __unused ) {
126 if ( ( unsigned short )colour_pair_number > COLOUR_PAIRS )
129 win->attrs = ( ( win->attrs & A_ATTRIBUTES ) |
130 COLOUR_PAIR ( colour_pair_number ) );