iPXE
widget.h
Go to the documentation of this file.
1 #ifndef _IPXE_WIDGET_H
2 #define _IPXE_WIDGET_H
3 
4 /** @file
5  *
6  * Text widgets
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 FILE_SECBOOT ( PERMITTED );
12 
13 #include <curses.h>
14 
15 /** A text widget */
16 struct widget {
17  /** Widget operations */
19 
20  /** Row */
21  unsigned int row;
22  /** Starting column */
23  unsigned int col;
24  /** Width */
25  unsigned int width;
26  /** Flags */
27  unsigned int flags;
28 };
29 
30 /** Text widget flags */
32  /** Widget may have input focus */
33  WIDGET_EDITABLE = 0x0001,
34  /** Widget contains a secret */
35  WIDGET_SECRET = 0x0002,
36 };
37 
38 /** Text widget operations */
40  /**
41  * Draw widget
42  *
43  * @v widget Text widget
44  */
45  void ( * draw ) ( struct widget *widget );
46  /**
47  * Edit widget
48  *
49  * @v widget Text widget
50  * @v key Key pressed by user
51  * @ret key Key returned to application, or zero
52  *
53  * This will not update the display: you must call the draw()
54  * method to ensure that any changes to an editable widget are
55  * displayed to the user.
56  */
57  int ( * edit ) ( struct widget *widget, int key );
58 };
59 
60 /**
61  * Initialise text widget
62  *
63  * @v widget Text widget
64  * @v op Text widget operations
65  * @v row Row
66  * @v col Starting column
67  * @v width Width
68  */
69 static inline __attribute__ (( always_inline )) void
71  unsigned int row, unsigned int col, unsigned int width,
72  unsigned int flags ) {
73 
74  widget->op = op;
75  widget->row = row;
76  widget->col = col;
77  widget->width = width;
78  widget->flags = flags;
79 }
80 
81 /**
82  * Draw text widget
83  *
84  * @v widget Text widget
85  */
86 static inline __attribute__ (( always_inline )) void
87 draw_widget ( struct widget *widget ) {
88 
89  widget->op->draw ( widget );
90 }
91 
92 /**
93  * Edit text widget
94  *
95  * @v widget Text widget
96  * @v key Key pressed by user
97  * @ret key Key returned to application, or zero
98  *
99  * This will not update the display: you must call draw_widget() to
100  * ensure that any changes to an editable widget are displayed to the
101  * user.
102  */
103 static inline __attribute__ (( always_inline )) int
104 edit_widget ( struct widget *widget, int key ) {
105 
106  return widget->op->edit ( widget, key );
107 }
108 
109 #endif /* _IPXE_WIDGET_H */
MuCurses header file.
static void init_widget(struct widget *widget, struct widget_operations *op, unsigned int row, unsigned int col, unsigned int width, unsigned int flags)
Initialise text widget.
Definition: widget.h:70
#define __attribute__(x)
Definition: compiler.h:10
static void draw_widget(struct widget *widget)
Draw text widget.
Definition: widget.h:87
unsigned int width
Width.
Definition: widget.h:25
unsigned int flags
Flags.
Definition: widget.h:27
void(* draw)(struct widget *widget)
Draw widget.
Definition: widget.h:45
Widget contains a secret.
Definition: widget.h:35
Widget may have input focus.
Definition: widget.h:33
FILE_SECBOOT(PERMITTED)
uint8_t flags
Flags.
Definition: ena.h:18
Text widget operations.
Definition: widget.h:39
unsigned int col
Starting column.
Definition: widget.h:23
widget_flags
Text widget flags.
Definition: widget.h:31
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
unsigned int row
Row.
Definition: widget.h:21
A text widget.
Definition: widget.h:16
struct widget_operations * op
Widget operations.
Definition: widget.h:18
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static int edit_widget(struct widget *widget, int key)
Edit text widget.
Definition: widget.h:104
int(* edit)(struct widget *widget, int key)
Edit widget.
Definition: widget.h:57
union @391 key
Sense key.
Definition: scsi.h:18