iPXE
winattrs.c
Go to the documentation of this file.
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  */
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 
MuCurses header file.
#define COLOUR_PAIR(n)
Definition: curses.h:151
#define COLOUR_PAIRS
Definition: curses.h:155
int wattrset(WINDOW *win, int attrs)
Set attributes in a window.
Definition: winattrs.c:52
Curses Window struct.
Definition: curses.h:89
#define A_ATTRIBUTES
Definition: curses.h:146
int wattr_get(WINDOW *win, attr_t *attrs, short *pair, void *opts __unused)
Get attributes and colour pair information.
Definition: winattrs.c:66
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
chtype getbkgd(WINDOW *win)
Get the background rendition attributes for a window.
Definition: winattrs.c:17
int wcolour_set(WINDOW *win, short colour_pair_number, void *opts __unused)
Set colour pair for a window.
Definition: winattrs.c:124
Definition: sis900.h:208
uint32_t attr_t
Definition: curses.h:30
#define ERR
Definition: curses.h:18
int wattr_off(WINDOW *win, attr_t attrs, void *opts __unused)
Turn off attributes in a window.
Definition: winattrs.c:81
int wattr_on(WINDOW *win, attr_t attrs, void *opts __unused)
Turn on attributes in a window.
Definition: winattrs.c:95
#define __unused
Declare a variable or data structure as unused.
Definition: compiler.h:573
uint32_t attrs
Extended attributes (optional)
Definition: memmap.c:32
attr_t attrs
window attributes
Definition: curses.h:93
int wattron(WINDOW *win, int attrs)
Turn on attributes in a window.
Definition: winattrs.c:40
#define A_COLOR
Definition: curses.h:149
uint32_t chtype
Definition: curses.h:29
int wattr_set(WINDOW *win, attr_t attrs, short cpair, void *opts __unused)
Set attributes and colour pair information in a window.
Definition: winattrs.c:110
int wattroff(WINDOW *win, int attrs)
Turn off attributes in a window.
Definition: winattrs.c:28
static union @438 opts
"cert<xxx>" option list
#define PAIR_NUMBER(attrs)
Definition: curses.h:153