iPXE
editbox.h
Go to the documentation of this file.
1 #ifndef _IPXE_EDITBOX_H
2 #define _IPXE_EDITBOX_H
3 
4 /** @file
5  *
6  * Editable text box widget
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <curses.h>
13 #include <ipxe/editstring.h>
14 #include <ipxe/widget.h>
15 
16 /** An editable text box widget */
17 struct edit_box {
18  /** Text widget */
19  struct widget widget;
20  /** Editable string */
22  /** First displayed character */
23  unsigned int first;
24 };
25 
27 
28 /**
29  * Initialise text box widget
30  *
31  * @v box Editable text box widget
32  * @v row Row
33  * @v col Starting column
34  * @v width Width
35  * @v flags Flags
36  * @v buf Dynamically allocated string buffer
37  */
38 static inline __attribute__ (( always_inline )) void
39 init_editbox ( struct edit_box *box, unsigned int row, unsigned int col,
40  unsigned int width, unsigned int flags, char **buf ) {
41 
42  init_widget ( &box->widget, &editbox_operations, row, col,
43  width, ( flags | WIDGET_EDITABLE ) );
44  init_editstring ( &box->string, buf );
45  if ( *buf )
46  box->string.cursor = strlen ( *buf );
47 }
48 
49 #endif /* _IPXE_EDITBOX_H */
MuCurses header file.
Editable strings.
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:69
int box(WINDOW *win, chtype verch, chtype horch)
Draw borders from single-byte characters and renditions around a window.
Definition: edging.c:22
struct widget_operations editbox_operations
Text box widget operations.
Definition: editbox.c:100
Widget may have input focus.
Definition: widget.h:32
struct edit_box __attribute__
static __nonnull void init_editstring(struct edit_string *string, char **buf)
Initialise editable string.
Definition: editstring.h:46
An editable text box widget.
Definition: editbox.h:17
uint8_t flags
Flags.
Definition: ena.h:18
Text widget operations.
Definition: widget.h:38
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
Text widgets.
static void init_editbox(struct edit_box *box, unsigned int row, unsigned int col, unsigned int width, unsigned int flags, char **buf)
Initialise text box widget.
Definition: editbox.h:39
unsigned int first
First displayed character.
Definition: editbox.h:23
An editable string.
Definition: editstring.h:13
A text widget.
Definition: widget.h:15
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct edit_string string
Editable string.
Definition: editbox.h:21