[prefix] Use garbage-collectable section names
[ipxe.git] / src / hci / mucurses / winattrs.c
1 #include <curses.h>
2
3 /** @file
4 *
5 * MuCurses window attribute functions
6 *
7 */
8
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10
11 /**
12 * Get the background rendition attributes for a window
13 *
14 * @v *win subject window
15 * @ret ch chtype rendition representation
16 */
17 inline chtype getbkgd ( WINDOW *win ) {
18 return win->attrs;
19 }
20
21 /**
22 * Turn off attributes in a window
23 *
24 * @v win subject window
25 * @v attrs attributes to enable
26 * @ret rc return status code
27 */
28 int wattroff ( WINDOW *win, int attrs ) {
29 win->attrs &= ~attrs;
30 return OK;
31 }
32
33 /**
34 * Turn on attributes in a window
35 *
36 * @v win subject window
37 * @v attrs attributes to enable
38 * @ret rc return status code
39 */
40 int wattron ( WINDOW *win, int attrs ) {
41 win->attrs |= attrs;
42 return OK;
43 }
44
45 /**
46 * Set attributes in a window
47 *
48 * @v win subject window
49 * @v attrs attributes to enable
50 * @ret rc return status code
51 */
52 int wattrset ( WINDOW *win, int attrs ) {
53 win->attrs = ( attrs | ( win->attrs & A_COLOR ) );
54 return OK;
55 }
56
57 /**
58 * Get attributes and colour pair information
59 *
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
65 */
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 );
70 return OK;
71 }
72
73 /**
74 * Turn off attributes in a window
75 *
76 * @v *win subject window
77 * @v attrs attributes to toggle
78 * @v *opts undefined (for future implementation)
79 * @ret rc return status code
80 */
81 int wattr_off ( WINDOW *win, attr_t attrs,
82 void *opts __unused ) {
83 wattroff( win, attrs );
84 return OK;
85 }
86
87 /**
88 * Turn on attributes in a window
89 *
90 * @v *win subject window
91 * @v attrs attributes to toggle
92 * @v *opts undefined (for future implementation)
93 * @ret rc return status code
94 */
95 int wattr_on ( WINDOW *win, attr_t attrs,
96 void *opts __unused ) {
97 wattron( win, attrs );
98 return OK;
99 }
100
101 /**
102 * Set attributes and colour pair information in a window
103 *
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
109 */
110 int wattr_set ( WINDOW *win, attr_t attrs, short cpair,
111 void *opts __unused ) {
112 wattrset( win, attrs | COLOUR_PAIR ( cpair ) );
113 return OK;
114 }
115
116 /**
117 * Set colour pair for a window
118 *
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
123 */
124 int wcolour_set ( WINDOW *win, short colour_pair_number,
125 void *opts __unused ) {
126 if ( ( unsigned short )colour_pair_number > COLOUR_PAIRS )
127 return ERR;
128
129 win->attrs = ( ( win->attrs & A_ATTRIBUTES ) |
130 COLOUR_PAIR ( colour_pair_number ) );
131 return OK;
132 }
133