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
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11FILE_SECBOOT ( PERMITTED );
12
13#include <curses.h>
14
15/** A text widget */
16struct 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 */
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 */
69static 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;
79}
80
81/**
82 * Draw text widget
83 *
84 * @v widget Text widget
85 */
86static inline __attribute__ (( always_inline )) void
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 */
103static inline __attribute__ (( always_inline )) int
104edit_widget ( struct widget *widget, int key ) {
105
106 return widget->op->edit ( widget, key );
107}
108
109#endif /* _IPXE_WIDGET_H */
union @162305117151260234136356364136041353210355154177 key
Sense key.
Definition scsi.h:3
MuCurses header file.
uint8_t flags
Flags.
Definition ena.h:7
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define __attribute__(x)
Definition compiler.h:10
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
Text widget operations.
Definition widget.h:39
int(* edit)(struct widget *widget, int key)
Edit widget.
Definition widget.h:57
void(* draw)(struct widget *widget)
Draw widget.
Definition widget.h:45
A text widget.
Definition widget.h:16
struct widget_operations * op
Widget operations.
Definition widget.h:18
unsigned int col
Starting column.
Definition widget.h:23
unsigned int width
Width.
Definition widget.h:25
unsigned int flags
Flags.
Definition widget.h:27
unsigned int row
Row.
Definition widget.h:21
static void draw_widget(struct widget *widget)
Draw text widget.
Definition widget.h:87
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
static int edit_widget(struct widget *widget, int key)
Edit text widget.
Definition widget.h:104
widget_flags
Text widget flags.
Definition widget.h:31
@ WIDGET_SECRET
Widget contains a secret.
Definition widget.h:35
@ WIDGET_EDITABLE
Widget may have input focus.
Definition widget.h:33